-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
The following code does a much better job at scaling bitmaps than SpDPIResizeBitmap.
procedure ResizeBitmap(Bitmap: TBitmap; const NewWidth, NewHeight: Integer);
var
Factory: IWICImagingFactory;
Scaler: IWICBitmapScaler;
Source : TWICImage;
IBitmap: IWICBitmap;
begin
Source := TWICImage.Create;
try
Factory := TWICImage.ImagingFactory;
Factory.CreateBitmapFromHBITMAP(Bitmap.Handle, Bitmap.Palette,
WICBitmapUsePremultipliedAlpha, IBitmap);
Factory.CreateBitmapScaler(Scaler);
try
Scaler.Initialize(IBitmap, NewWidth, NewHeight,
WICBitmapInterpolationModeHighQualityCubic);
Source.Handle := IWICBitmap(Scaler);
finally
Scaler := nil;
Factory := nil;
end;
Bitmap.Assign(Source);
finally
Source.Free;
end;Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels