Recent

Author Topic: Problem with TLazIntfImage : works with windows but not with linux  (Read 5585 times)

Axxel

  • Newbie
  • Posts: 2
Hi  :)

Sorry for advance for my english because I'm french.

I Try this code source usin the TLazIntfImage to work with scanlines like delphi.

This code allow to force the red channel at the maximum. (I took it form this example : http://wiki.lazarus.freepascal.org/Developing_with_Graphics )

Code: [Select]
procedure TForm1.FadeIn2(aBitMap: TBitMap);
 var
   IntfImg1, IntfImg2: TLazIntfImage;
   ImgHandle,ImgMaskHandle: HBitmap;
   FadeStep: Integer;
   px, py: Integer;
   CurColor: TFPColor;
   TempBitmap: TBitmap;
   Row1, Row2: PRGBTripleArray;
 begin
   IntfImg1:=TLazIntfImage.Create(0,0);
   IntfImg1.LoadFromBitmap(aBitmap.Handle,aBitmap.MaskHandle);

   IntfImg2:=TLazIntfImage.Create(0,0);
   IntfImg2.LoadFromBitmap(aBitmap.Handle,aBitmap.MaskHandle);

   TempBitmap:=TBitmap.Create;

   //with Scanline-like
   for FadeStep:=1 to 32 do begin
     for py:=0 to IntfImg1.Height-1 do begin
       Row1 := IntfImg1.GetDataLineStart(py); //like Delphi TBitMap.ScanLine
       Row2 := IntfImg2.GetDataLineStart(py); //like Delphi TBitMap.ScanLine
       for px:=0 to IntfImg1.Width-1 do begin
         Row2^[px].rgbtRed:= 255;
         Row2^[px].rgbtGreen := (FadeStep * Row1^[px].rgbtGreen) shr 5; // Fading
         Row2^[px].rgbtBlue := (FadeStep * Row1^[px].rgbtBlue) shr 5;
       end;
     end;
     IntfImg2.CreateBitmaps(ImgHandle,ImgMaskHandle,false);

     TempBitmap.Handle:=ImgHandle;
     TempBitmap.MaskHandle:=ImgMaskHandle;
     Canvas.Draw(0,0,TempBitmap);
   end;

   IntfImg1.Free;
   IntfImg2.Free;
   TempBitmap.Free;
 end;


I compile it under widows and this is a success !

http://img823.imageshack.us/img823/7431/winrl.jpg

An now I compile it under Ubuntu 10.10 and i have this result :

http://img689.imageshack.us/img689/6290/linuxf.jpg

I've tried a lot of things but unsuccessful  %)

Everyone have an idea how can we works with the scanlines under linux without this bug ?

I thought there is a bug into the linux LCL no  :o

Thank you for advance!

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1891
Re: Problem with TLazIntfImage : works with windows but not with linux
« Reply #1 on: March 21, 2011, 11:42:37 pm »
(I took it form this example : http://wiki.lazarus.freepascal.org/Developing_with_Graphics )

I read there:

Quote
If you know that the TBitmap is using blue 8bit, green 8bit, red 8bit you can directly access the bytes, which is somewhat faster:

I guess you don't know this.
Maybe it's not 24bpp but 32bpp or something else.
You could try with an array of TRGBQuad.

It's probably easier to do it like the first example in "Fading example", then you don't have to worry about pixelformats.

circular

  • Hero Member
  • *****
  • Posts: 3359
    • Personal webpage
Re: Problem with TLazIntfImage : works with windows but not with linux
« Reply #2 on: March 22, 2011, 01:38:34 am »
Or you can use BGRABitmap, I made it for this  ;)
Conscience is the debugger of the mind

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2510
Re: Problem with TLazIntfImage : works with windows but not with linux
« Reply #3 on: March 22, 2011, 11:07:26 am »
You falsely assume that all rawimages have the same data format.
Where on windows a pixel might be stored as a 3-byte RGB, it might be stored completely different on linux. It can be stored in 4 bytes, but also in 2 bytes (5-5-5) if your screen depth is only 16 bits.
Look at the IntfImage RawImageDescription  how the pixels are really stored.

When accessing raw image data, never assume the pixel layout.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Axxel

  • Newbie
  • Posts: 2
Re: Problem with TLazIntfImage : works with windows but not with linux
« Reply #4 on: March 26, 2011, 04:57:57 pm »
Hi.

Thanks ! It works wery well now with the TRGBQuad

 :)  :D

 

TinyPortal © 2005-2018