Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-07

TLazIntfImage GetDataLineStart

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

theo
to Mattias Gaertner
The TLazIntfImage.Colors property converts automatically.

Thanks, I am aware of this.

/>> Is it safe to assume that the pointer from IntfImg.GetDataLineStart is />>/ always pointing to a PRGBTripleArray ?
/

No.

So the wiki example is misleading?

Is there a built in method in TLazIntfImage to convert to / ensure a certain format after loading an image form file etc.?

Thank you Mattias.

Reply by email

Mattias Gaertner
to theo
Show quoted text 11 lines
> The TLazIntfImage.Colors property converts automatically. Thanks, I am aware of this. />> Is it safe to assume that the pointer from IntfImg.GetDataLineStart is />>/ always pointing to a PRGBTripleArray ? / > No. So the wiki example is misleading?

Yes.
I replaced the note.

Is there a built in method in TLazIntfImage to convert to / ensure a certain format after loading an image form file etc.?

You can use TLazIntfImage to convert to any format you like. Just create a second TLazIntfImage, init its memory layout and copy the Colors:

var
  Description: TRawImageDescription;
  IntfImage1: TLazIntfImage;
begin
  Description.Init_BPP24_B8G8R8_BIO_TTB(IntfImage1.Width,IntfImage1.Height);
  IntfImage2:=TLazIntfImage.Create(0,0);
  IntfImage2.DataDescription:=Description;
  IntfImage2.CopyPixels(IntfImage1);
  ...
end;

I didn't test it, but it should work like that.

Keep in mind that TBitmap only supports the formats of the widgetset. You must convert back to the TBitmap format before calling CreateBitmaps. It depends on your drawing operations if these conversions pay off.

Mattias

Reply by email

theo
to Mattias Gaertner

Ah, now I see. Thanks!

I tried like below, it seems to work.
TBitmap.LoadFromIntfImage seems to care about the back-conversion, right?

procedure TForm1.Button1Click(Sender:TObject);
var li1,li2:TLazIntfImage;
  Description: TRawImageDescription;
  Row1: PRGBQuadArray;
i:integer;
begin
Li1:=TLazIntfImage.Create(0,0);
Li1.LoadFromDevice(Image1.Canvas.Handle);
Writeln(Li1.DataDescription.AsString);
Description.Init_BPP32_B8G8R8A8_BIO_TTB(Li1.Width,Li1.Height);
Li2:=TLazIntfImage.Create(0,0);
Li2.DataDescription:=Description;
Li2.CopyPixels(Li1);
Row1:=Li2.GetDataLineStart(3);
for i:=0 to 20 do
  begin
    Row1^[i].rgbRed:=$FF;
    Row1^[i].rgbGreen:=$88;
    Row1^[i].rgbBlue:=$88;
  end;
Writeln(Li2.DataDescription.AsString);
Image2.Picture.Bitmap.LoadFromIntfImage(Li2);
end;

Reply by email

Mattias Gaertner
to theo
Ah, now I see. Thanks! I tried like below, it seems to work. TBitmap.LoadFromIntfImage seems to care about the back-conversion, right?

AFAIK: no
The intfimage must be in a compatible format.

Mattias

Reply by email

Marc Weustink
to Mattias Gaertner
Mattias Gaertner wrote 10 lines
On Sun, 18 Jul 2010 01:02:03 +0200 theo wrote: > Ah, now I see. Thanks! > > I tried like below, it seems to work. > TBitmap.LoadFromIntfImage seems to care about the back-conversion, right? AFAIK: no The intfimage must be in a compatible format.

I thought it didnt, but recently I saw it does a conversion (somewhere).

BTW, TBitmap.LoadFromIntfImage loads through handle creation, which may lead to data loss (alpha channel, image depth)

Better use:

var
   RI: TRawImage;
begin
   ...
   IntfImg.GetRawImage(RI, True);
   Bitmap.LoadFromRawImage(RI, True);
   ...
end;

If you want to reuse the IntfImage data, then Pass False to both functions (don't transfer ownership)

Marc (still needs to adapt LoadFromIntfImage)

Marc

Reply by email

theo
to Marc Weustink

Both LoadFromRawImage and LoadFromIntfImage seem to work here without any conversion by me.
I'm now on a 16bit display for testing, and it has no problem showing the BPP32_B8G8R8A8_BIO_TTB image using
either mehtod.
Complicated matter without documentation. ;-)

Thank you both Marc an Mattias

Reply by email

Marc Weustink
to theo
theo wrote 9 lines
Both LoadFromRawImage and LoadFromIntfImage seem to work here without any conversion by me. I'm now on a 16bit display for testing, and it has no problem showing the BPP32_B8G8R8A8_BIO_TTB image using either mehtod. Complicated matter without documentation. ;-) Thank you both Marc an Mattias

:)

You will notice the difference if you want to save your bitmap to file.

Marc

Reply by email