Prevent Image Resizing On Insert

General TRichView support forum. Please post your questions here
Post Reply
fchintc
Posts: 47
Joined: Thu Oct 25, 2007 2:49 pm

Prevent Image Resizing On Insert

Post by fchintc »

When I insert a picture (JPG or PNG) from file, the image container resizes to match the picture size.

Is it possible to force the image container to remain at a certain size and not resize?

Frederick
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Inserting picture with resizing it to 100x100:

Code: Select all

rve.TopLevelEditor.BeginUndoGroup(rvutInsert); 
rve.TopLevelEditor.SetUndoGroupMode(True); 
if rve.InsertPicture(...) then begin 
  rve.SetCurrentItemExtraIntProperty(rvepImageHeight, 100, True); 
  rve.SetCurrentItemExtraIntProperty(rvepImageWidth, 100, True); 
  rve.SetCurrentItemExtraIntProperty(rvepResizable, 0, True); 
end; 
rve.TopLevelEditor.SetUndoGroupMode(False);
Instead of forbidding resizing for the given picture (using rvepResizable), you can forbid resizing for all pictures, by including rvoNoImageResize in rve.EditorOptions.
fchintc
Posts: 47
Joined: Thu Oct 25, 2007 2:49 pm

Post by fchintc »

Thank you for the code.

Is it possible to set the inserted picture to be of a certain width and height but still allow the user to resize it themselves? The idea is that if the user imports a large image accidentally, the image will not be out of range for them to resize.

Frederick
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Remove the line

Code: Select all

rve.SetCurrentItemExtraIntProperty(rvepResizable, 0, True); 
and the user will be able to resize this picture (if rvoNoImageResize is not in rve.EditorOptions)
fchintc
Posts: 47
Joined: Thu Oct 25, 2007 2:49 pm

Post by fchintc »

Thanks for the code and help.

Frederick
Post Reply