画像を Zimage(graphcontrol) に読み込むアプリを入手しました。私が抱えている問題の 1 つは、元の画像がコンポーネントに表示される画像よりもはるかに優れていることです。表示されているものには、ランダムな黒いマークが付いているように見えます。では私は何をすべきか:
- フォルダから TJpegimage に画像を読み込む
- jpg をビットマップに割り当てる
- ビットマップをオブジェクト リストに保存
すべての画像がオブジェクトリストにロードされるまで上記を繰り返します
次に、ビットマップを作成します
- オブジェクトリストの最初の画像をそれに割り当てます
- キャンバスにビットマップを描画します。
しかし、それはオリジナルよりもはるかに悪いように見えます。これに関するヘルプやアイデアはありますか?
これが読み込みコードです。
procedure TForm1.LoadImages(const Dir: string);
var
i: Integer;
CurFileName: string;
JpgIn: TJPEGImage;
BmpOut: TBitmap;
begin
//set up progress bar
progressbar1.Min := 0;
progressbar1.Max := GetFilesCount(dir,'*.*');
Label3.Visible := true;
progressbar1.Visible := true;
//sets array for length
SetLength(hwArray,GetFilesCount(dir,'*.*'));
//sets index for object list
CurIdx := -1;
i := 0;
while True do
begin
//gets file name out of current folder
CurFileName := Format('%s%d.jpg',
[IncludeTrailingPathDelimiter(Dir), i]);
if not FileExists(CurFileName) then
Break;
//count files in folder for progress bar.
progressbar1.StepBy(1);
//creates jpgin
JpgIn := TJPEGImage.Create;
try
//loads jpgin with file
JpgIn.LoadFromFile(CurFileName);
//creates TBitmap and sets width to same as jpgs
BmpOut := TBitmap.Create;
bmpout.Width := jpgin.Width;
bmpout.Height := jpgin.Height;
try
BmpOut.Assign(JpgIn);
//adds 1 to index for object list. thus starting at 0
curIdx := curIdx+1;
//add bitmap to objectlist
CurIdx:= mylist.Add(TBitmap(bmpout));
hwArray[CurIdx][0]:=jpgin.Width;
hwArray[CurIdx][1]:=jpgin.height;
finally
end;
finally
JpgIn.Free;
end;
Inc(i);
end;
//makes sure cout is above 0 thus files added
if mylist.Count > 0 then
begin
try
CurIdx := 0;
getBitmapfromList(CurIdx,bmpout);
ZImage1.Bitmap.Assign(bmpout);
//image1.Canvas.Assign(bmpout);
finally
BmpOut.Free;
end;
end;
Label3.Visible := false;
progressbar1.Visible := false;
page:= '0';
zimage1.DblClick;
end;
関数はリストからビットマップを取得します
procedure Tform1.getBitmapfromList(index:integer;var Bitm:TBitmap);
begin
Bitm.Assign(TBitmap(mylist[index]));
if (Bitm.Width<>hwArray[index][0]) OR (Bitm.Height<>hwArray[index][1]) then begin
ShowMessage('Size differs');
Bitm.Width:=hwArray[index][0];
Bitm.Height:=hwArray[index][1];
end;
end;
[次へ] ボタンで次の画像を表示
procedure TForm1.Button3Click(Sender: TObject);
var
BmpOut: TBitmap;
begin
bmpout := TBitmap.Create;
CurIdx:= strtoint(page);
getBitmapfromList(CurIdx,bmpout);
ZImage1.Bitmap.Assign(bmpout);
//image1.Canvas.Assign(bmpout);
page := inttostr(strtoint(page) +1); //this should show next item in ilst?
zimage1.Repaint;
end;
助けや提案をありがとう。
画像は次のとおりです。
http://s7.postimage.org/48mectvsp/image_Difference.png
編集
画像をズームインすると、より良くなるようです。最悪のクリティは、フルスクリーン/ズームアウトしたときです..元のサイズ。