I have experimented on W10 with DX trying to get fast thumbnail save routine and only Mode 1 works correctly. All other modes produce a heavily pixelated output, please advise what I am doing wrong - thanks in advance.
for i:= 0 to mvHorz.ImageCount - 1 do begin
if mvHorz.MIO.Params[i].FileName = '' then Continue;
iThumbnailFilename:= iFolder + JustName(mvHorz.MIO.Params[i].FileName) + '_thumbnail.jpg';
//
if Mode = 1 then begin // Load From File Into ImageEn, ReSample And Save
Image.IO.LoadFromFile(mvHorz.MIO.Params[i].FileName);
Image.Proc.Resample(100, 100, rfFastLinear, True);
Image.IO.SaveToFileJpeg(iThumbnailFilename);
end;
if Mode = 2 then begin // Load From File Into IEBitmap, Convert To Thumb And Save
iIEBitmap:= TIEBitmap.Create;
Bitmap:= TBitmap.Create;
Graphic:= nil;
FS:= TFileStream.Create(mvHorz.MIO.Params[i].FileName, fmOpenRead);
try
SetLength(FirstBytes, 8);
FS.Read(FirstBytes[1], 8);
if Copy(FirstBytes, 1, 2) = 'BM' then begin
Graphic := TBitmap.Create;
end else if FirstBytes = #137'PNG'#13#10#26#10 then begin
Graphic:= TPngImage.Create;
end else if Copy(FirstBytes, 1, 3) = 'GIF' then begin
Graphic:= TGIFImage.Create;
end else if Copy(FirstBytes, 1, 2) = #$FF#$D8 then begin
Graphic:= TJPEGImage.Create;
end;
if Assigned(Graphic) then begin
try
FS.Seek(0, soFromBeginning);
Graphic.LoadFromStream(FS);
Bitmap.Assign(Graphic);
iIEBitmap.CopyFromTBitmap(Bitmap);
iIEBitmap.IEConvertToThumbnail(100, 100, Stretch, rfLanczos3, Border, BorderColor, Shadow, BlurRadius, ShadowOffset, ShadowColor, BackgroundColor); // hyiedefs
iIEBitmap.IESaveToFile(iThumbnailFilename, ioJPEG);
except
end;
Graphic.Free;
end;
finally
FS.Free;
Bitmap.Free;
iIEBitmap.Free;
end;
end;
if Mode = 3 then begin // Load Into IEBitmap From ImageEnMView, Convert To Thumb And Save
iIEBitmap:= TIEBitmap.Create;
try
iIEBitmap:= mvHorz.GetTIEBitmap(i);
{rfNone, rfTriangle, rfHermite, rfBell, rfBSpline, rfLanczos3, rfMitchell, rfNearest, rfLinear, rfFastLinear, rfBilinear, rfBicubic, rfProjectBW, rfProjectWB, rfWICNearestNeighbor, rfWICLinear, rfWICCubic, rfWICFant}
iIEBitmap.IEConvertToThumbnail(100, 100, Stretch, rfLanczos3, Border, BorderColor, Shadow, BlurRadius, ShadowOffset, ShadowColor, BackgroundColor); // hyiedefs
iIEBitmap.IESaveToFile(iThumbnailFilename, ioJPEG);
except
end;
iIEBitmap.Free;
end;
if Mode = 4 then begin // Load From File As Thumbnail Into IEBitmap And Save
iIEBitmap:= TIEBitmap.Create;
try
iIEBitmap.IELoadAsThumbnail(mvHorz.MIO.Params[i].FileName, 100, 100, False);
iIEBitmap.IESaveToFile(iThumbnailFilename, ioJPEG);
except
end;
iIEBitmap.Free;
end;
if Mode = 5 then begin // Load From File Into IEBitmap, Resample And Save
iIEBitmap:= TIEBitmap.Create;
try
iIEBitmap.IELoadFromFile(mvHorz.MIO.Params[i].FileName, 100, 100, False);
iIEBitmap.Resample(100, 100, rfLanczos3, True);
iIEBitmap.IESaveToFile(iThumbnailFilename, ioJPEG);
except
end;
iIEBitmap.Free;
end;
Break;
end;
Andy