Recent

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

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #135 on: March 09, 2011, 05:55:07 pm »
Ok, i've tried. It works, but the following line must be commented out :
Quote
RequireDerivedFormResource := True;

What is this line for?
Maybe with a compiler directive can we make a version that works directly on both Lazarus ?
Conscience is the debugger of the mind

DirkS

  • Sr. Member
  • ****
  • Posts: 251
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #136 on: March 09, 2011, 06:14:41 pm »
Ok, i've tried. It works, but the following line must be commented out :
Quote
RequireDerivedFormResource := True;

What is this line for?
Maybe with a compiler directive can we make a version that works directly on both Lazarus ?
See http://wiki.lazarus.freepascal.org/Lazarus_0.99.0_release_notes#TCustomForm.Create_raises_an_exception_if_resource_is_not_found

So if you're using a resource-less form you should use Form.CreateNew instead of .Create.

Gr.
Dirk.

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #137 on: March 09, 2011, 06:24:57 pm »
I understand but there was no such line in previous version of Lazarus.
Conscience is the debugger of the mind

DirkS

  • Sr. Member
  • ****
  • Posts: 251
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #138 on: March 09, 2011, 06:39:19 pm »
I understand but there was no such line in previous version of Lazarus.
AFAIK if you use CreateNew it should compile in all versions...

Gr.
Dirk.

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #139 on: March 09, 2011, 08:24:10 pm »
I don't know, the line is :
Quote
Application.CreateForm(TFMain, FMain)
Conscience is the debugger of the mind

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #140 on: March 09, 2011, 10:14:14 pm »
I don't know, the line is :
Quote
Application.CreateForm(TFMain, FMain)

This line is correct. I just commented the "RequireDerivedFormResource := True;" as it's only for the new lazarus, now it should compile on all Lazarus versions
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

DirkS

  • Sr. Member
  • ****
  • Posts: 251
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #141 on: March 09, 2011, 11:35:08 pm »
I don't know, the line is :
Quote
Application.CreateForm(TFMain, FMain)

This line is correct. I just commented the "RequireDerivedFormResource := True;" as it's only for the new lazarus, now it should compile on all Lazarus versions
IMHO that's the wrong way around... if the main form does not use a 'normal' resource it should be created with CreateNew. In the not too distant future you'll probably have to change it anyway, so why not now?

Gr.
Dirk.

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #142 on: March 10, 2011, 12:38:06 am »
Fixed now.
I have reconstruct LPI and LPR files so it will compile on all Lazarus versions.
Tell me if it works DirkS please :)
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #143 on: March 10, 2011, 04:49:21 pm »
In fact it was already working on v0.9.28 with a project with .pas. It was ok. The only thing was this little line with the boolean.
Conscience is the debugger of the mind

Gintas

  • Jr. Member
  • **
  • Posts: 71
    • Developer's Diary
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #144 on: March 11, 2011, 03:19:56 pm »
I updated the SVN so you can now compile the testbgrafunc and enjoy demos :)

Just tested on Linux and works like a charm. Those demos gives me some ideas :)

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #145 on: March 11, 2011, 04:10:50 pm »
Cool  :)
Conscience is the debugger of the mind

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #146 on: March 11, 2011, 10:58:48 pm »
@circular. I am experimenting with TBGRABitmap. Most of lazarus components (e.g. TToolBar) which have ImageList property, using this imagelist to draw icon (TImageList.Draw). So I change TImageList.Draw method to virtual and create TBGRAImageList component which inherit from TImageList and override Draw method (don't pay attention to performance, I am not familiar in drawing, I am only testing):
Code: Pascal  [Select][+][-]
  1. type
  2.  
  3.   { TBGRAImageList }
  4.  
  5.   TBGRAImageList = class(TImageList)
  6.   private
  7.     { Private declarations }
  8.     FBGRA: TBGRABitmap;
  9.   protected
  10.     { Protected declarations }
  11.   public
  12.     { Public declarations }
  13.     constructor Create(AOwner: TComponent); override;
  14.     destructor Destroy; override;
  15.  
  16.     procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer;
  17.       ADrawEffect: TGraphicsDrawEffect); override;
  18.   published
  19.     { Published declarations }
  20.   end;    
  21.  
  22. procedure TBGRAImageList.Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer;
  23.   ADrawEffect: TGraphicsDrawEffect);
  24. var
  25.   bmp: TBitmap;
  26. begin
  27.   //inherited; - We use TBGRABitmap drawing only
  28.  
  29.   // This is required part from TImageList.Draw
  30.   if (AIndex < 0) or (AIndex >= Count) then Exit;
  31.   ReferenceNeeded;
  32.  
  33.   // My code
  34.   bmp := TBitmap.Create;
  35.   GetBitmap(AIndex, bmp, ADrawEffect);
  36.   FBGRA := TBGRABitmap.Create(bmp);
  37.   //FBGRA.Assign(bmp); <- this dosen't work so I use above constructor
  38.   FBGRA.Draw(ACanvas, AX, AY, True);
  39.   // This works without error but have no alpha channel
  40.   //ACanvas.Draw(AX, AY, FBGRA.Bitmap);
  41.   bmp.Free;
  42.   FBGRA.Free;
  43. end;
  44.  
