trichview.support
Re: Inserting of images with a fixed (metrical) size |
Author |
Message |
Sergey Tkachenko |
Posted: 12/02/2004 20:58:35 Well, what's the main difference between size in pixels and size in mm? Size in pixels depend on screen resolution (In TRichView, it does not depend on printer resolution - images are scaled to neglect the difference between the screen and printer resolutions). It's possible to make TRichView document independent of the screen resolution by specifying the resolution directly. For example, you can set resolution equal to 96 (a typical value for the display resolution in "small fonts" mode). You can do it by assigning RichViewPixelsPerInch := 96; // defined in RVFuncs unit RVStyle1.TextStyles.PixelsPerInch := 96; After that, mm can be unambiguously convered to pixels: pixels = (mm * 5 * 96) / 127 As you can see, this formula does not depend on any parameters. To set image size in pixels, you can use rvepImageWidth and rvepImageHeight extra item properties. This example adds picture at the caret position and resizes it to 32x32 (this insertion and resizing can be undone/redone as a single operation): var bmp: TBitmap; rve: TCustomRichViewEdit; begin bmp := TBitmap.Create; bmp.LoadFromFile('d:\New Bitmap Image.bmp'); rve := RichViewEdit1.TopLevelEditor; rve.BeginUndoGroup(rvutInsert); rve.SetUndoGroupMode(True); if RichViewEdit1.InsertPicture('', bmp, rvvaBaseline) then begin RichViewEdit1.SetCurrentItemExtraIntProperty(rvepImageHeight, 32, False); RichViewEdit1.SetCurrentItemExtraIntProperty(rvepImageWidth, 32, True); end; rve.SetUndoGroupMode(False); end; This example creates document with this image: var bmp: TBitmap; rve: TCustomRichViewEdit; begin bmp := TBitmap.Create; bmp.LoadFromFile('d:\New Bitmap Image.bmp'); rve := RichViewEdit1.TopLevelEditor; RichViewEdit1.Clear; RichViewEdit1.AddNL('Image 32x32', 0, 0); RichViewEdit1.AddPictureEx('', bmp, 0, rvvaBaseline); RichViewEdit1.SetItemExtraIntProperty(RichViewEdit1.ItemCount-1, rvepImageWidth, 32); RichViewEdit1.SetItemExtraIntProperty(RichViewEdit1.ItemCount-1, rvepImageHeight, 32); RichViewEdit1.Format; end; |
Powered by ABC Amber Outlook Express Converter