Recent

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

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #75 on: February 18, 2011, 03:24:34 pm »
Quote
What about blur windows (in Filter menu) ?
It would be superb.
It is already there. I was asking if it works on Mac OS.

Hello Circular,

I wanted to debug into the Blur methods but it does not stop when I set the breakpoints.
Maybe it is in compiler options (code optimizations and link options may disturb debugger).

Quote
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.
What changes do you propose exactly ? Can you post here the resulting code ?
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #76 on: February 18, 2011, 05:54:36 pm »
Hi folks.

Here is a new version ( 1.8 ) with :
- rotate 90°
- GPL license for LazPaint, LGPL for BGRABitmap
- embedded Paint.NET files reading in BGRABitmap (so it's LGPL)
- clouds rendering
- autoshow grid
- set canvas size
- selection fit
- remove transparency menu

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

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #77 on: February 20, 2011, 01:22:13 am »
And another new version 1.9 with :
- hue support (colorize, colorshift)
- lightness and intensity of colors
- gif and ico loading
- normalize each channel and with gamma correction

https://sourceforge.net/projects/lazpaint/files/lazpaint/

I guess this version is quite complete. Maybe I'll add some other features (magic wand, sin gradient and effects like a pen). I'm looking for people to make binaries on different platforms. I can do it for Win64.
Conscience is the debugger of the mind

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 251
    • Fresh sound.
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #78 on: February 20, 2011, 05:55:07 am »
Hi,

But to make it a "complete" product, I suggest to add the following features:

- Recent Files list. (displays the latest files used in LazPaint)
- an About-Dialog with Information about LazPaint (Autor,VersionNo,Link to Homepage,Libraries used)

And very important:
- an "Self-Test" command line parameter. e.g. c:\lazpaint -selftest.
This "Self-Test" feature should do the following:

1.) load a test picture.
2.) call each filter function once.
3.) measure the execution time of each filter function. e.g. gettickcount.
4.) call other image manipulation functions to check e.g. rotate, paint a box ...
5.) save the final image together with a little log-file about version,computername,execution time of the filters into a file with name "yyyymmdd_HHMMSS_LazPaint_Selftest.txt"

This self-test feature would be very helpfull for:

  - people who build the executables for the different platforms.
  - you to check if LazPaint does not have regressions after you changed something.

If you provide such I Self-Test feature, I will provide the win32 executables for LazPaint.

By the way:
I recommend you to let the files in folder "bgrabitmap" go through the "Tools"->"JEDI Code Format".

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

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #79 on: February 20, 2011, 03:52:29 pm »
I understand. I will take this into accout.

I asked you about the optimization you were proposing before. Did you notice ?

Another thing I was asking about, if someone know how to read and write to the clipboard, I would be happy to have some explanations. The program uses only an internal clipboard yet.
« Last Edit: February 20, 2011, 03:55:53 pm by circular »
Conscience is the debugger of the mind

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 251
    • Fresh sound.
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #80 on: February 20, 2011, 05:14:29 pm »
Hello circular,

yes I noticed about your question for optimizations.

Sorry I had not time until now, but now I had just a quick look and as an example I propose this:
Code: [Select]
procedure ErasePixelInline(dest: PBGRAPixel;
  alpha: byte); inline;
var newAlpha: byte;
begin
  newAlpha := dest^.alpha * (255-alpha) div 255;
  if newAlpha = 0 then dest^:= BGRAPixelTransparent else
    dest^.alpha := newAlpha;
end;

In this method a new value for alpha is calculated.
So if dest^.alpha is already 0, then newAlpha will also be 0. There is no need to calculate in this case. It will save you some CPU time.
As I pointed out already, I just had a quick look and I am sure there are more situations like this in your bitmap library.

Another hint: I compiled LazPaint with Compiler switch "Range Check". In this case, LazPaint will fire an "run error 201" in method

Code: [Select]
function ColorToBGRA(color: TColor): TBGRAPixel; overload;
begin
  result.red := color;
  result.green := color shr 8;
  result.blue := color shr 16;
  result.alpha := 255;
end;



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

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #81 on: February 20, 2011, 05:52:39 pm »
I have just tried the new fast release :) and something wrong with the Smart Zoom x3.
After doing 2 times "Smart Zoom x3" and one time "Zoom fit", the applications going into the crazy phase. (not response correctly)

Secondly, Under the Colors menu: revise the Colorize(window position different than the other ones),Shift Colors, Intensity menus, not renders correctly.
Thirdly, After doing Grayscale Tools and Color menus paint themselves again.

P.S. Hide/Unhide looks good.  :D

Leledumbo

  • Hero Member
  • *****
  • Posts: 8294
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #82 on: February 20, 2011, 08:10:39 pm »
I don't know, is it just me or do I really start seeing another PhotoShop / GIMP alternative but with Paint(.NET) easy drawing capabilities? You're nuts, circular! :P

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #83 on: February 20, 2011, 10:31:21 pm »
In this method a new value for alpha is calculated.
So if dest^.alpha is already 0, then newAlpha will also be 0. There is no need to calculate in this case. It will save you some CPU time.
I understand. Well, maybe I'll try to optimize the program, but it's not in my priorities, except of course things that do really slow the program in a normal use.

Quote
Another hint: I compiled LazPaint with Compiler switch "Range Check". In this case, LazPaint will fire an "run error 201" in method

