- uses [...] {$IFDEF GLB_DELPHI} Dialogs, Graphics, Types, GR32, {$ENDIF} [...]
- function TglBitmapData.AssignFromBitmap(const aBitmap: TBitmap32): Boolean;
- var
- pSource: PColor32Array;
- pData, pTempData: PByte;
- Row, RowSize, TempWidth, TempHeight: Integer;
- IntFormat: TglBitmapFormat;
- begin
- result := false;
- if (Assigned(aBitmap)) then
- begin
- IntFormat := tfBGRA8ub4;
- TempWidth := aBitmap.Width;
- TempHeight := aBitmap.Height;
- RowSize := TFormatDescriptor.Get(IntFormat).GetSize(TempWidth, 1);
- GetMem(pData, TempHeight * RowSize);
- try
- pTempData := pData;
- for Row := 0 to TempHeight -1 do
- begin
- pSource := aBitmap.Scanline[Row];
- if (Assigned(pSource)) then
- begin
- Move(pSource^, pTempData^, RowSize);
- Inc(pTempData, RowSize);
- end;
- end;
- SetData(pData, IntFormat, TempWidth, TempHeight);
- result := true;
- except
- if Assigned(pData) then
- FreeMem(pData);
- raise;
- end;
- end;
- end;