Marc Weustink wrote:
Should I define lRow as a PByteArray?
In delphi mode, Yes.
Unless you want to compile this in Delphi, there is no reason to use
delphi mode. You can, if needed, use a different mode per unit.
Hi Marc,
Thanks for that and I'm a little bit further, but now get a crash.
The original data is stored as follows...
type
TDWordArray = array [WORD] of DWord;
PDWordArray = ^TDWordArray;
TBGR = packed record b,g,r: BYTE; end; // for 24-bit bitmaps
TBGRArray = array [WORD] of TBGR;
PBGRArray = ^TBGRArray;
TBGRA = packed record b,g,r,a: BYTE; end; // for 32-bit bitmaps
TBGRAArray = array [WORD] of TBGRA;
PBGRAArray = ^TBGRAArray;
var
s_data:PDWordArray; // the actual data
and I'm trying to convert it to a TBitmap using the following code...
function TInternalBitmap.CreateBitmap24 : TBitmap;
// Returns a 24-bit bitmap from the object
var
row:PBGRArray; // Row in the bitmap
i,j:integer;
ScanLineImage : TLazIntfImage;
ImgFormatDescription : TRawImageDescription;
begin
Result := nil;
Result := TBitmap.Create;
Result.PixelFormat := pf24bit;
Result.Width := s_w;
Result.Height := s_h;
ScanLineImage := TLazIntfImage.Create( s_w, s_h );
ImgFormatDescription.Init_BPP24_B8G8R8_BIO_TTB( s_w, s_h );
ScanLineImage.DataDescription := ImgFormatDescription;
for j := 0 to s_h - 1 do
begin
row := ScanLineImage.GetDataLineStart( j );
for i := 0 to s_w-1 do
begin
row[i].r := (s_data[j*s_w+i] shr 16) and $ff;
row[i].g := (s_data[j*s_w+i] shr 8) and $ff;
row[i].b := s_data[j*s_w+i] and $ff;
end;
end;
// create IntfImage with the format of the current LCL interface
Result.Width := ScanLineImage.Width;
Result.Height := ScanLineImage.Height;
// convert the content from the very specific to the current format
Result.LoadFromIntfImage( ScanLineImage );
ScanLineImage.Free;
{ Original Delphi code...
// Copy the data to the bitmap
for j := 0 to s_h-1 do
begin
row := Result.ScanLine[j];
for i := 0 to s_w-1 do
begin
row[i].r := (s_data[j*s_w+i] shr 16) and $ff;
row[i].g := (s_data[j*s_w+i] shr 8) and $ff;
row[i].b := s_data[j*s_w+i] and $ff;
end;
end;}
end;
But the call to Result.LoadFromIntfImage( ScanLineImage ); causes an AV
and I'm not sure why.
From what I can tell it's correctly grabbing the scanline information.
Any ideas?
Dominique.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives