Save RVF file with resized image
Save RVF file with resized image
Hi Sergey,
If this has been answered before let me know.
I often import a large image and resize it in a regular rve. No problem there. What I wanted to know is, after resizing the image how do I then save the rvf file with the resized image?
I've been able to resize them in the editor or upon import, but when I save the file the image is saved in its original (not displayed) size. I want to save the file with the image at the size it's being displayed in the doc.
I can resize them outside of my rve and then paste them in, but if there's a way to save the rve file without that extra step that would be great.
Thanks Sergey
Stan
If this has been answered before let me know.
I often import a large image and resize it in a regular rve. No problem there. What I wanted to know is, after resizing the image how do I then save the rvf file with the resized image?
I've been able to resize them in the editor or upon import, but when I save the file the image is saved in its original (not displayed) size. I want to save the file with the image at the size it's being displayed in the doc.
I can resize them outside of my rve and then paste them in, but if there's a way to save the rve file without that extra step that would be great.
Thanks Sergey
Stan
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Save RVF file with resized image
Can you send me a simple project reproducing this problem?
Of course, sizes of resized images must be stored in RVF.
Of course, sizes of resized images must be stored in RVF.
Re: Save RVF file with resized image
Hi Sergey,
I don't have any code yet that I'm trying to use to do this with other than this kind of thing (or using the mouse):
I've been using the words "size" and "resize" when I should probably be using "resolution." I can resize the images in code or with the mouse no problem. I think what I am wanting to do is to resample the original image, or make a thumbnail from it.
However, I'm beginning to think I'll be better off resizing in an image editor and then pasting it in. Just thought if there's a way to do it in code that would be worth a try.
Thanks Sergey.
Stan
I don't have any code yet that I'm trying to use to do this with other than this kind of thing (or using the mouse):
Code: Select all
rv.SetCurrentItemExtraIntProperty(rvepImageWidth, W , True);
rv.SetCurrentItemExtraIntProperty(rvepImageHeight, H, True);
However, I'm beginning to think I'll be better off resizing in an image editor and then pasting it in. Just thought if there's a way to do it in code that would be worth a try.
Thanks Sergey.
Stan
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Save RVF file with resized image
Sorry, I misread your original question.
Yes, when you assign rvepImageWidth or rvepImageHeight property (either in code or resizing with mouse or touchscreen gestures), the image itself is not changed.
If you need it, you need to replace the original image with a resized copy (using SetCurrentPictureInfo or similar method).
Please note that even if you scaled an image down, keeping the original still makes sense to improve quality of
- printing
- displaying on higher DPI screens
Yes, when you assign rvepImageWidth or rvepImageHeight property (either in code or resizing with mouse or touchscreen gestures), the image itself is not changed.
If you need it, you need to replace the original image with a resized copy (using SetCurrentPictureInfo or similar method).
Please note that even if you scaled an image down, keeping the original still makes sense to improve quality of
- printing
- displaying on higher DPI screens
Re: Save RVF file with resized image
Hi Sergey,
OK, that sounds about like what I thought. I was able to work it with a TBitMap and using Canvas.StretchDraw, but the resulting image is not that good plus transparency drops out on PNGs and so on. I'll resize in a paint program when I have to.
Thanks, this helps to verify things for me!
Stan
OK, that sounds about like what I thought. I was able to work it with a TBitMap and using Canvas.StretchDraw, but the resulting image is not that good plus transparency drops out on PNGs and so on. I'll resize in a paint program when I have to.
Thanks, this helps to verify things for me!
Stan
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Save RVF file with resized image
TRichView includes high-quality resizing procedures.
Unit RVThumbMaker,
It supports transparency.
For some graphics it may refuse to resize, in this case it returns nil.
Unit RVThumbMaker,
Code: Select all
NewBitmap := RVThumbnailMaker.MakeThumbnail(Graphic, Width, Height);
For some graphics it may refuse to resize, in this case it returns nil.
Re: Save RVF file with resized image
Hi Sergey,
Finally had time to try this and it seems to work very well. I use PNGs most of the time and it makes a great image reduction and maintains transparency.
Here's the code I'm using in case it will help someone else needing to do the same thing:
Stan
Finally had time to try this and it seems to work very well. I use PNGs most of the time and it makes a great image reduction and maintains transparency.
Here's the code I'm using in case it will help someone else needing to do the same thing:
Code: Select all
try
if (rv.CurItemStyle = rvsPicture) or (rv.CurItemStyle = rvsHotPicture) then
begin
//get image info
rv.GetCurrentPictureInfo( s, gr, RVAlign, ATag );
//800 is an arbitrary figure I picked as it seems to work best for my purposes.
//Could be anything wanted:
if (gr.Width < 800) and (gr.Height < 800) then
begin
ShowMessage('Image height and width are already less than 800px');
exit;
end;
//get image sizes:
w := gr.Width;
h := gr.Height;
//set the larger of the 2 to 800px and adjust the other one to match
//aspect size proportionally:
ImageSize := ImageAspect(w,h);
//uses RVThumbMaker:
gr := RVThumbnailMaker.MakeThumbnail(gr, ImageSize.cx , ImageSize.cy );
if gr = nil then exit;
gr.Transparent := true; //need this or no workee for xparent images
rv.SetCurrentPictureInfo( s, gr, RVAlign, ATag );
end;
except
//do nothing
end;
Re: Save RVF file with resized image
Hi Sergey,
I spoke to soon. It appears to be working, but it's not.
I can insert the png image and resize it, make the thumbnail, and then set the picture info and all looks as it should, i.e., transparency is intact and the image has in fact been resized. However, if I save the file and then reopen it, size is still OK but the transparency has been lost.
If I just resize the image (by code or by mouse) and save the file and load it again transparency is fine.
Any ideas on what I can do to fix the transparency problem?
Thanks Sergey
Stan
I spoke to soon. It appears to be working, but it's not.
I can insert the png image and resize it, make the thumbnail, and then set the picture info and all looks as it should, i.e., transparency is intact and the image has in fact been resized. However, if I save the file and then reopen it, size is still OK but the transparency has been lost.
If I just resize the image (by code or by mouse) and save the file and load it again transparency is fine.
Any ideas on what I can do to fix the transparency problem?
Thanks Sergey
Stan
Re: Save RVF file with resized image
Hi Sergey,
OK, the following changes seemed to get around the problem:
If anything looks really off please let me know. But this lets me resize as well as maintain transparency.
Stan
OK, the following changes seemed to get around the problem:
Code: Select all
//uses RVThumbMaker:
gr := RVThumbnailMaker.MakeThumbnail(gr, ImageSize.cx , ImageSize.cy );
if gr = nil then
begin
ShowMessage('Unable to resize this image.');
exit;
end;
//gr.Transparent := RVGraphicHandler.IsTransparent(gr); //no longer needed
png := TPngImage(RVGraphicHandler.GraphicToPng(gr));
rv.SetCurrentPictureInfo( s, png, RVAlign, ATag );
gr.Free;
Stan