See comments. ACanvas.Draw works but without alpha channel. FBGRA.Draw raise some strange exception SIGFPE. This is last call stack:
Quote
#0 RAISEGDBEXCEPTION(0xa1c3e0 'TGtk2WidgetSet.CreateBitmapFromRawImage Incompatible BitsPerPixel') at lclproc.pas:1544
#1 RAWIMAGE_CREATEBITMAPS(0x7ffff7f86ed0, {DESCRIPTION = {FORMAT = RICFRGBA, WIDTH = 32, HEIGHT = 32, DEPTH = 24, BITORDER = RIBOBITSINORDER, BYTEORDER = RIBOLSBFIRST, LINEORDER = RILOTOPTOBOTTOM, LINEEND = RILEDWORDBOUNDARY, BITSPERPIXEL = 24, REDPREC = 8, REDSHIFT = 16, GREENPREC = 8, GREENSHIFT = 8, BLUEPREC = 8, BLUESHIFT = 0, ALPHAPREC = 0, ALPHASHIFT = 0, MASKBITSPERPIXEL = 0, MASKSHIFT = 0, MASKLINEEND = RILETIGHT, MASKBITORDER = RIBOBITSINORDER, PALETTECOLORCOUNT = 0, PALETTEBITSPERINDEX = 0, PALETTESHIFT = 0, PALETTELINEEND = RILETIGHT, PALETTEBITORDER = RIBOBITSINORDER, PALETTEBYTEORDER = RIBOLSBFIRST}, DATA = 0x7ffff7fbe310 'M' <repeats 39 times>, #255#255#255#255#255#255#255#255#255'M' <repeats 24 times>, #255 <repeats 24 times>, 'M' <repeats 39 times>, #255#255#255'M' <repeats 33 times>, #255 <repeats 21 times>, 'MMMMMMMM'..., DATASIZE = 3072, MASK = 0x0, MASKSIZE = 0, PALETTE = 0x0, PALETTESIZE = 0}, 140737353512256, 0, false) at gtk2/gtk2lclintf.inc:407
#2 RAWIMAGE_CREATEBITMAPS({DESCRIPTION = {FORMAT = RICFRGBA, WIDTH = 32, HEIGHT = 32, DEPTH = 24, BITORDER = RIBOBITSINORDER, BYTEORDER = RIBOLSBFIRST, LINEORDER = RILOTOPTOBOTTOM, LINEEND = RILEDWORDBOUNDARY, BITSPERPIXEL = 24, REDPREC = 8, REDSHIFT = 16, GREENPREC = 8, GREENSHIFT = 8, BLUEPREC = 8, BLUESHIFT = 0, ALPHAPREC = 0, ALPHASHIFT = 0, MASKBITSPERPIXEL = 0, MASKSHIFT = 0, MASKLINEEND = RILETIGHT, MASKBITORDER = RIBOBITSINORDER, PALETTECOLORCOUNT = 0, PALETTEBITSPERINDEX = 0, PALETTESHIFT = 0, PALETTELINEEND = RILETIGHT, PALETTEBITORDER = RIBOBITSINORDER, PALETTEBYTEORDER = RIBOLSBFIRST}, DATA = 0x7ffff7fbe310 'M' <repeats 39 times>, #255#255#255#255#255#255#255#255#255'M' <repeats 24 times>, #255 <repeats 24 times>, 'M' <repeats 39 times>, #255#255#255'M' <repeats 33 times>, #255 <repeats 21 times>, 'MMMMMMMM'..., DATASIZE = 3072, MASK = 0x0, MASKSIZE = 0, PALETTE = 0x0, PALETTESIZE = 0}, 140737353512256, 0, false) at include/lclintf.inc:159
#3 DATADRAWOPAQUE(0x7ffff7feb120, 0x7ffff7e0ce00, {LEFT = 2, TOP = 1, RIGHT = 34, BOTTOM = 33, TOPLEFT = {X = 2, Y = 1}, BOTTOMRIGHT = {X = 34, Y = 33}}, 0x7ffff7fbb950, RILOTOPTOBOTTOM, 32, 32) at ../lazpaint/bgrabitmap/bgradefaultbitmap.pas:3979
#4 DRAW(0x7ffff7feb120, 0x7ffff7e0ce00, 2, 1, true) at ../lazpaint/bgrabitmap/bgradefaultbitmap.pas:1060
#5 DRAW(0x7ffff7e04340, 0x7ffff7e0ce00, 2, 1, 0, GDENORMAL) at bgraimagelist.pas:66
#6 DRAW(0x7ffff7e04340, 0x7ffff7e0ce00, 2, 1, 0, true) at include/imglist.inc:495
#7 PAINT(0x7ffff7fbb530) at include/toolbutton.inc:356
#8 WMPAINT(0x7ffff7fbb530, {MSG = 15, UNUSEDMSG = 32767, DC = 140737352024128, PAINTSTRUCT = 0x0, RESULT = 0}) at include/graphiccontrol.inc:64
#9 SYSTEM_TOBJECT_$__DISPATCH$formal at :0
#10 DESTROY(0x7ffff7fbb530, 0x7fffffffd538) at include/graphiccontrol.inc:46
#11 PERFORM(0x7ffff7fbb530, 15, 140737352024128, 0) at include/control.inc:1083
#12 PAINTCONTROLS(0x7ffff7fbab70, 140737352024128, 0x0) at include/wincontrol.inc:4791
#13 PAINTHANDLER(0x7ffff7fbab70, {MSG = 15, UNUSEDMSG = 0, DC = 140737352024128, PAINTSTRUCT = 0x7ffff7f758e0, RESULT = 0}) at include/wincontrol.inc:4709
#14 WMPAINT(0x7ffff7fbab70, {MSG = 15, UNUSEDMSG = 0, DC = 140737352024128, PAINTSTRUCT = 0x7ffff7f758e0, RESULT = 0}) at include/wincontrol.inc:6560
#15 WMPAINT(0x7ffff7fbab70, {MSG = 15, UNUSEDMSG = 0, DC = 140737352024128, PAINTSTRUCT = 0x7ffff7f758e0, RESULT = 0}) at include/customcontrol.inc:112
#16 SYSTEM_TOBJECT_$__DISPATCH$formal at :0
Have you any idea? This can solve most problems with alpha on lazarus GTK
« Last Edit: March 11, 2011, 11:02:20 pm by Dibo »

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #147 on: March 12, 2011, 12:04:26 am »
@circular
Here is the screenshot of the Colorize also Shift Colors is the same in Mac.
And Colorize menu could be Single Borderstyle. These are the minor changes I notice.
Anyway the processing of the application goes well by the way.   :D

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #148 on: March 12, 2011, 10:23:57 am »
@dibo

