Author |
Topic |
|
sxbug
14 Posts |
Posted - Oct 08 2023 : 20:30:58
|
Hi sir I want to copy the image by clicking on the image control,
Clipboard.Assign(Image3.Picture);
and then paste the image onto a new layer in ImageEnView by clicking on ImageENView, with the background transparent.
ImageEnView1.LayersAdd; //(ielkImage); ImageEnView1.LayersCreateFromSelection; ImageEnView1.CurrentLayer.SetDefaults;
ImageEnView1.Layers[ImageEnView1.LayersCurrent].Bitmap.fill (clWhite); //It is too big size of layer
ImageEnView1.Proc.PointPasteFromClip(X-2, Y-2,True); ImageEnView1.Proc.SetTransparentColors(CreateRGB(250, 250, 250), CreateRGB(255,255, 255), 0); ImageEnView1.Update();
How can I achieve this? thanks |
|
xequte
38610 Posts |
Posted - Oct 09 2023 : 16:58:21
|
Hi
I don't tend to use VCL objects, like TImage and TPicture, but I am almost certain that transparency would not be supported if you called Clipboard.Assign(Image3.Picture);
Transparency in clipboard operations is not a standard part of Windows. It requires passing a PNG object internally. This is a "non-standard standard" that is widely used by editing applications that have alpha support, like PhotoShop, etc.
If your question is only how to maintain the transparency when moving an object from TImage to a TImageEnView layer then that would depend on the way the transparency has been assigned in the TImage. I would need more information on that to comment, e.g. was a an image loaded from file? What type of the image? If it was loaded from a 32bit bitmap file, what is the value of TBitmap.Alphaformat?
Ideally you would avoid using VCL objects completely and do everything with ImageEn which will make alpha support much simpler.
Nigel Xequte Software www.imageen.com
|
|
|
sxbug
14 Posts |
Posted - Oct 10 2023 : 00:10:11
|
Firstly, thank you for your reply.
I have displayed a png file in the wallpaper of imageEnView2, and I want to copy this image with a transparent background by clicking on this control.
Then click imageEnView1 to paste this image onto a new layer. How can I achieve this? thanks |
|
|
sxbug
14 Posts |
Posted - Oct 10 2023 : 01:20:27
|
mypic:tiebitmap;
procedure Tfmain.ImageEnView2Click(Sender: TObject); begin ImageEnView2.CopySelectionToIEBitmap(mypic, false); end;
procedure ImageEnView1MouseDown ImageEnView1.EnableAlphaChannel := True; ImageEnView1.IEBitmap.AlphaChannel.Location := ietbitmap; ImageEnView1.IO.Params.Bmp_HandleTransparency := True; ImageEnView1.LayersCreateFromClipboard(); // nothing happen :(
Why? Thanks
|
|
|
xequte
38610 Posts |
|
sxbug
14 Posts |
Posted - Oct 10 2023 : 18:57:34
|
Hi I have tried ImageEnView2.Proc.CopyToClipboard( iecpSelection ); and changed parameter#12290;it could not copy wallpaper anyway.Why? I want copy ImageEnView2'picture to ImageEnView1 's new layer and move this picture to click point. I always can't achieve it, please advise me Thanks
sxbug |
|
|
xequte
38610 Posts |
Posted - Oct 10 2023 : 21:44:21
|
Sorry, I'm not following. Do you want to copy the background of the control (the area of the TImageEnView behind the image)?
Perhaps you can attach a screenshot to explain what you mean.
Nigel Xequte Software www.imageen.com
|
|
|
sxbug
14 Posts |
Posted - Oct 11 2023 : 00:08:29
|
I want to copy imageEnView's backgroup to clipbroad, and paste image to imageEnView .
|
|
|
xequte
38610 Posts |
Posted - Oct 11 2023 : 22:22:22
|
But why copy the background?
Why not just load the content directly from the PNG file?
ImageEnView1.LayersAdd( 'D:\MyImage.png', 300, 200 );
Or if must use the wallpaper from another TImageEnView, you could use:
ImageEnView1.LayersAdd( ielkImage, 100, 100, 200, 200 ); TIEImageLayer( ImageEnView1.CurrentLayer ).Bitmap.Assign( ImageEnView2.Wallpaper ); ImageEnView1.Update();
Nigel Xequte Software www.imageen.com
|
|
|
xequte
38610 Posts |
Posted - Oct 11 2023 : 22:27:20
|
Here's an example that inserts the image wherever you click on the control:
procedure Tfmain.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
mx, my: Integer;
begin
mx := ImageEnView1.XScr2Bmp( x );
my := ImageEnView1.XScr2Bmp( y );
ImageEnView1.LayersAdd( ielkImage, mx, my, 200, 200 );
TIEImageLayer( ImageEnView1.CurrentLayer ).Bitmap.Assign( ImageEnView2.Wallpaper );
TIEImageLayer( ImageEnView1.CurrentLayer ).RestoreAspectRatio();
ImageEnView1.Update();
end;
Nigel Xequte Software www.imageen.com
|
|
|
sxbug
14 Posts |
Posted - Oct 12 2023 : 09:39:21
|
That's Great.Thanks |
|
|
|
Topic |
|