Recent

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

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #615 on: August 10, 2014, 10:42:22 pm »
Ok so here is a version 6.2 with:
- fix for access violation with circle selection
- fix for big font with phong crashes
- fix for font size in labels toolbar
- fix for about box too small horizontally

Linux fixes:
- fix for popup message, not all letters were shown
- fix for cursor not updated outside image zone
- fix for colors>curve crashes
- fix for shift colors bar clipped
- fix for semaphore init failed in threaded filter

Source:
http://sourceforge.net/projects/lazpaint/files/src/lazpaint6.2_src.zip/download

Hopefully this version is ok.
Conscience is the debugger of the mind


zehess

  • New Member
  • *
  • Posts: 12
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #617 on: August 14, 2014, 08:08:01 pm »
Hi,
I have problems to open lzp/ora files. Following message appears:
-The file format has not been regognized
-Can not load file ....
That happens with LazPainz portable and installed versions (6.0 and also 6.2).
No Problems wit jpg,png, gif and pdn files. Running Win8, any ideas?

Thanks CS

EDIT, 19.Aug.14: [solved] after recompiling the win_64bit exe, everything is fixed! Thanks.
« Last Edit: August 19, 2014, 02:36:06 pm by zehess »

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #618 on: August 14, 2014, 10:44:58 pm »
Can you send me a copy of a file you cannot open?
Conscience is the debugger of the mind

CM630

  • Hero Member
  • *****
  • Posts: 1081
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #619 on: August 16, 2014, 08:21:57 pm »
I have attached a patch for LazPaint. Changes description is inside.
Please let me know if there is some problem with it.
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #620 on: August 17, 2014, 10:53:31 pm »
Thank you. I am going to have a look more in details.  8-)
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #621 on: August 19, 2014, 07:23:43 pm »
I have applied the changes, except for:
Quote
2. Save as dialog extension handling improvents. Commented until Settings windows is implemented.

We need to do the following:
- check the extension index from the filter defined for the dialog

It reminds me that we would like to do:
- have the list of formats that can be read
- have the list of formats that can be written
- creating the strings for the opendialogs using the functions that provide different cases for the extensions (however I am not sure anyway that we need to provide really all cases, as basically only the following are encountered "BMP, Bmp and bmp", an extension like "bMp" or "bMP" could safely be ignored)
Conscience is the debugger of the mind

CM630

  • Hero Member
  • *****
  • Posts: 1081
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #622 on: August 19, 2014, 09:21:15 pm »
I have applied the changes, except for:
Quote
2. Save as dialog extension handling improvents. Commented until Settings windows is implemented.

We need to do the following:
- check the extension index from the filter defined for the dialog
 


You mean that if the extension is written manually the app should know to use that extension?
So if the user types image.png, the file will be automatically saved as PNG? Or you mean sth. else?
 


- creating the strings for the opendialogs using the functions that provide different cases for the extensions (however I am not sure anyway that we need to provide really all cases, as basically only the following are encountered "BMP, Bmp and bmp", an extension like "bMp" or "bMP" could safely be ignored)
Well, I have already written this fuction in the imagelist form, it just needs to be moved to a more global unit. It has a shortcomming, that it does not ignore noncaseble chars (numbers, punctations, etc) which I will fix one day but that is not a bug indeed.
 

 an extension like "bMp" or "bMP" could safely be ignored)
 

I seen no benefit from ignoring them.
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #623 on: August 20, 2014, 01:31:23 am »
You mean that if the extension is written manually the app should know to use that extension?
So if the user types image.png, the file will be automatically saved as PNG? Or you mean sth. else?
No, I am talking about computing the index of the extensions by going through the filter string (the Filter property of the TOpenDialog/TSaveDialog). This way we can be sure that the index correspond to the extension. The Filter property need to contain the extension and moreover, the list may be different depending on the dialog box.

Quote
Well, I have already written this fuction in the imagelist form, it just needs to be moved to a more global unit. It has a shortcomming, that it does not ignore noncaseble chars (numbers, punctations, etc) which I will fix one day but that is not a bug indeed.
Yes.

Quote

 an extension like "bMp" or "bMP" could safely be ignored)

I seen no benefit from ignoring them.
Yeah, I don't know if there could be a slow down let's say if we have a directory of thousands of files and each extension having 16 masks (*.abc; *.Abc, etc.). I reckon the beauty of generating all possible cases, but I am not sure it is reasonable. I propose you to go on with the code you wrote, and test it on Linux. I can test it on Puppy Linux and on Linux Mint. For Windows, this is better not to do it because it is not case sensitive. We can do that with a {$IFNDEF WINDOWS}
Conscience is the debugger of the mind

