Proportional image size changing without quality decreasing in TImage - delphi

I have TImage 800x600 with image 1024x768.
TImage aligns to alClient.
Timage is proportional.
TImage is streched.
When I resize the form, the image resizes too, but it's quality makes lower and the visible text labels on the Image shrinks, makes unreadable, or even after load big image into small TImage, I have the same problem.
How I can resolve that? How resize image in TImage with quality where text still readable in any normal size?(e.g. 1024x768 resized to 500x400, and text still readable in it).

You cannot hope to resize raster graphics and maintain high quality text. Text is rendered to a specific resolution. Any resampling will destroy the quality of the text. The only way to maintain high quality text through a resize operation is to re-render the text at the new resolution. One way to achieve that is to use a vector graphics format rather than raster. Another way is to be able to re-create the text on the fly.

TImage resizing is not perfect. I prefer to keep the original image in the memory, and to use, say, bicubic resizing when needed (or bilinear for shrinkink). Once you resized the image just draw it to the TImage on the form.
Always keep the original image in the memory, and discard the resized one from the memory once you draw it.

Related

Sharp UILabel after zooming image

I don't know what to ask exactly. I put a text on an UIImage (with aspect fit content) and save it to album. If saved image is same size as aspect content mode then "text" seems OK. But after zooming in that image, text on that image gets blurred. I want it to be sharp also. Is it possible to do that?
Is it possible to increase pixel count per point? Or What should I do?
Edit: I think I need to increase font size without increasing frame. Is it possible to increase font size (for example from 20 to 50) without changing label's frame size.
Thank you.
If the image is saved as a bitmap, there's not much you can do. The best suggestion I can make is to render it at larger than the target size and save THAT to the photo album. Normally it will be scaled smaller, which looks good. Then when the user zooms in, the text will still be sharp because you will be revealing text rendered at the larger size.
The down-side, of course, is file size and memory footprint. Larger images take more storage, more memory, and more CPU horsepower to display.
I seriously doubt if the iOS photo album supports any vector formats (PDF, illustrator, etc.) If they did that would be another possibility, but like I said, probably not.

When iOS shrinks an image, does it clip/pixelate it?

I have 2 relatively small pngs that will be images inside UIButtons.
Once our app is finished, we might want to resize the buttons and make them smaller.
Now, we can easily do this by resizing the button frame; the system automatically re-sizes the images smaller.
Would the system's autoresize cause the image to look ugly after shrinking the image? (i.e., would it clip pixels and make it look less smooth than if I were to shrink it in a photo editor myself?)
Or would it better to make the image the sizes they are intended to be?
It is always best to make the images of correct size from the beginning. All resize-functions will have negative impact on the end result. If you scale it up to a larger image it will be a big different, but even if you scale it down to a smaller it is usually creating visible noise in the image. Let's say that you have a line of one pixel in your image. scale it down to 90% of the original size, this line will just use 90% of a pixel wide and other parts of the images will influence the colors of the same pixels.

How to get rid of empty transparent areas in a PNG image so that it conforms to actual image size?

I have a series of images that I would look to loop through using iOS's [UIView startAnimating]. My trouble is that, when I exported the images, they all came standard in a 240x160 size, although only 50x50 contains the actual image, the rest being transparent parts that are just taking up space.
When I set the frame of the image automatically using image.size.width and image.size.height, iOS takes into images' original size of 240x160, so I am unable to get a frame that conforms to the actual parts of the image. I was wondering if there is a way using Illustrator or Photoshop, or any other graphics editing software for me to export the images based on their natural dimensions, and not a fixed dimension. Thanks!
I am a fan of vector graphics and thinks everything in the world should be vector ;-) so here is what you do in illustrator: file - document setup - edit artboards. Then click on the image, and the artboard should adjust to the exact size. You can of course have multiple artboards, or simply operate with one artboard and however-many images.

UIButton Image size

I have 2 UIButtons. I set the background images to 2 different pngs. The pngs have different width. I looks like this:
The button size is set to the images.size.width and height.
I would like these buttons to be the same size, but when I resize the buttons manually, the images gets distorted, like this:
Is it possible to resize my buttons without distorting the image? Since it's a picture, I thought stretching doesn't make sense.
Any help would be appreciated.
Thanks!
As you guessed, you are stretching the pictures size by resizing the buttons. If I was you, I would look into manually resizing the images so that they are the same dimensions as your buttons.
Without distorting or ruining the integrity of the image the only real solution would be to add more padding to the right and left of the "delete" button.
Other options (which I personally would not reccomend) would include:
split the "Reschedule" into two lines and shrink the alarm clock, so it would read:
Re-
Schedule
Enlarge the trashcan icon manually (this will even them out a little more)
Manually shrink the size of the reschedule icon (your legibility will suffer)
Regardless of the route you take I would resize or edit the original files in a program such as Photoshop or Fireworks to preserve the integrity of the UI elements. Be sure to scale proportionally in those programs to avoid more distortion and stretching.

Avoiding blended layers when using resizableImages on iOS

I'm trying to avoid blended layers on iOS to improve performance. However, I notice that the resizable image I'm using for the backgroundView of my UITableViewCell is being marked as a blended layer:
In fact, using any resizable image--even a JPEG with no transparency--caused layer blending, as seen in this screenshot where first a PNG and then a JPEG is used as a resizable image in a UIImageView. The only resizable image that didn't require a blended layer was a 1x1 pixel image, seen at the bottom:
Is there any way to avoid this? Core Animation profiling is imprecise art (atleast to me), but I think it's a main contributor to dropping to around 25 FPS when scrolling my table view.
Edit2: Upon more experimentation, I found that if I only vertically or horizontally stretched the images (either a PNG or JPG), they weren't marked as blended layers. However, upon even more experimentatio I think this may be because the images only stretched in one dimension are smaller. My image is not being treated as blended at 100x100, but it is at 150x100.
I created a very wide image and only stretched it vertically. This did not require blended layers, and achieves the correct effect for my table view cell. This isn't ideal, but because of the small height it's still only 236 bytes for the retina image.

Resources