procedure TCmdForm.MnuDiskImageClick(Sender: TObject);
var
//inlineimg: TInlineImage;
InsImage: TImage;
ImgSize: Types.TSize;
ImgWide,ImgTall: integer;
ImgFile: string;
begin
{ // using this section
OpenDialog1.Title:= 'Select Image-File';
OpenDialog1.Filter:= 'Jpeg (*.jpg)|*.jpg|Ping (*.png)|*.png|Tiff (*.tif)|*.tif';
OpenDialog1.Execute;
if (OpenDialog1.Files.Count = 1) and (FileExistsUTF8(OpenDialog1.FileName))
then begin
// not being used
end;
} // end of not using this section
GetImageFile; // used instead of the above
ImgFile:= OpenPictureDialog1.Filename;
InsImage.Picture:= Image1.Picture;
InsImage.proportional:= true;
ImgWide:= round(InsImage.Width*72/96);
ImgTall:= round(InsImage.Height*72/96);
ImgSize:= Types.Size(ImgWide,ImgTall);
//InsertImageFromFileNoResize(PageMemo, PageMemo.SelStart, ImgFile);
InsertImageFromFile(PageMemo, PageMemo.SelStart, ImgFile, ImgSize);
// Inline example. It works... but coding an image into ImageList is not obvious.
(*
//ImageList2.LoadFromFile(ImgFile); // ??? an idea, but not tested
inlineimg:= TInlineImage.Create;
inlineimg.imageList:=ImageList2;
inlineimg.frame:=framecnt;
// must use Types.Size and the following method to avoid conflict...
ImgWide:= round(ImageList2.Width*72/96);
ImgTall:= round(ImageList2.Height*72/96);
ImgSize:= Types.Size(ImgWide,ImgTall);
PageMemo.InDelInline(inlineimg, PageMemo.SelStart, 0, ImgSize);
inc(framecnt);
if framecnt>=ImageList1.Count then framecnt:=0;
*)
end;
procedure TCmdForm.GetImageFile;
begin
//OpenPictureDialog1.Options:= OpenPictureDialog1.Options+[ofFileMustExist]; // has a conflict
if not OpenPictureDialog1.Execute then exit;
try
//--------------------------------------------------------------------------
// Loading directly into a TImage. This will load any registered image
// format. .bmp, .xpm, .png are the standard LCL formats.
// The jpeg units register .jpeg and .jpg.
Image1.Picture.LoadFromFile(OpenPictureDialog1.Filename);
//--------------------------------------------------------------------------
//UpdateInfo(OpenPictureDialog1.Filename); // has a conflict
except
on E: Exception do begin
MessageDlg('Error','Error: '+E.Message,mtError,[mbOk],0);
end;
end;
end;