Code: [Select]
function ColorToBGRA(color: TColor): TBGRAPixel; overload;
begin
  result.red := color;
  result.green := color shr 8;
  result.blue := color shr 16;
  result.alpha := 255;
end;
That's right, and it's on purpose. I wanted to avoid the "and 255".

I don't know, is it just me or do I really start seeing another PhotoShop / GIMP alternative but with Paint(.NET) easy drawing capabilities? You're nuts, circular! :P
Thanks !   :D

I have just tried the new fast release :) and something wrong with the Smart Zoom x3.
After doing 2 times "Smart Zoom x3" and one time "Zoom fit", the applications going into the crazy phase. (not response correctly)
Hmm... I could not reproduce this problem. Which size is the image at the beggining ?

Quote
Secondly, Under the Colors menu: revise the Colorize(window position different than the other ones)
Ok.

Quote
Shift Colors, Intensity menus, not renders correctly.
Can you send a screenshot ?

Quote
Thirdly, After doing Grayscale Tools and Color menus paint themselves again.
What do you mean?

Quote
P.S. Hide/Unhide looks good.  :D
Cool
Conscience is the debugger of the mind

José Mejuto

  • Full Member
  • ***
  • Posts: 136
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #84 on: February 21, 2011, 10:11:16 am »
Quote
Another hint: I compiled LazPaint with Compiler switch "Range Check". In this case, LazPaint will fire an "run error 201" in method
Code: [Select]
function ColorToBGRA(color: TColor): TBGRAPixel; overload;
begin
  result.red := color;
  result.green := color shr 8;
  result.blue := color shr 16;
  result.alpha := 255;
end;
That's right, and it's on purpose. I wanted to avoid the "and 255".

Hello,

So better include it in a range check disable directive:
Code: [Select]
{$PUSH}{$R-}
  result.red := color;
  result.green := color shr 8;
  result.blue := color shr 16;
  result.alpha := 255;
{$POP}

panoss

  • Full Member
  • ***
  • Posts: 156
  • You only live twice
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #85 on: February 21, 2011, 11:17:29 am »
I tried Lazpaint in Windows, works perfectly. My congratulations!
But, then i tried in Ubuntu 9.10 (Lazarus 0.9.28.2).
I get the message (/usr/lib/lazarus/0.9.28.2/examples/lazpaint1.9/bgrabitmap/bgragtkbitmap.pas(131,38) Error: Identifier not found "TGtkDeviceContext") trying to install Lazpaint.
The file gtkdevicecontext.inc is in the folder /usr/lib/lazarus/0.9.28.2/lcl/interfaces/gtk.
Windows 7 32bit, Lazarus v1.8.4    FPC 3.0.4.

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #86 on: February 21, 2011, 09:03:52 pm »
I tried Lazpaint in Windows, works perfectly. My congratulations!
Cool  8)

Quote
But, then i tried in Ubuntu 9.10 (Lazarus 0.9.28.2).
I get the message (/usr/lib/lazarus/0.9.28.2/examples/lazpaint1.9/bgrabitmap/bgragtkbitmap.pas(131,38) Error: Identifier not found "TGtkDeviceContext") trying to install Lazpaint.
I've added some directive on subversion. In fact it should be TGtk2DeviceContext. I guess it's because it's using gtk2 unit, instead of gtk.

I've also noticed the following problems on Gtk2 :
- customized cursors make the program crash
- TopMost windows do not stay on top

So better include it in a range check disable directive:
Code: [Select]
{$PUSH}{$R-}
  result.red := color;
  result.green := color shr 8;
  result.blue := color shr 16;
  result.alpha := 255;
{$POP}
Thanks. It's updated.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #87 on: February 21, 2011, 09:27:13 pm »
I've uploaded a new version (2.0) with
- Gtk2DeviceContext fix
- mouseloop for ubuntu in colorcircle (to avoid mouse latency)
- ask for saving current file if changed
- about box
- recent files menu
- better multifile handling
- sine gradients

https://sourceforge.net/projects/lazpaint/files/lazpaint/

Despite the Gtk2 fix, the two following problems are not solved :
- customized cursors make the program crash on ubuntu
- TopMost windows do not stay on top on ubuntu

Anyone has an idea to solve this?

On subversion, I've added an external clipboard. It seems to work on Windows, but I do not know if it works on Linux Gtk1, Gtk2 or MacOS.
« Last Edit: February 22, 2011, 02:50:40 am by circular »
Conscience is the debugger of the mind

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 251
    • Fresh sound.
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #88 on: February 22, 2011, 06:04:48 am »
Hoi circular,

your progress on LazPaint is incredible! Does your day have more than 24 hours?

I downloaded the sources but it did not compile anymore.
I am using Lazarus Lazarus 0.9.31 r29638 FPC 2.4.3 i386-win32-win32/win64

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.
Linux Mint 19.1, Lazarus 2.0, Windows 7&10, Delphi 7, Delphi 10.3 Rio

garlar27

  • Hero Member
  • *****
  • Posts: 649
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #89 on: February 22, 2011, 05:25:20 pm »
Look here Clipbrd, may be you'll find something useful.

I used the clipboard for text and images (long time ago, and only for the whole image). What I remember is that you need to register de format you are putting on the ClipBoard as long as de image. Let me take a look and in a couple of days I might bring you some small example (I thought there was one in the wiki but I Could'nt find it).

 

TinyPortal © 2005-2018