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
 Problem with alpha after clipboard exchange
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

BionicWave

Germany
33 Posts

Posted - Jul 28 2011 :  09:41:00  Show Profile  Reply
When i paste an image via img.proc.selpastefromclip i have a problem with transparent pixels.
i want to overwrite all pixels in a square of 64x64 with the ones from the clipboard. For that to happen i have to clear all the pixels in the square before using the selpastefromclip-function.

I tried clearsel with clNone as background-color, but it doesnt work.
How do i make the square completely transparent?

thanks in advance

w2m

USA
1990 Posts

Posted - Jul 28 2011 :  13:27:58  Show Profile  Reply
When I paste to a 32-bit image with alphachannel it maintains the alpha channel.

Make sure that:
1. ImageENView.IEBitmap.AlphaChannel.Location := ietbitmap;
2. ImageENView.EnableAlphaChannel := True;
3. ImageENView.IO.Params.Bmp_HandleTransparency := True;

are set and you open an image that supports an alphachannel like png or a 32-bit bitmap. Images without an alphachannel will not have transparency.

If that does not work post the results and we can work on it.



William Miller
Go to Top of Page

BionicWave

Germany
33 Posts

Posted - Jul 29 2011 :  03:34:47  Show Profile  Reply
Im sorry, i tried the parameters, but nothing changed.
I think the problem is that i can not clear out the selected area of the file.

I need to erase the selected area with clear pixels.
Is there a way to do this with TImageEn?
Go to Top of Page

BionicWave

Germany
33 Posts

Posted - Jul 29 2011 :  05:06:00  Show Profile  Reply
I think i found it.
To delete the pixels i set the Alpha of all pixels in the current selection to Zero.
Seems to do the trick.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Jul 29 2011 :  05:25:02  Show Profile  Reply
procedure TForm1.FormCreate( Sender: TObject );
begin
  ImageEnView1.EnableAlphaChannel := True;
  ImageEnView2.EnableAlphaChannel := True;
  ImageEnView1.IEBitmap.AlphaChannel.Location := ietbitmap;
  ImageEnView1.EnableAlphaChannel := True;
  ImageEnView1.IO.Params.Bmp_HandleTransparency := True;
  ImageEnView2.IEBitmap.AlphaChannel.Location := ietbitmap;
  ImageEnView2.EnableAlphaChannel := True;
  ImageEnView2.IO.Params.Bmp_HandleTransparency := True;
end;

procedure TForm1.Button1Click( Sender: TObject );
begin
  // paste to the clipboard
  ImageEnView1.Proc.SelCopyToClip;
  // if clipboard contains data valid for TImageEnProc
  if ImageEnView2.Proc.IsClipboardAvailable then
  begin
    // assuming X,Y = mouse coordinates, makes all colors the area transparent
    // tolerance specifies the maximum difference from the starting pixel
    ImageEnView2.Proc.CastAlpha( ImageEnView2.SelX1 + 1, ImageEnView2.SelY1 + 1, 0, 15 );
    // paste the contents of the Clipboard inside the ImageEnView2 selected area
    ImageEnView2.Proc.SelPasteFromClip( );
    ImageEnView2.Update;
  end;
end;


If this does not work are you positive that both images are 32-bit?
Is:
ImageEnView1.IO.Params.BitsPerSample = 8;
ImageEnView1.IO.Params.SamplesPerPixel = 4;
ImageEnView2.IO.Params.BitsPerSample = 8;
ImageEnView2.IO.Params.SamplesPerPixel = 4;


William Miller
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: