ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Try to make a feathered 8 bits selection
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

nwscomps

185 Posts

Posted - Oct 04 2018 :  08:22:51  Show Profile  Reply
This is the code I use, however the result is a selection that is 8 bits but is ignored applying filters from TImageenproc.

In attachment please find a demo project

procedure TForm1.Button3Click(Sender: TObject);
var
  myProc:TImageenproc;
  maskBmp:TIEBitmap;
  J: Integer;
  p, psel: pByte;
  I: Integer;
begin
  myProc := TImageEnProc.Create(nil);
  maskBmp := TIEBitmap.Create;
  try
    maskbmp.PixelFormat := ie8g;
    maskBmp.Width := imageenview1.SelectionMask.Width;
    maskBmp.Height := imageenview1.SelectionMask.Height;
    for J := 0 to maskBmp.Height-1 do
    begin
      p := maskbmp.ScanLine[j];
      psel := imageenview1.SelectionMask.ScanLine[j];
      case imageenview1.SelectionMask.BitsPerPixel of
        1:
        begin
          for I := 0 to maskBmp.Width-1 do
          begin
            p^ := (pbytearray(pSel)^[i shr 3] and iebitmask1[i and $7])*255;

            inc(p);
          end;
        end
        else //8 bits
        begin
          for I := 0 to maskBmp.Width-1 do
          begin
            p^ := psel^;

            inc(p);
            inc(psel);
          end;
        end;
      end;
    end;

  myproc.AttachedIEBitmap := maskbmp;
  myproc.Blur(15); //apply feather

 // maskbmp.Write('C:\Users\nwsco\Documents\DXE2_Projects\ImgProc\test.bmp');
 
 maskbmp.CopyToTIEMask(imageenview1.SelectionMask);
 // imageenview1.SelectionMask.Assign(maskbmp);  //I have tried this too but the selection becomes 1 bit again

  showmessage(inttostr(imageenview1.SelectionMask.BitsPerPixel)+' bits per pixel'); //Bits per pixels is 8

  finally
    myproc.Free;
    maskBmp.Free;
  end;

end;

attach/nwscomps/201810481947_Feather selection.zip
86.5 KB

Francesco Savastano
Add-ons for the ImageEn Library
web: http://www.fssoft.it/delphicomps.html

nwscomps

185 Posts

Posted - Oct 05 2018 :  05:09:20  Show Profile  Reply
Any hint on this, yet? I think creating 8 bits selection could be a nice feature for imageEn. Please if my code is wrong tell me, thanks in advance

Francesco Savastano
Add-ons for the ImageEn Library
web: http://www.fssoft.it/delphicomps.html
Go to Top of Page

xequte

38198 Posts

Posted - Oct 06 2018 :  01:20:19  Show Profile  Reply
Sorry Francesco

I won't be able to look at this till after the weekend.

Have you set ImageEnView1.SelectionMaskDepth?

https://www.imageen.com/help/TImageEnView.SelectionMaskDepth.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

nwscomps

185 Posts

Posted - Oct 06 2018 :  03:20:40  Show Profile  Reply
Hi Nigel,
setting imageenview1.SelectionMaskDepth := 8;
will clear the selection either before assigning my mask or after.

Francesco Savastano
Add-ons for the ImageEn Library
web: http://www.fssoft.it/delphicomps.html
Go to Top of Page

nwscomps

185 Posts

Posted - Oct 06 2018 :  03:24:07  Show Profile  Reply
ok I found this combination works (but still the selection borders are not visible:

imageenview1.SelectionMaskDepth := 8;
imageenview1.SelectionMask.Assign(maskbmp);

Is it possible to make the selection border visible after this?


Francesco Savastano
Add-ons for the ImageEn Library
web: http://www.fssoft.it/delphicomps.html
Go to Top of Page

nwscomps

185 Posts

Posted - Oct 06 2018 :  04:04:11  Show Profile  Reply
Calling ImageenView1.update solves the problem of the borders not showing

Francesco Savastano
Add-ons for the ImageEn Library
web: http://www.fssoft.it/delphicomps.html
Go to Top of Page

nwscomps

185 Posts

Posted - Oct 06 2018 :  04:25:55  Show Profile  Reply
I correct myself:
Imageenview1.VisibleSelection := true;
solves the problem of the borders not showing

Francesco Savastano
Add-ons for the ImageEn Library
web: http://www.fssoft.it/delphicomps.html
Go to Top of Page

nwscomps

185 Posts

Posted - Oct 06 2018 :  05:09:40  Show Profile  Reply
I have another problem.
After:
Imageenview1.SelectionMaskDepth := 8;
Imageenview1.SelectionMask.Assign(maskbmp);
Imageenview1.VisibleSelection := true;

the property Imageenview1.Selected remains false. This I think is a bug.

Francesco Savastano
Add-ons for the ImageEn Library
web: http://www.fssoft.it/delphicomps.html
Go to Top of Page

xequte

38198 Posts

Posted - Oct 07 2018 :  15:04:52  Show Profile  Reply
Hi Francesco

> the property Imageenview1.Selected remains false.

Ensure you are are using 8.1.1.


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

nwscomps

185 Posts

Posted - Oct 08 2018 :  02:23:07  Show Profile  Reply
Hi Nigel, yes I am using 8.1.1

Francesco Savastano
Add-ons for the ImageEn Library
web: http://www.fssoft.it/delphicomps.html
Go to Top of Page

xequte

38198 Posts

Posted - Oct 09 2018 :  01:37:43  Show Profile  Reply
Oh, after assigning SelectionMask you need to call:

ImageEnView1.SelectCustom();

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: