I have followed this answer to crop image: how do I crop a bitmap “in place”?
In delphi 7 I have a TImage Image_center.
Image := TPngObject.Create;
try
Image.LoadFromStream(Stream);
Image_center.Picture.Graphic := Image;
Image_center.width := Image.width;
Image_center.height := Image.height;
Image_center.Left := ( form1.clientWidth div 2 ) - (Image_center.width div 2);
CropBitmap(Image_center.Picture.Bitmap, 1, 45, Image.width, Image.height-45);
finally
Image.Free;
end;
But the result is that the TImage contains white bitmap. If I skip/comment out the CropBitmap function, so I can see the image. So there is not problem with loading. Why I see the white area instead of the image?
procedure CropBitmap(InBitmap : TBitmap; X, Y, W, H :Integer);
begin
BitBlt(InBitmap.Canvas.Handle, 0, 0, W, H, InBitmap.Canvas.Handle, X, Y, SRCCOPY);
InBitmap.Width :=W;
InBitmap.Height:=H;
end;
Delphi 7 Bitmap methods:
In TBitmap
~TBitmap
Assign
Create
Destroy
Dormant
FreeImage
HandleAllocated
LoadFromClipboardFormat
LoadFromResourceID
LoadFromResourceName
LoadFromStream
Mask
ReleaseHandle
ReleaseMaskHandle
ReleasePalette
SaveToClipboardFormat
SaveToStream
TBitmap
Derived from TGraphic
LoadFromFile
SaveToFile
Derived from TInterfacedPersistent
AfterConstruction
QueryInterface
Derived from TPersistent
GetNamePath
Derived from TObject
BeforeDestruction
ClassInfo
ClassName
ClassNameIs
ClassParent
ClassType
CleanupInstance
DefaultHandler
Dispatch
FieldAddress
Free
FreeInstance
GetInterface
GetInterfaceEntry
GetInterfaceTable
InheritsFrom
InitInstance
InstanceSize
MethodAddress
MethodName
NewInstance
SafeCallException