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
 How to split one IEBitmap into two IEBitmaps
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

mmehlfeldt

Germany
4 Posts

Posted - Jul 09 2015 :  09:22:12  Show Profile  Reply
Hi,

I am looking for a performant way to split one IEBitmap into two IEBitmaps using a Mask/AlphaChannel and a negative of the Mask/AlphaChannel:
AImageEnVectMaskP.IEBitmap.Width := ASourceImage.Width;
AImageEnVectMaskP.IEBitmap.Height := ASourceImage.Height; 
AImageEnVectMaskP.Proc.Random(0.8, 0.1);
AImageEnVectMaskP.Proc.ConvertToBWOrdered;
AImageEnVectMaskP.IEBitmap.PixelFormat := ie1g;

AImageEnVectMaskN.IEBitmap.Width := AImageEnVectMaskP.IEBitmap.Width;
AImageEnVectMaskN.IEBitmap.Height := AImageEnVectMaskP.IEBitmap.Height;
AImageEnVectMaskN.IEBitmap.AssignImage(AImageEnVectMaskP.IEBitmap);
AImageEnVectMaskN.Proc.Negative;
 
{
???
ASourceImage --> ADestImageP (only pixels using positive mask)
             --> ADestImageN (only pixels using negative mask)
}


Please help me, I cant't find the the matching methods :-(

Thanks in advance,
Marc

xequte

38514 Posts

Posted - Jul 09 2015 :  17:11:15  Show Profile  Reply
Hi Marc

IEBitmap offers a CopyToTIEMask method that will accept your 1bit image.

Likewise if you assign an IEBitmap to an alpha channel. For a 1bit image the black pixels will be fully opaque and the white ones fully transparent.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

mmehlfeldt

Germany
4 Posts

Posted - Jul 21 2015 :  09:31:51  Show Profile  Reply
Hi Nigel,

thanks a lot for your help. Unfortunately I cannot find the right methods for a solution. The source files are Windows BMP with 4 colors (4 BPP). The merging of the assigned 1 bit alpha channels to the source file have not the result I need. I suppose because of wrong pixel formats?

Attached you will find a zipped pdf showing what I want to do in the Photoshop way.

Please tell me the fast way using ImageEN :)

attach/mmehlfeldt/201572193133_Merging1bitAlphaChannelsTo4BppImage.zip
129.37 KB
Go to Top of Page

xequte

38514 Posts

Posted - Jul 23 2015 :  05:52:11  Show Profile  Reply
Hi

Sorry I'm not entirely following your requirements, but essentially ImageEn supports both 1bit and 8bit masks, so you should have no trouble assigning an image to a mask (or creating one randomly by setting myIEMask.SetPixel() for example). To get a negative you can assign it to a another TIEMask and then call myIEMask.Negative().

If that is not what you are looking for, please explain in what way it is failing.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

mmehlfeldt

Germany
4 Posts

Posted - Jul 28 2015 :  09:47:13  Show Profile  Reply
Still strange results when applying a 1 bpp ieBitmap as alpha channel to a 4 bpp ieBitmap


Hi Nigel,

i still have some problems finding the right methods to apply a alpha channel to a bitmap. The alpha channel image loaded as ieBitmap from file is shown perfect. But after assigning it to an alpha channel of another image (same dimensions) the alpha channel seems to be rotated and recalculated and is now grayscale instead of black/white.
Please send me a short example code to show me how things work. Thank you!

Kind regards, Marc
Go to Top of Page

xequte

38514 Posts

Posted - Aug 05 2015 :  00:32:29  Show Profile  Reply
Hi Marc

Here is an example of setting the alpha channel using a source bitmap:

// Assign an alpha channel to an image using a source file (which is a monochrome bitmap where the black pixels will become transparent)

aBMP := TIEBitmap.create( 'D:\alpha.bmp' );

// Range of values in image must be 0 to 255
aBMP.PixelFormat := ie8g;

// Size of alpha channel must match size of image
aBMP.Resample( ImageEnView1.IEBitmap.Width, ImageEnView1.IEBitmap.Height );

// Use our bitmap as the alpha channel
ImageEnView1.IEBitmap.AlphaChannel.Assign( aBMP );

// Advise that the Alpha channel has value range
ImageEnView1.IEBitmap.AlphaChannel.Full := False;

// Update the container
ImageEnView1.Update;

aBMP.free;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

mmehlfeldt

Germany
4 Posts

Posted - Aug 11 2015 :  01:30:36  Show Profile  Reply
Hello Nigel,

it works well now, thank you!

Kind regards,
Marc
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: