function PictureToBitmap(const picFileName: string; Bitmap: TBitmap): TBitmap;
var
vIcon: TIcon;
Graphic: TPicture;
begin
Result := Bitmap;
Graphic := TPicture.Create;
try
Graphic.LoadFromFile(picFileName);
if Graphic.Graphic is TBitmap then
begin
Bitmap.Assign(Graphic.Bitmap);
end
else if Graphic.Graphic is TIcon then
begin
vIcon := TIcon.Create;
vIcon.LoadFromFile(picFileName);
Bitmap.Height := vIcon.Height;
Bitmap.Width := vIcon.Width;
Bitmap.Canvas.Draw(0, 0, vIcon);
vIcon.Free;
end
else
begin
Bitmap.Assign(Graphic.Graphic);
end;
finally
FreeAndNil(Graphic);
end;
end;
procedure InsPicIntoRxre(const RxRichEdit: TRxRichEdit);
var
Bitmap: TBitmap;
op: TOpenDialog;
fn: string;
begin
op := TOpenDialog.Create(nil);
Bitmap := TBitmap.Create;
with op do
try
if not Execute then
exit;
fn := op.FileName;
Clipboard.Assign(PictureToBitmap(fn, Bitmap));
RxrichEdit.PasteFromClipboard;
finally
FreeAndNil(Bitmap);
Free;
end;
end;