CM630

  • Hero Member
  • *****
  • Posts: 1081
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #624 on: August 20, 2014, 09:53:48 am »
I found out is a huge problem in LazPaint. When an indexed image is open (let's say 1bpp, or strictly black and white it is automatically converted to RGB). And after saving it takes significantly more disk space.
If LazPaint cannot work in other mode than RGB, I suppose that a warning message should be shown, when a non RGB image is open.


No, I am talking about computing the index of the extensions by going through the filter string (the Filter property of the TOpenDialog/TSaveDialog). This way we can be sure that the index correspond to the extension. The Filter property need to contain the extension and moreover, the list may be different depending on the dialog box.
 


I'll take care for that.
Quote
Well, I have already written this fuction in the imagelist form, it just needs to be moved to a more global unit. It has a shortcomming, that it does not ignore noncaseble chars (numbers, punctations, etc) which I will fix one day but that is not a bug indeed.
Yes.

Quote

 an extension like "bMp" or "bMP" could safely be ignored)

I seen no benefit from ignoring them.
Yeah, I don't know if there could be a slow down let's say if we have a directory of thousands of files and each extension having 16 masks (*.abc; *.Abc, etc.). I reckon the beauty of generating all possible cases, but I am not sure it is reasonable. I propose you to go on with the code you wrote, and test it on Linux. I can test it on Puppy Linux and on Linux Mint. For Windows, this is better not to do it because it is not case sensitive. We can do that with a {$IFNDEF WINDOWS}

I will test in on XUBUNTU. Indeed, it should better be skipped in Windows. Actually I was wondering if handling non-caseble extensions would require less or more resources. So you'd better wait until I add this fucntionality before starting tests. Maybe we could ask other people to test in the Linux section. It's a general issue.
EDIT: Actually it is the file system that is case sensitive, not the OS. A FAT32 system mounted on should be case insensitive, which is quite common (USB devices, etc). Respectively an EXT2 FS, mounted on Windows will be case sensitive, which is quite a rare cse, IMHO, so indeed disabling AllExtension on Windows won't cause many problems. Anyway, it's worth testing. If no significant delay occurs, it could stay.

The best solution would be to act according the FAT, but AFAIK a standard dialog won't do that so the world will have to do without it ;)
« Last Edit: August 20, 2014, 12:47:08 pm by paskal »
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #625 on: August 20, 2014, 01:38:05 pm »
I found out is a huge problem in LazPaint. When an indexed image is open (let's say 1bpp, or strictly black and white it is automatically converted to RGB). And after saving it takes significantly more disk space.
If LazPaint cannot work in other mode than RGB, I suppose that a warning message should be shown, when a non RGB image is open.
I understand. We can update the writers to reduce the number of colors in the output file. I can take care of that. What format in particular did you use as an input?

Quote
I will test in on XUBUNTU. Indeed, it should better be skipped in Windows. Actually I was wondering if handling non-caseble extensions would require less or more resources. So you'd better wait until I add this fucntionality before starting tests. Maybe we could ask other people to test in the Linux section. It's a general issue.
EDIT: Actually it is the file system that is case sensitive, not the OS. A FAT32 system mounted on should be case insensitive, which is quite common (USB devices, etc). Respectively an EXT2 FS, mounted on Windows will be case sensitive, which is quite a rare cse, IMHO, so indeed disabling AllExtension on Windows won't cause many problems. Anyway, it's worth testing. If no significant delay occurs, it could stay.
I did not think of that mounting of EXT on Windows. Yes if Windows can take it, it would be better to keep it on this platform too.

Quote
The best solution would be to act according the FAT, but AFAIK a standard dialog won't do that so the world will have to do without it ;)
Oh ok, well, that may be a bit complicated. :D
Conscience is the debugger of the mind

CM630

  • Hero Member
  • *****
  • Posts: 1081
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #626 on: August 20, 2014, 09:54:17 pm »
...If LazPaint cannot work in other mode than RGB, I suppose that a warning message should be shown, when a non RGB image is open.
I understand. We can update the writers to reduce the number of colors in the output file.
 

I thinks it's not that simple. For example, if you open a file with a custom palette of let's say 20 colours, and you open it in RGB mode, care should be taken that only the available indexed colours should be used. Maybe some restricted colour palettes could be used as a beginning. Anyway, probably real indexed mode could take less resources than RGB.
 

I can take care of that. What format in particular did you use as an input?
 


I opened some PNGs. I think JPG does not support indexed colours.
 
... Respectively an EXT2 FS, mounted on Windows will be case sensitive, which is quite a rare cse, IMHO, so indeed disabling AllExtension on Windows won't cause many problems. Anyway, it's worth testing. If no significant delay occurs, it could stay.
I did not think of that mounting of EXT on Windows. Yes if Windows can take it, it would be better to keep it on this platform too.
 
   

It can, with some additional drivers. BTW, the function is ready, I will post it here tomorrow.
 
The best solution would be to act according the FAT, but AFAIK a standard dialog won't do that so the world will have to do without it ;)
Oh ok, well, that may be a bit complicated. :D 


Since you have a custom file opening dialogue, it might not be so complicated, but anyway, time can be used for sth. more useful.
« Last Edit: August 20, 2014, 09:56:48 pm by paskal »
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #627 on: August 20, 2014, 10:24:54 pm »
I thinks it's not that simple. For example, if you open a file with a custom palette of let's say 20 colours, and you open it in RGB mode, care should be taken that only the available indexed colours should be used. Maybe some restricted colour palettes could be used as a beginning.
I understand. It is a bit out of the scope of LazPaint.

Quote
I opened some PNGs. I think JPG does not support indexed colours.
Probably PNG is not automatically used with indexed mode.
Conscience is the debugger of the mind

CM630

  • Hero Member
  • *****
  • Posts: 1081
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #628 on: August 21, 2014, 01:39:15 pm »
I thinks it's not that simple. For example, if you open a file with a custom palette of let's say 20 colours, and you open it in RGB mode, care should be taken that only the available indexed colours should be used. Maybe some restricted colour palettes could be used as a beginning.
I understand. It is a bit out of the scope of LazPaint.

Actually maybe there is a way of reaching some decent result- when indexed colour is used (black and white, grayscale, custom palette), instead of the current colour selection palette a custom one shall be made. But I don't think I could help in this area, at least in the next year.
And here are the allcase functions:
Code: [Select]
...uses ... LazUTF8...
//All case extension subs
//TODO: Extensions containing non-caseable chars will be duplicated
function GetBit(Value: QWord; Index: Byte): Boolean;
begin
  Result := ((Value shr Index) and 1) = 1;
end;

{en Converts aChar to uppercase if aUcase= true. No conversion is done if aUcase= false}
function UCase(aChar: string; aUcase: Boolean): string;
begin
  if aUCase then Result:=UTF8UpperCase(aChar) else Result:=aChar;
end;

{en Checks if a character is caseble}
function IsCaseble(aStr: string): Boolean;
begin
   Result:=not (UTF8LowerCase(aStr)=UTF8UpperCase(aStr));
end;

{en: Generates all possible upper and lowercase combinations of a string.
if HandleNonCaseble= true care is taken not to duplicate strings with no-caseble characters.}
function AllCases (aStr: string; Delimiter: String=';'; Prefix: string=''; Suffix: String=''; HandleNonCaseble: Boolean= True):string;
var
  FWord,FChar:integer;
  LCString: string;
  Len: integer;
  Count: integer;
  LCArray: array of String;
  CExt:string='';
  Cased: Boolean;
  CChar: String;
begin
  Result := '';
  Len:= Length(aStr);
  LCString:=Utf8Copy(UTF8LowerCase(aStr),Length(Prefix)+1, Len-Length(Suffix)-Length(Prefix));
  Len:=Length(LCString);
  Count:=(1 shl len) - 1;
  SetLength(LCArray,Len);
  for FWord:=0 to Len -1 do
     LCArray[FWord]:=Utf8Copy (LCString,FWord+1,1);
  if HandleNonCaseble then
  begin
     for FWord:=0 to Count do
       begin
         CExt:='';
         Cased:=True;
         for FChar:=0 to Len-1 do
           begin
             CChar:=LCArray[FChar];
                if IsCaseble(CChar)
                 then CExt:=CExt+ UCase (CChar,GetBit(FWord,FChar))
                 else if not GetBit(FWord,FChar)
                    then CExt:=CExt+ UCase (CChar,GetBit(FWord,FChar))
                    else
                      begin
                         CExt:=''; Cased:= False; Break; end;
             end; //for FChar
            if Cased then
            begin
               Result:= Result+ Prefix+ CExt + Suffix + Delimiter;
            end;  //if
         end; //for FWord
      end  //if HandleNonCaseble
     else
      for FWord:=0 to Count do
      begin
        Result:=Result + Prefix;
        for FChar:=0 to Len-1 do
         begin
           Result:=Result+ UCase (LCArray[FChar],GetBit(FWord,FChar));
         end;
      Result:=Result + Suffix + Delimiter;
      end;
      Result:= LeftStr(Result, Length(Result)-1);  //Remove last Delimiter;
end;

function ExtensionAllCase (AllExtensions: String; HandleNonCaseble: Boolean= True): String;
var
  ExtList: TStringList;
  i: integer;
begin
  Result := '';
  ExtList:= TStringList.Create;
  ExtList.Delimiter:=';';
  ExtList.DelimitedText:=AllExtensions;
  for i:=0 to ExtList.Count -1 do
    Result:= Result + AllCases(ExtList[i],';','*.','',HandleNonCaseble);
  ExtList.Free;
end;
//end All case extension subs
 
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #629 on: August 23, 2014, 02:10:56 pm »
Actually maybe there is a way of reaching some decent result- when indexed colour is used (black and white, grayscale, custom palette), instead of the current colour selection palette a custom one shall be made.
It is not so simple because the colors are merged with antialiasing and all. So it is not only about selecting the color in the palette.

Thanks for the function. I will add a unit.

About the save dialog, I discovered a bug on Linux Mint. Basically on my computer the "save as" dialog crashes the application. The reason is unknown, maybe related to having a mix of NTFS and EXT drives.

I am thinking of using the browse dialog for both opening and saving files. And use the filter strings with it.
« Last Edit: August 23, 2014, 02:16:15 pm by circular »
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018