Hello
If I copy a bmp image and paste it into my Trichview, is it pasted as bmp or jpge?
If it is pasted as bmp, is there any way to paste it as jpge?
Regards
Insert image from a copy and paste
-
- Site Admin
- Posts: 17553
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Insert image from a copy and paste
There is no standard Clipboard format for Jpegs, so the copied image will be inserted as a bitmap.
The only way to paste JPEG to RichViewEdit is copying a JPEG file (for example, from Explorer).
Here is a function that pastes bitmap as JPEG:
I think it's not a very good idea to paste all bitmap images as JPEGs. JPEGs are good for photos, but not good for screenshots, because they use lossy compression. However, if you want it, you can implement OnPaste event:
The only way to paste JPEG to RichViewEdit is copying a JPEG file (for example, from Explorer).
Here is a function that pastes bitmap as JPEG:
Code: Select all
function PasteBitmapAsJpeg(rve: TCustomRichViewEdit): Boolean;
var
bmp: TBitmap;
jpg: TJPEGImage;
begin
Result := Clipboard.HasFormat(Windows.CF_BITMAP);
bmp := TBitmap.Create;
try
bmp.Assign(Clipboard);
jpg := TJPEGImage.Create;
jpg.Assign(bmp);
finally
bmp.Free;
end;
rve.InsertPicture('', jpg, rvvaBaseline)
end;
Code: Select all
procedure TForm3.SRichViewEdit1Paste(Sender: TCustomRichViewEdit;
var DoDefault: Boolean);
begin
DoDefault := not PasteBitmapAsJpeg(Sender);
end;