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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 paste a bmp into an object and adjust its opacity

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
zhengyuanyi27 Posted - Sep 15 2020 : 04:12:48
Dear all,
Is it possible to paste a bitmap into a selection ROI and adjust its opacity? I think it should use layer, but I don't know how to realize it. Thanks a lot!
Such as:
imageenvect1.Proc.CopyToClipboard(iecpauto) ;
ImageEnVect3.Proc.PasteFromClipboard(iecpSelection);
ImageEnVect3.Layers[layerscurrent].Opacity := 10;
imageenvect3.Update;


7   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Sep 27 2020 : 16:08:08
Excellent

Nigel
Xequte Software
www.imageen.com
zhengyuanyi27 Posted - Sep 26 2020 : 03:15:51
Hi Nigel,
Thanks a lot.
It works!!!
I set the color transparent "imageenvect.Proc.SetTransparentColors( clBlack, clBlack, 0 );
And then copy it and paste it into the ROI.

All the best,
Yuanyi
xequte Posted - Sep 24 2020 : 18:46:58
OK, I don't see where you use BMP. But to use transparency in ImageEn you need to enable use the Alpha Channel of TIEBitmap (the alpha channel is basically a gray scale bitmap, where white is opaque, black is transparent and gray is semi-transparent)



https://www.imageen.com/help/TIEBitmap.AlphaChannel.html


If you are bringing in a pf32bit bitmap into ImageEn then you need to convert the bitmap A channel to ImageEn's Alpha Channel using SynchronizeRGBA

https://www.imageen.com/help/TIEBitmap.SynchronizeRGBA.html

e.g.

  ImageEnView1.IEBitmap.Assign( bmp );
  ImageEnView1.IEBitmap.SynchronizeRGBA( true );
  ImageEnView1.Update();



If you have a TIEBitmap and just want to set all the black pixels as transparent just use SetTransparentColors:

https://www.imageen.com/help/TIEBitmap.SetTransparentColors.html


e.g.

MyBMP.SetTransparentColors( clBlack, clBlack, 0 );



Nigel
Xequte Software
www.imageen.com
zhengyuanyi27 Posted - Sep 24 2020 : 12:52:36
Dear Nigel,
Thanks.
I want to paste an bmp into the ROI selection region in an imageenvect, and the clblack pixels in the bmp should be transparent after being pasted into the roi region of imageenvect.

Thanks.

The following are the codes. It seems the pasted bmp is not transparent. The black pixels are still there.


procedure TplayAVI.ToolButton16Click(Sender: TObject);
var
    i,   j,   uG:   Integer;
    P:   PByteArray;
    bggray: integer;
    bmp:Tbitmap;
    layerno:integer;
begin
          ImageEnvect3.IEBitmap.Assign(imageenvect0.ieBitmap);
          imageenvect3.Update;

          IDSImageEnvect.Bitmap.Assign(imageenvect0.Bitmap);
          IDSimageenvect.Update;

          GrayToColor(IDSimageenvect.Bitmap);  //This procedure will turn the gray image into color image.
          IDSimageenvect.Proc.CopyToClipboard(iecpauto)  ;  //This will copy an ROI to the clipboard.

 //-------create bmp and get rid of the given pixels such as clblack pixels.
          bmp:=Tbitmap.Create;
          bmp.Assign(clipboard);
          bggray:= strtoint(backgroundgrayedit.Text) ;
          for   j   :=   0   to   Bmp.Height   -   1   do
          begin
                 P   :=   Bmp.ScanLine[j];
                for   i   :=   0   to   Bmp.Width   -   1   do
                begin
                      uG   :=   P[3   *   i];
                      if   ug< bggray then   //set the pixels to be clblack.
                      begin
                           P[3   *   i   +   2]   :=   0;
                           P[3   *   i   +   1]   :=   0;
                           P[3   *   i]   :=   0;
                     end;
                 end;
           end;
              Bmp.PixelFormat   :=   pf32bit;
              Bmp.TransparentColor:=clblack;   //set the black pixels in bmp to be transparent
              Bmp.Free;
  
              ImageEnVect3.Proc.PasteFromClipboard(iecpSelection);    //Paste the bmp file into the ROI in Imageenvect3.
              imageenvect3.Update;
end;
xequte Posted - Sep 24 2020 : 05:55:45
Hi

So you are copying from an image that has alpha (background transparency) like ICO or PNG, and you want to paste it as a new layer (supporting the alpha).

Is that correct?

Nigel
Xequte Software
www.imageen.com
zhengyuanyi27 Posted - Sep 24 2020 : 03:28:52
Thanks, Nigel!
I am Sorry. I made a mistake. I found what I really want is to paste the bmp with transparent background like ICO, NOT opacity.
I tried to set bitmap.transparentcolor:=clblack; (I want
to set the black color as transparent color. )
It doesn't work.
Could you please tell me how to make It work? Thanks a lot.
xequte Posted - Sep 15 2020 : 22:52:18
Hi

Please use LayersCreateFromClipboard:

ImageEnView1.Proc.CopyToClipboard(iecpAuto);
idx := ImageEnView2.Proc.LayersCreateFromClipboard();
ImageEnView2.Layers[idx].Opacity := 10;
ImageEnView2.Update();

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

Nigel
Xequte Software
www.imageen.com