.jpg を bmp に変換してから imagelist1 に保存することで、jpg をイメージリストにロードしようとしています。
コードスニップの上から下へ。Selectdir が機能し、fileexists パーツが機能します。これは、フォルダ内のすべての画像をロードするために使用されます。すべての画像は、0.jpg / 1.jpg などのように名前が付けられます。
次に、jpg を tpicture にロードします。bmp の幅/高さを設定し、同じ画像を jpg で bmp をロードしてから、bmp を画像リストに追加します。完了すると、最初の画像 0.jpg が表示されます。
2 つの問題。最初に、BMP の小さな領域 (左上) しか表示されないようにした場合、それは正しい画像でした。これはオプションクロップによるものだと思います。実行時に中心を選択する方法がわかりませんか?
第二に、私が入れた場合
Imagelist1.width := currentimage.width;
Imagelist1.height := currentimage.height;
次に、最後の画像を表示します。Imagelist1.GetBitmap()
うまくいきませんでしたか? だから私はどちらかの修正が素晴らしいと思います! 乾杯
procedure TForm1.Load1Click(Sender: TObject);
var
openDialog : TOpenDialog;
dir :string;
MyPicture :TPicture;
currentimage :Tbitmap;
image : integer;
clTrans : TColor;
begin
Image := 0 ;
//lets user select a dir
SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],SELDIRHELP);
myPicture :=Tpicture.Create;
currentimage := TBitmap.Create;
//keeps adding images as long as the file path exsist.
//thus comic pages should be renumbed to 0-XX
while FileExists(Dir+'\'+inttostr(image)+'.jpg') do
begin
try
MyPicture.LoadFromFile(Dir+'\'+inttostr(image)+'.jpg'); //load image to jpg holder
currentimage.Width := mypicture.Width; //set width same as jpg
currentimage.Height:= mypicture.Height; //set height same as jpg
currentimage.Canvas.Draw(0, 0, myPicture.Graphic); //draw jpg on bmp
clTrans:=currentimage.TransparentColor; //unknown if needed?
//Imagelist1.Width := currentimage.Width;
//imagelist1.Height := currentimage.Height;
Imagelist1.Addmasked(Currentimage,clTrans); //add to imagelist
finally
image := image +1; //add one so it adds next page
end;
end;
ImageList1.GetBitmap(0,zImage1.Bitmap);
mypicture.Free;
currentimage.Free;
end;