ImageGear for Java
blendWithAlpha Method
Page to blend with .
Left margin of blended image.
Top margin of blended image.
Second page.

This method blends page2 over page1 and stores result in page1.

Page2 should contain an Alpha channel, otherwise, an error is returned.

If page1 does not contain an Alpha channel, page2 is composited over it using page1 as the background. The resulting image does not contain an Alpha channel. The following formulas are used:

If page2 is not pre-multiplied,

I1 = I2 * A2 + I1 (1-A2)

If page2 is pre-multiplied,

I1 = I2 + I1 (1-A2)

If page2 contains an Alpha channel, page1 and page2 are blended together. The resulting image contains an alpha channel. Blending two images, both of which contain an Alpha channel, can be interpreted as placing one semi-transparent film over another semi-transparent film. The result of applying such combined images to some background is the same as applying one image over background and then applying another image to the result. Using pseudocode,

BlendWithAlpha(page1, page2) BlendWithAlpha(BackPage, page1)

produces the same result as

BlendWithAlpha(BackPage, page1) BlendWithAlpha(BackPage, page2)

The following formulas are used:

if (A1=A2=0)

I1 = 0; A1 = 0;

else

If both page1 and page2 are not pre-multiplied,

I1 = (I2*A2 + I1*A1*(1-A2)) / (A1 + A2 - A1*A2)

A1 = A1 + A2 - A1*A2

Result is not pre-multiplied

If page1 is not pre-multiplied, and page2 is pre-multiplied:

I1 = (I2 + I1*A1*(1-A2)) / (A1 + A2 - A1*A2)

A1 = A1 + A2 - A1*A2

Result is not pre-multiplied

If page1 is pre-multiplied, and page2 is not:

I1 = I2*A2 + I1*(1-A2)

A1 = A1 + A2 - A1*A2

Result is pre-multiplied

If both page1 and page2 are pre-multiplied:

I1 = I2 + I1*(1-A2)

A1 = A1 + A2 - A1*A2

Result is pre-multiplied

Alpha values are mapped to a float value between 0.0 and 1.0, where 0.0 means full transparency and 1.0 means full opaquity. Alpha value of 0 corresponds to float value of 0.0 and alpha value of 2^n-1 (where n is alpha channel's bit depth) corresponds to float value of 1.0. Any ChannelDepths are allowed for color channels.

This method does not process Extra Channels.

blend(ImGearRasterPage,int,int,ImGearRasterPage,double)com.accusoft.imagegear.core.ImGearRasterPage

Blends two images with alpha.
Syntax
public static void blendWithAlpha( 
   ImGearRasterPage page1,
   int left,
   int top,
   ImGearRasterPage page2
)

Parameters

page1
Page to blend with .
left
Left margin of blended image.
top
Top margin of blended image.
page2
Second page.

This method blends page2 over page1 and stores result in page1.

Page2 should contain an Alpha channel, otherwise, an error is returned.

If page1 does not contain an Alpha channel, page2 is composited over it using page1 as the background. The resulting image does not contain an Alpha channel. The following formulas are used:

If page2 is not pre-multiplied,

I1 = I2 * A2 + I1 (1-A2)

If page2 is pre-multiplied,

I1 = I2 + I1 (1-A2)

If page2 contains an Alpha channel, page1 and page2 are blended together. The resulting image contains an alpha channel. Blending two images, both of which contain an Alpha channel, can be interpreted as placing one semi-transparent film over another semi-transparent film. The result of applying such combined images to some background is the same as applying one image over background and then applying another image to the result. Using pseudocode,

BlendWithAlpha(page1, page2) BlendWithAlpha(BackPage, page1)

produces the same result as

BlendWithAlpha(BackPage, page1) BlendWithAlpha(BackPage, page2)

The following formulas are used:

if (A1=A2=0)

I1 = 0; A1 = 0;

else

If both page1 and page2 are not pre-multiplied,

I1 = (I2*A2 + I1*A1*(1-A2)) / (A1 + A2 - A1*A2)

A1 = A1 + A2 - A1*A2

Result is not pre-multiplied

If page1 is not pre-multiplied, and page2 is pre-multiplied:

I1 = (I2 + I1*A1*(1-A2)) / (A1 + A2 - A1*A2)

A1 = A1 + A2 - A1*A2

Result is not pre-multiplied

If page1 is pre-multiplied, and page2 is not:

I1 = I2*A2 + I1*(1-A2)

A1 = A1 + A2 - A1*A2

Result is pre-multiplied

If both page1 and page2 are pre-multiplied:

I1 = I2 + I1*(1-A2)

A1 = A1 + A2 - A1*A2

Result is pre-multiplied

Alpha values are mapped to a float value between 0.0 and 1.0, where 0.0 means full transparency and 1.0 means full opaquity. Alpha value of 0 corresponds to float value of 0.0 and alpha value of 2^n-1 (where n is alpha channel's bit depth) corresponds to float value of 1.0. Any ChannelDepths are allowed for color channels.

This method does not process Extra Channels.

blend(ImGearRasterPage,int,int,ImGearRasterPage,double)com.accusoft.imagegear.core.ImGearRasterPage

See Also

Reference

ImGearRasterProcessing Class
ImGearRasterProcessing Members

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback