Recent

Author Topic: LazPaint (alpha-blending, antialiasing, filters)  (Read 531223 times)

circular

  • Hero Member
  • *****
  • Posts: 3666
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #60 on: February 15, 2011, 09:44:27 pm »
Conscience is the debugger of the mind

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #61 on: February 15, 2011, 10:27:01 pm »

Upps, I overlooked the file. Here is the changes.

//     {$IFDEF DARWIN}
//     RawImage.Description.Init_BPP32_R8G8B8_BIO_TTB(AWidth,AHeight);
//     SwapRedBlue;
//     {$ELSE}
     RawImage.Description.Init_BPP32_B8G8R8_BIO_TTB(AWidth,AHeight);
//     {$ENDIF}
     RawImage.Description.LineOrder:= ALineOrder;
     RawImage.Description.LineEnd := rileDWordBoundary;
     RawImage.Data:= PByte(AData);
     RawImage.DataSize:= AWidth*AHeight*Sizeof(TBGRAPixel);
     CreateSuccess := RawImage_CreateBitmaps(RawImage, BitmapHandle, MaskHandle, false);
//     {$IFDEF DARWIN}
//     SwapRedBlue;
//     {$ENDIF}

And here is the result.

circular

  • Hero Member
  • *****
  • Posts: 3666
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #62 on: February 16, 2011, 01:01:21 am »
It does not make sense. The header is correct, and the generation of the color circle does not goes through a TColor type. So there is no inversion in LazPaint code. So I suppose the error is in the Lazarus code or Freepascal code. We can fix it in LazPaint by swapping Red/Blue without changing headers, we will obtain the right result, but it is a trick. If the Freepascal code is corrected, it will be swapped again. In the meantime, can you try this:

     {$IFDEF DARWIN}
     SwapRedBlue;
     {$ENDIF}

     RawImage.Description.Init_BPP32_B8G8R8_BIO_TTB(AWidth,AHeight);
     RawImage.Description.LineOrder:= ALineOrder;
     RawImage.Description.LineEnd := rileDWordBoundary;
     RawImage.Data:= PByte(AData);
     RawImage.DataSize:= AWidth*AHeight*Sizeof(TBGRAPixel);
     CreateSuccess := RawImage_CreateBitmaps(RawImage, BitmapHandle, MaskHandle, false);

     {$IFDEF DARWIN}
     SwapRedBlue;
     {$ENDIF}

Note: there is another problem with the background color. In uchoosecolor.pas, in the procedure FormCreate, there are two lines to determine the colors of the text and of the background :

   FormBackgroundColor := ColorToBGRA(ColorToRGB(self.Color));
   FormTextColor := ColorToBGRA(ColorToRGB(clWindowText));

It seems that this does not work on Mac. Can you try this instead?

   FormBackgroundColor := ColorToBGRA(ColorToRGB(clBtnFace));
   FormTextColor := ColorToBGRA(ColorToRGB(clWindowText));
« Last Edit: February 16, 2011, 01:05:18 am by circular »
Conscience is the debugger of the mind

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #63 on: February 16, 2011, 04:48:41 pm »
For the first changes, but the effect is same. (output is the same as the previous one.)
     if (AHeight=0) or (AWidth = 0) then exit;

     RawImage.Init;
     {$IFDEF DARWIN}
     SwapRedBlue;
     {$ENDIF}

          RawImage.Description.Init_BPP32_B8G8R8_BIO_TTB(AWidth,AHeight);
          RawImage.Description.LineOrder:= ALineOrder;
          RawImage.Description.LineEnd := rileDWordBoundary;
          RawImage.Data:= PByte(AData);
          RawImage.DataSize:= AWidth*AHeight*Sizeof(TBGRAPixel);
          CreateSuccess := RawImage_CreateBitmaps(RawImage, BitmapHandle, MaskHandle, false);

     {$IFDEF DARWIN}
     SwapRedBlue;
     {$ENDIF}

     if not CreateSuccess then ...
----------------------------------------------------------------------------------------------------
And the second is correct, that can be changed as you suggested.
   FormBackgroundColor := ColorToBGRA(ColorToRGB(clBtnFace));
   FormTextColor := ColorToBGRA(ColorToRGB(clWindowText));            

For the first case, I tested with the original TColorDialog on the mac and the result is correct. I mean the colors are the correct positions.

Here is the trick point maybe this can be show the way.
In the first screenshot (screenshot1) the red picked from the Color Window, but blue is shown. (I pointed with the red circle)
In the second screenshot (screenshot2) the blue picked from the Color Window, but red is shown. (I pointed out with the red circle)
Thanks.
« Last Edit: February 16, 2011, 05:06:39 pm by IndianaJones »

circular

  • Hero Member
  • *****
  • Posts: 3666
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #64 on: February 16, 2011, 09:27:57 pm »
For the first changes, but the effect is same. (output is the same as the previous one.)
     if (AHeight=0) or (AWidth = 0) then exit;

     RawImage.Init;
     {$IFDEF DARWIN}
     SwapRedBlue;
     {$ENDIF}

          RawImage.Description.Init_BPP32_B8G8R8_BIO_TTB(AWidth,AHeight);
          RawImage.Description.LineOrder:= ALineOrder;
          RawImage.Description.LineEnd := rileDWordBoundary;
          RawImage.Data:= PByte(AData);
          RawImage.DataSize:= AWidth*AHeight*Sizeof(TBGRAPixel);
          CreateSuccess := RawImage_CreateBitmaps(RawImage, BitmapHandle, MaskHandle, false);

     {$IFDEF DARWIN}
     SwapRedBlue;
     {$ENDIF}

That's not possible. Maybe the compilation is not complete. When you run the project, do a "rebuild all" or something like this. It is the item after normal build (Ctrl-F9). Can you try commenting or decommenting the SwapRedBlue line, rebuild everything and launch the program?

Quote
Here is the trick point maybe this can be show the way.
In the first screenshot (screenshot1) the red picked from the Color Window, but blue is shown. (I pointed with the red circle)
In the second screenshot (screenshot2) the blue picked from the Color Window, but red is shown. (I pointed out with the red circle)
In this cas, clearly the color circle is red-blue swapped.

Thanks.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3666
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #65 on: February 16, 2011, 11:02:13 pm »
I've updated the English help for LazPaint and BGRABitmap :
http://wiki.lazarus.freepascal.org/LazPaint
http://wiki.lazarus.freepascal.org/BGRABitmap
Conscience is the debugger of the mind

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #66 on: February 16, 2011, 11:06:47 pm »
I rebuild the application with Build All, but there is no difference. So I think BGRAGtkBitmap is not interpreted because of the $(LCLWidgetType) in the BGRABitmap unit.
In this unit there are the following statements but carbon is missing or BGRADefaultBitmap is interpreted not BGRAGtkBitmap.
That could be the problem or may be I am wrong with looking at the source code.
P.S. I am using Mac OS X (Carbon widgetset)

{$IFDEF LCLwin32}
  BGRAWinBitmap
{$ELSE}
  {$IFDEF LCLgtk}
   BGRAGtkBitmap
  {$ELSE}
    {$IFDEF LCLgtk2}
     BGRAGtkBitmap
    {$ELSE}
     BGRADefaultBitmap
    {$ENDIF}
  {$ENDIF}
{$ENDIF}                   

circular

  • Hero Member
  • *****
  • Posts: 3666
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #67 on: February 16, 2011, 11:33:47 pm »
You're right. If it's not using Gtk, the it swaps to default implementation.

I have done new changes. You can download it on subversion. Does it work ?

It is possible to make a special unit for carbon, in order to make it faster. Problem is I can't do it myself because I do not have carbon.
Conscience is the debugger of the mind

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #68 on: February 17, 2011, 12:29:38 pm »

I have tested the latest svn 15, and get the following error while compiling.

/lazpaint/bgrabitmap/bgradefaultbitmap.pas(3118,27) Error: identifier idents no member "Init_BPP24_R8G8B8_BIO_TTB"

circular

  • Hero Member
  • *****
  • Posts: 3666
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #69 on: February 17, 2011, 05:06:17 pm »
Ok. So let's do the swap manually.

Can you try with the new version ?
Conscience is the debugger of the mind

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #70 on: February 17, 2011, 08:40:23 pm »
I have tested with the new svn 16, and it works now also "New Image" window renders ok.
P.S. Hide/Unhide can be added to the Tools and Color windows.
Good work.
« Last Edit: February 17, 2011, 08:49:52 pm by IndianaJones »

circular

  • Hero Member
  • *****
  • Posts: 3666
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #71 on: February 17, 2011, 09:39:22 pm »
Cool. Thank you.

About hiding tools and color window, it is possible with the menu View.

What about blur windows (in Filter menu) ?
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3666
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #72 on: February 18, 2011, 01:28:28 am »
Here is a new version (1.7)
- renders correctly on MacOS
- added two filters : sphere and cylinder
- added "crop to selection" in Image menu

https://sourceforge.net/projects/lazpaint/files/lazpaint/
Conscience is the debugger of the mind

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #73 on: February 18, 2011, 12:46:18 pm »
Quote
What about blur windows (in Filter menu) ?
It would be superb.

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 251
    • Fresh sound.
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #74 on: February 18, 2011, 01:03:03 pm »
Hello Circular,

I wanted to debug into the Blur methods but it does not stop when I set the breakpoints.
How to do this?

I did once a little performance optimization.

The optimizations is based on the following theory:
A) to "get" a pixel is faster the "set" a pixel.
B) a black pixel can not get darker than black.

So this means from a performance point of view, it make sense to only calculate blur for pixels which are not already black.
 
http://www.cabiatl.com/mricro/bounty/

Regards,
Sam

Linux Mint 19.1, Lazarus 2.0, Windows 7&10, Delphi 7, Delphi 10.3 Rio

 

TinyPortal © 2005-2018