PNG and JPEG images
PNG and JPEG images
Greetings Sergey,
When I load a JPEG in Ms Word and resize it that carries over to RVF in the rtf format.
However, if I load a PNG in Ms Word and reisize it that does not carry over correctly to RVF.
The visual size is correct but the image appears to be cropped.
I used this page for png https://www.trichview.com/forums/viewtopic.php?t=89
When I load a JPEG in Ms Word and resize it that carries over to RVF in the rtf format.
However, if I load a PNG in Ms Word and reisize it that does not carry over correctly to RVF.
The visual size is correct but the image appears to be cropped.
I used this page for png https://www.trichview.com/forums/viewtopic.php?t=89
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: PNG and JPEG images
Please give me step-by-step instructions how to reproduce this problem.
Re: PNG and JPEG images
1. In a MS Word file. I am in ms word 365
2. load a png image through insert>picture file
3. Now resize the image with the msword picture handles they are little boxes that appear when you click the image. Resizd it a lot smaller than the original to see this issue quicker
4. Now save to rtf and load it in rvf 18.3 (I have my rvf to load a lot as png to save on space)
5. I followed the png procedure for png since I am in delphi7
6. I am not surr if I am just missing a setting if I do this with Jpeg it is fine.
2. load a png image through insert>picture file
3. Now resize the image with the msword picture handles they are little boxes that appear when you click the image. Resizd it a lot smaller than the original to see this issue quicker
4. Now save to rtf and load it in rvf 18.3 (I have my rvf to load a lot as png to save on space)
5. I followed the png procedure for png since I am in delphi7
6. I am not surr if I am just missing a setting if I do this with Jpeg it is fine.
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: PNG and JPEG images
After loading this RTF in TRichView, please save it as RVF file, and send the both files (RTF and RVF) to me to email richviewgmailcom
Re: PNG and JPEG images
Greetings Sergey,
I sent the email over from jgkthewordbookscom
I sent the email over from jgkthewordbookscom
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: PNG and JPEG images
I received it, need some time to test.
Re: PNG and JPEG images
I verify this behavior.
It seems that PNG images are not resampled. Setting rvepImageWidth and rvepImageHeight with SetItemExtraIntProperty does change the graphic size on the canvas, yet the image is not resampled but it is displayed in the original size, thus cropped to the given dimensions.
This used to work in RV14 (my last version), broken in RV17.
Thanks
It seems that PNG images are not resampled. Setting rvepImageWidth and rvepImageHeight with SetItemExtraIntProperty does change the graphic size on the canvas, yet the image is not resampled but it is displayed in the original size, thus cropped to the given dimensions.
This used to work in RV14 (my last version), broken in RV17.
Thanks
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: PNG and JPEG images
The source of the original problem (reported by jgkoehn) was a wrong version of TPNGObject.
While he had the correct version, another version was used to compile the project (because its folder was listed first in the Delphi library paths).
After fixing the library paths, the problem was solved.
PS: TPNGObject is needed for Delphi 2007 and older. For newer version of Delphi, a built-in TPNGImage is used.
While he had the correct version, another version was used to compile the project (because its folder was listed first in the Delphi library paths).
After fixing the library paths, the problem was solved.
PS: TPNGObject is needed for Delphi 2007 and older. For newer version of Delphi, a built-in TPNGImage is used.
Re: PNG and JPEG images
I am using D7 with a version of pngobject that used to work with RV14.
Can you give me some pointer to the code to see where resizing happens or is decided so i can step through the code to try to find out what the problem is?
Can you give me some pointer to the code to see where resizing happens or is decided so i can step through the code to try to find out what the problem is?
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: PNG and JPEG images
Resizing itself does not change the image, it only changes ImageWidth and ImageHeight properties.
You can check how the picture is drawn.
Check RVItem.pas,TRVGraphicItemInfo.Paint.
In this procedure, two options are possible.
1) The item may create a thumbnail for scaled image, it happens on the line
2) The item may draw the image as it is, it happens on the line
You can check how the picture is drawn.
Check RVItem.pas,TRVGraphicItemInfo.Paint.
In this procedure, two options are possible.
1) The item may create a thumbnail for scaled image, it happens on the line
Code: Select all
ImageCopy := RVThumbnailMaker.MakeThumbnail(GraphicHolder.Graphic,
wScaled, hScaled);
Code: Select all
Style.GraphicInterface.StretchDrawGraphic(Canvas,
Bounds(X, Y, w, h), Image);
Re: PNG and JPEG images
Hi Sergey,
coming back to this to bring up the issue of quality.
I followed the code path and, as you said, when resizing an image it ends up to pnimage.pas -> TPngObject.Draw where StretchDiBits is used that is very simplistic (e.g. no serious interpolation). Obviously the image quality during down-sizing is not good, yet my question is why in RV14 the quality was good, whereas in RV17 i now upgraded to the quality is bad. The difference in quality is quite large.
Did you change something to the way images are drawn?
Thanks
coming back to this to bring up the issue of quality.
I followed the code path and, as you said, when resizing an image it ends up to pnimage.pas -> TPngObject.Draw where StretchDiBits is used that is very simplistic (e.g. no serious interpolation). Obviously the image quality during down-sizing is not good, yet my question is why in RV14 the quality was good, whereas in RV17 i now upgraded to the quality is bad. The difference in quality is quite large.
Did you change something to the way images are drawn?
Thanks
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: PNG and JPEG images
Currently, our advanced scaling is applied only to non-transparent images. Probably, this PNG contains semitransparent pixels.
Re: PNG and JPEG images
Just to know: was this any different in RV14? Because, looking at the code, it seems the same.
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: PNG and JPEG images
The code that determines which pictures are transparent was changed.