Hi all, this is my code
private void CheckImg(string xfile, string outfile)
FIBITMAP dib = FreeImage.LoadEx(xfile);
FIBITMAP dibTemp = dib;
uint X = FreeImage.GetResolutionX(dib);
uint Y = FreeImage.GetResolutionY(dib);
bitMap = FreeImage.GetBitmap(dib);
DeSkew deSkew = new DeSkew();
double angle = deSkew.GetSkewAngle();
dibTemp = FreeImage.Rotate(dibTemp, (double)angle);
FreeImage.SetResolutionX(dibTemp, X);//but not effect
FreeImage.SetResolutionY(dibTemp, Y);//but not effect
bitMap = FreeImage.GetBitmap(dibTemp);
Rectangle rec = new Rectangle(left -20, top - 20, right - left + 35, bot - top + 35);//(left, top,bitMap.Width,bitMap.Height);
using (Bitmap crop = bitMap.Clone(rec, bitMap.PixelFormat))
FreeImage.SaveBitmap(crop, outfile, FREE_IMAGE_FORMAT.FIF_JP2, FREE_IMAGE_SAVE_FLAGS.DEFAULT);
ProcessEx(outfile, xfile, 3);
my image input have resolution is (300,300) but output image cannot set same resolution with input image.
Who's give me solution?
The OpenJPEG library (internally used by FreeImage) doesn't read nor write the "Resolution box".
That's why you can't save the resolution.
You can fill an issue here :
Thanks Drolon. Follow your post, FreeImage cannot read or write Resolution for a JPEG 2000 image, then, why does it have function SetResolution. It's useless?
no, the function is not useless. While the image is loaded (aka. in memory) you can change and set almost everything, including metadata, resolution, backcolor etc. However, FreeImage is plugin-driven and each plugin decides which information to write into a file.
Some file formats do not even support all the information, that is available in memory (as an example, the TARGA format does not contain a resolution). On the other side, some of the plugins do not have support for reading and/or writing all the image data that is supported by a certain image format (not supporting resolution with JPEG2000 for example).
The latter case you could call a limitation of FreeImage or even a bug if you like.