I've updated Assign function so now it should take transparency into account.

I don't understand why this error pops up. I tested BGRA drawing on forms and it was working fine. Does the bgrafunctest work on your configuration ?

Maybe you are using BGRADefaultBitmap unit instead of BGRABitmap unit. It should not use DataDrawOpaque of TBGRADefaultBitmap but DrawOpaque from TBGRAGtkBitmap instead.

But you are using TBGRABitmap that should redirect to the right implementation. So maybe is there a problem with the $IFDEF.

@indianajones

There was a problem of font size, it's fixed. Every form must have a font size set to avoid it to change according to system configuration. If font size is zero, then it's kind of random.

About BorderStyle, here on Windows, if I set to Single border, the form becomes sizable.

I don't understand why you have the size thing at the bottom right, because Dialog border should not be sizable. By the way, what does Single border mean exactly for a form ?
« Last Edit: March 12, 2011, 10:37:44 am by circular »
Conscience is the debugger of the mind

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #149 on: March 12, 2011, 04:12:15 pm »
I've updated Assign function so now it should take transparency into account.
Works, thanks.
Quote
I don't understand why this error pops up. I tested BGRA drawing on forms and it was working fine. Does the bgrafunctest work on your configuration ?

Maybe you are using BGRADefaultBitmap unit instead of BGRABitmap unit. It should not use DataDrawOpaque of TBGRADefaultBitmap but DrawOpaque from TBGRAGtkBitmap instead.

But you are using TBGRABitmap that should redirect to the right implementation. So maybe is there a problem with the $IFDEF.
If I draw with Opaque=False then there is no error but it draw without alpha. But you have right that somethin wrong is with compiler defines. I have GTK2 but it uses this block in BGRABitmap unit:
Code: Pascal  [Select][+][-]
  1. {$ELSE}
  2.   BGRADefaultBitmap,
  3. {$ENDIF}  
  4.  
But only when I use TBGRABitmap in this component. In simple project it uses correct units. Strange...

 

TinyPortal © 2005-2018