Recent

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

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #90 on: February 22, 2011, 06:12:48 pm »
your progress on LazPaint is incredible! Does your day have more than 24 hours?
No, I'm not working full time.

Quote
I had to modify the unit <ucliboard>.

Replaced the line

     
Code: [Select]
result := TBGRABitmap.Create(Stream);
with
     
Code: [Select]
       result := TBGRABitmap.Create;
       result.LoadFromStream(Stream);   
     

Now I can compile the project.
That's right, I forgot to update BGRABitmap, i've added a create shortcut.
Conscience is the debugger of the mind

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #91 on: February 22, 2011, 06:29:41 pm »
Can I somehow use BGRABitmap to draw PNG glyph with alpha on TSpeedButton? This code:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   bmp := TBGRABitmap.Create('config.png');
  4. end;    
  5.  
  6. procedure TForm1.FormDestroy(Sender: TObject);
  7. begin
  8.  bmp.Free;
  9. end;  
  10.  
  11. procedure TForm1.SpeedButton1Paint(Sender: TObject);
  12. begin
  13.   bmp.Draw(SpeedButton1.Canvas, 1,1, True);
  14. end;      
  15.  
... draw icons with black background (see attachment)

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #92 on: February 23, 2011, 05:04:52 pm »
Yes, it depends on the last parameter of Draw. Here it is True, which means Opaque. It's faster but of course, it's not what you want if you want transparency.
Conscience is the debugger of the mind

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #93 on: February 23, 2011, 06:14:32 pm »
Hm, with "False" this same problem

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #94 on: February 23, 2011, 07:25:22 pm »
Strange. Can you debug it to see what drawing procedure is called ?

What about :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.SpeedButton1Paint(Sender: TObject);  
  2. begin  
  3.   SpeedButton1.Canvas.Draw(1, 1, bmp.Bitmap);
  4. end;
?
Conscience is the debugger of the mind

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #95 on: February 23, 2011, 08:35:20 pm »
Now it works... almost. Lazarus GTK have known issue, it don't have alpha drawing. So images on SpeedButton have jagged edges (or this is antialiasing?). I thought that I solve this problem using TBGRABitmap draw, but this same result (see attachment). I don't know why on TBitBtn images looks clear (if GTK have no alpha). I want to get result like on second button.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #96 on: February 23, 2011, 11:03:22 pm »
Ok. If you do :
  SpeedButton1.Canvas.Draw(1, 1, bmp.Bitmap); 
it use the bitmap property, it uses standard drawing functions, so there is no alpha blending.

So the right way should be :
  bmp.Draw(SpeedButton1.Canvas, 1,1, False);

When you debug it, go step by step, what procedures are executed on this line ?
Conscience is the debugger of the mind

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #97 on: February 24, 2011, 12:30:06 am »
Quote
#0 PUTIMAGE(0x7ffff7feb3a0, 0, 0, 0x7ffff7fead60, DMDRAWWITHTRANSPARENCY) at ../../components/lazpaint/bgrabitmap/bgradefaultbitmap.pas:3016
#1 SLOWDRAWTRANSPARENT(0x7ffff7fead60, 0x7ffff7fead60, 0x7ffff7e43a40, {LEFT = 1, TOP = 1, RIGHT = 33, BOTTOM = 33, TOPLEFT = {X = 1, Y = 1}, BOTTOMRIGHT = {X = 33, Y = 33}}) at ../../components/lazpaint/bgrabitmap/bgragtkbitmap.pas:80
#2 DRAW(0x7ffff7fead60, 0x7ffff7e43a40, 1, 1, false) at ../../components/lazpaint/bgrabitmap/bgragtkbitmap.pas:110
#3 SPEEDBUTTON1PAINT(0x7ffff7fb6590, 0x7ffff7fb7b70) at unit1.pas:40[/quote

Are you need more details? Go deeper?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #98 on: February 24, 2011, 12:39:17 am »
Thank you. You don't need to go deeper here.

It goes into SLOWDRAWTRANSPARENT, this routine is supposed to draw with transparency. So there is a problem here.

Code: Pascal  [Select][+][-]
  1. procedure TBGRAGtkBitmap.SlowDrawTransparent(ABitmap: TBGRADefaultBitmap;
  2.   ACanvas: TCanvas; ARect: TRect);
  3. var
  4.   background, temp: TBGRADefaultBitmap;
  5.   w, h: integer;
  6.  
  7. begin
  8.   w := ARect.Right - ARect.Left;
  9.   h := ARect.Bottom - ARect.Top;
  10.   background := NewBitmap(w, h);
  11.   background.GetImageFromCanvas(ACanvas, ARect.Left, ARect.Top);
  12.   if (ABitmap.Width = w) and (ABitmap.Height = h) then
  13.     background.PutImage(0, 0, ABitmap, dmDrawWithTransparency)
  14.   else
  15.   begin
  16.     temp := ABitmap.Resample(w, h, rmSimpleStretch);
  17.     background.PutImage(0, 0, temp, dmDrawWithTransparency);
  18.     temp.Free;
  19.   end;
  20.   background.Draw(ACanvas, ARect.Left, ARect.Top, True);
  21.   background.Free;
  22. end;
The background should be initialized to the current background by :
  background.GetImageFromCanvas(ACanvas, ARect.Left, ARect.Top);

Maybe GetImageFromCanvas do not work on a speed button.

What happens if you try to draw your transparent bitmap outside the paint event of the speed button ? And if you draw the image directly on the form instead of the speed button ?
Conscience is the debugger of the mind

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #99 on: February 24, 2011, 12:56:06 am »
This same poblem (attachment). I am using TBGRABitmap from LazPaint 2.0

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 255
    • Fresh sound.
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #100 on: February 24, 2011, 06:59:22 am »
Hello circular,

here is a hint for another little improvement.

Could you please save the settings for Dialog "New Image" so it is available again after the restart of LazPaint?

It's always set to 640*480.

Thank you.
Linux Mint 20.3, Lazarus 2.3, Windows 10, Delphi 10.3 Rio, Delphi 11.1 Alexandria

de_jean_7777

  • New Member
  • *
  • Posts: 11
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #101 on: February 24, 2011, 09:29:54 am »
Very impressive program. I just wanted to say that the lazpaint.compiled and lazpaint.res files do not need to be in the svn repository, as they are generated upon compilation.
Existence is pain

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #102 on: February 24, 2011, 11:13:03 am »
This same poblem (attachment). I am using TBGRABitmap from LazPaint 2.0
Ok, so I suppose that GetImageFromCanvas do not work at all on gtk2. You can check this by drawing something on the form with the normal canvas, then call GetImageFromCanvas with a TBGRABitmap, and then draw it (in opaque mode) somewhere else on the form and see if something is copied.

Could you please save the settings for Dialog "New Image" so it is available again after the restart of LazPaint?
Ok. Done.

Very impressive program. I just wanted to say that the lazpaint.compiled and lazpaint.res files do not need to be in the svn repository, as they are generated upon compilation.
Ok, thank you. Done.
« Last Edit: February 24, 2011, 11:23:57 am by circular »
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 #103 on: February 24, 2011, 12:49:14 pm »
Hey circular,

Would it be easy to implement multiple-file support? (having Tabs?)
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #104 on: February 24, 2011, 07:04:40 pm »
No, it would need refactoring.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018