How to compress subpixel text bitmap - compression

Recently, I am doing jobs about Windows clearType text compression; Windows text font use sub-pixel rendering tech which making the text font edge full of mess colors, like below.
I have try the jpeg, zstd, lz4, the compression ratio of them cannot satisfied me ,SO anyone have experience or ideas to compress this type of bitmap, lossy or lossless?

Related

Shrink the size of a .png file

There are many programs that claim to reduce the size of a .png file but none of the well known ones, optipng , pngcrush , pngquant, allow me to shrink to a specified size. pngcrush tried its hardest, but the result was still way to big for my needs. For .jpg files, jpegoptim has an -m option that does allow me to shrink to the size I need. The obvious solution seemed to be to convert to jpg, shrink to the right size, then convert back, but that doesn't work either, the reconstituted .png file just jumps back to its original size.
Presumably, this has something to do with the structure of .png files.
Is there any way to get a small png file? This png file is an example of something i need to shrink to below 1K bytes.
Thanks for any suggestions!
Use ImageMagick to reduce the colors, then pngcrush to get rid of ancillary chunks:
magick in.png -colors 8 temp.png
pngcrush -rem alla temp.png out.png
results in a 1621-byte file. If you have an older version of ImageMagick, use "convert" instead of "magick". Using "-colors 4" instead of "-colors 8" gets you a 1015-byte file, but the dithering looks very spotty.
Note that these preserve the transparency in the image, while converting to JPEG loses the transparency and makes the background a solid color.
The only solution to your problem that I can think of is to use .jpg instead of .png. The .jpg format was mainly created for its high lossy compression but still gets a good enough image. On the other hand, .png is going for the full transparency and no quality loss. To sum it all up, .jpg is ideal for getting smaller files if quality doesn't matter, and .png is perfect for high-quality images that quality and colour really matter.
Sources:
http://www.labnol.org/software/tutorials/jpeg-vs-png-image-quality-or-bandwidth/5385/, http://www.interactivesearchmarketing.com/jpeg-png-proper-image-formatting/
I can get that 9.5 KB file down to 3.4 KB using the 8-bit palette PNG format. The image has a transparent boundary, which adds unnecessary pixels and an alpha channel for the whole image which isn't needed, since it's rectangular. After stripping the transparent boundary, eliminating the alpha channel, and using a palette, I can get it down to 3.2 KB.
To get any further, I have to use JPEG for lossy compression. At a very low image quality of 5 (out of 100), I can get it down to 1 KB. It shows some artifacts from the severe compression (look around the prompt > and _ to see some of those):

Libjpeg write text at some specific position

Is there a way to output a text at some (x,y) position having a certain "size", such as a numeral '1'? For example in gnuplot, we can use
plot ... using x:y:size w labels center...
Is there something similar which I can use with the libjpeg library?
No
libJPEG is only a loading/saving library. It allows the conversion of JPEG to other more workable formats and back. You will need some sort of image processing library (e.g. OpenCV) or high-level graphics library (e.g. DirectX, SFML). There are a lot of image libraries that implement writing of text on a bitmap. libJPEG will allow you to decode into a bitmap format in memory and from there you can work with pretty much any other library that has functions that write text onto a bitmap.
Personally, I would just use SFML since you can load a JPG file (or any image format for that matter), set that texture as a render target, render text, and then get the texture for that and save it back. But any high level graphics library should do the trick...like listed above.

.png Image Information

Where can I find image information such as width, height and rgba pixels in a .png image?
I found it quite easy to do so with a bitmap image but png images look way too complicated. Wikipedia won't help either. (probably because of my bad English)
Instead of writing your own PNG renderer, you probably should use an existing library (such as libpng) to do it for you. libpng has functions such as png_get_image_width, png_get_image_height, and png_get_rows to get the width, height, and image data respectively.
The .png file format is much more flexible than .bmp, so there's not a fixed place where you can find the width and height. The more serious problem is that the pixel values are compressed, they must be uncompressed before you can use them. This almost guarantees that you'll need a library to use .png files.

How can I draw a png ontop of another png?

How can I "draw"\"merge" a png top of another png (background) using libpng, while keeping the alpha section of the png being drawn on top of the backhround png. There does not seem to be any tutorials or anything mentioned in the documentation about it.
libpng is a library for loading images stored in the PNG file format. It is not a library for blitting images, compositing images, or anything of that nature. libpng's basic job is to take a file or memory image and turn it into an array of color values. What you're talking about is very much out of scope for libpng.
If you want to do this, you will have to do the image composition yourself manually. Or use a library that can do image composition (cairo, etc).

What kind of images are used in iphone?

i am making a game with a background and animated helicopter that is flying.When i see other iphone games their backgrounds are so graphically strong ,mine is not near to that .Why is that?
Are there any special type of images used in iphone?
JPG, PNG, BMP, etc are all capable of being displayed fine on an iPhone.
Keep an eye out for:
If you are resizing the image (in either direction), it may lose detail.
If you are not using the full bit-depth - e.g. if you are only using 16 colours.
If you are highly compressing JPEG images, which is a lossy format.
Of course, if your source image looks bad, it will continue to look bad.