Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

the documentation states to leave p2 as NULL when using AEE_RO_BLEND in IImage_SetParm. How then do I specify the actual alpha for the transparency? If I want something to be 30% opaque, normally I would set the alpha to 30. Here I don't see any way to do this.
Am I missing something obvious?

thanks in advance

Up to That time alpha channel is not supported by Brew API
Widget has it because internally they implementing it.
You may also implement it by doing this.
1. Get IBitmap * of Two Image Which you want to Bland they are Image1
& Image2. where Image1 is Base Image in which Image2 is Bland.
2. Use CONVERTBMP to Convert it in native format.
3. repeat step 4,5,6,7 for all pixel of Image1
4. get image pixel’s of Both Image’s p1 & p2
5. extracted its RGB value from native format
[
Device color depth:
The number of bits taken by the device to store the color value of one pixel is termed as the device color depth of the device. There are devices having color depth as 18 bit, 16 bit, 12 bit, 8bit.
RGB format of device:
RGB format specifies the number of bits used to represent the intensity of colors.
a) 18 bit device:
For 18 bit device the RGB format is 6 6 6. It does indicate that 6 bits (out of 18) are used to represent the Red color intensity similarly 6 for Green and last 6 for Blue color. In actual, to store one color value, memory consumption is not 18 bits, but is 4 byte (32 bits). The first 14 bits (32-18) are set to zero and they have no meaning. E.g. RGB of Red color is 255, 0, 0 in windows format. Now we have 4 bytes to store this color value in memory. As device is 18 bit device with format 6 6 6, the color value would be as 00000000 000000 11 1111 0000 00 000000
Unused 14 bits 6 bits for Red 6 bits for Green 6 bits for Blue
b) 16 bit device:
For 16 bit device the RGB format is 5 6 5. It means that 5 bits are used to represent the Red color intensity, 6 bits are used to represent the green color intensity and the last 5 bits are used for Blue color intensity. For 16 bit device 2 bytes required to store a color value of any pixel.
c) 12 bit device:
For 12 bit device the RGB format is 4 4 4. It means that 4 bits are used to represent the Red color intensity, 4 bits are used to represent the green color intensity and the last 4 bits are used for Blue color intensity. For 12 bit device 2 bytes are required to store the color value of one pixel.
d) 8 bit device:
For 8 bit device the RGB format is 3 2 3. It means that 3 bits are used to represent the Red color intensity, 2 bits are used to represent the green color intensity and the last 3 bits are used for Blue color intensity. For 8 bit device 1 byte is required to store the color value of one pixel.
]
in this Let Device Color Depth is 16
use
typedef union mynative
{
uint16 color;
struct{
uint16 B:5;
uint16 G:6;
uint16 R:5;
}stct;
myN;
for this color is Native Color value.
ex. ->
myN.color = p1;
assigned in this Union then
stct. B stct. G stct. R is the RGB Value which you want.]
6. Calculate newR , newG, newB values
by Appling this formula
NewR = (R1+ opacity*(R2-R1) );
NewG = (G1+ opacity*(G2-G1) );
NewB = (B1+ opacity*(B2-B1) );
Where
Opacity = 0 to 1. [0 for full Transparency]
Ex-> Opacity= 0.25 .0.50 etc.
R1 = R Value of Native Color of p1
R2 = R Value of Native Color of p2
Similarly G1,G2 & B1,B2
7.
noe again use
typedef union mynative
{
uint16 color;
struct{
uint16 B:5;
uint16 G:6;
uint16 R:5;
}stct;
myN;
this union to reassembled the RGB values of Native color
value
by doing this
myN.stct.R = newR;
myN.stct.G = newG;
myN.stct.B = newB;
now
myN. Color is the Native Color Value of new Bland Pixel
Now use IBITMAP_SetPixels() to Display it on Image1 for Display.
:)

Up to That time alpha channel is not supported by Brew API
Widget has it because internally they implementing it.
You may also implement it by doing this.
1. Get IBitmap * of Two Image Which you want to Bland they are Image1
& Image2. where Image1 is Base Image in which Image2 is Bland.
2. Use CONVERTBMP to Convert it in native format.
3. repeat step 4,5,6,7 for all pixel of Image1
4. get image pixel’s of Both Image’s p1 & p2
5. extracted its RGB value from native format
[
Device color depth:
The number of bits taken by the device to store the color value of one pixel is termed as the device color depth of the device. There are devices having color depth as 18 bit, 16 bit, 12 bit, 8bit.
RGB format of device:
RGB format specifies the number of bits used to represent the intensity of colors.
a) 18 bit device:
For 18 bit device the RGB format is 6 6 6. It does indicate that 6 bits (out of 18) are used to represent the Red color intensity similarly 6 for Green and last 6 for Blue color. In actual, to store one color value, memory consumption is not 18 bits, but is 4 byte (32 bits). The first 14 bits (32-18) are set to zero and they have no meaning. E.g. RGB of Red color is 255, 0, 0 in windows format. Now we have 4 bytes to store this color value in memory. As device is 18 bit device with format 6 6 6, the color value would be as 00000000 000000 11 1111 0000 00 000000
Unused 14 bits 6 bits for Red 6 bits for Green 6 bits for Blue
b) 16 bit device:
For 16 bit device the RGB format is 5 6 5. It means that 5 bits are used to represent the Red color intensity, 6 bits are used to represent the green color intensity and the last 5 bits are used for Blue color intensity. For 16 bit device 2 bytes required to store a color value of any pixel.
c) 12 bit device:
For 12 bit device the RGB format is 4 4 4. It means that 4 bits are used to represent the Red color intensity, 4 bits are used to represent the green color intensity and the last 4 bits are used for Blue color intensity. For 12 bit device 2 bytes are required to store the color value of one pixel.
d) 8 bit device:
For 8 bit device the RGB format is 3 2 3. It means that 3 bits are used to represent the Red color intensity, 2 bits are used to represent the green color intensity and the last 3 bits are used for Blue color intensity. For 8 bit device 1 byte is required to store the color value of one pixel.
]
in this Let Device Color Depth is 16
use
typedef union mynative
{
uint16 color;
struct{
uint16 B:5;
uint16 G:6;
uint16 R:5;
}stct;
myN;
for this color is Native Color value.
ex. ->
myN.color = p1;
assigned in this Union then
stct. B stct. G stct. R is the RGB Value which you want.]
6. Calculate newR , newG, newB values
by Appling this formula
NewR = (R1+ opacity*(R2-R1) );
NewG = (G1+ opacity*(G2-G1) );
NewB = (B1+ opacity*(B2-B1) );
Where
Opacity = 0 to 1. [0 for full Transparency]
Ex-> Opacity= 0.25 .0.50 etc.
R1 = R Value of Native Color of p1
R2 = R Value of Native Color of p2
Similarly G1,G2 & B1,B2
7.
noe again use
typedef union mynative
{
uint16 color;
struct{
uint16 B:5;
uint16 G:6;
uint16 R:5;
}stct;
myN;
this union to reassembled the RGB values of Native color
value
by doing this
myN.stct.R = newR;
myN.stct.G = newG;
myN.stct.B = newB;
now
myN. Color is the Native Color Value of new Bland Pixel
Now use IBITMAP_SetPixels() to Display it on Image1 for Display.
:)

hi marges,
if u want to give make image opaque or want to give the blind effect
there is one thing which can be very help full to u
i.e. IBITMAP_RGBtoNative(),
you have to to give color in hexa decimal format
like this in second argument of that function
0x000000aa
here BGRA --- aa stands for alpha....
or
#define RGBA(r,g,b,a) ((*uint8)a<<0 , (*uint8)r <<8,(*uint8)g<<16,(*uint8)b<<32));
i made a application with this its success fully running...

hi marges,
if u want to give make image opaque or want to give the blind effect
there is one thing which can be very help full to u
i.e. IBITMAP_RGBtoNative(),
you have to to give color in hexa decimal format
like this in second argument of that function
0x000000aa
here BGRA --- aa stands for alpha....
or
#define RGBA(r,g,b,a) ((*uint8)a<<0 , (*uint8)r <<8,(*uint8)g<<16,(*uint8)b<<32));
i made a application with this its success fully running...

Hi Prabhat,
I have some questions regarding hex value format.
Suppose if I have R=210 B = 190 G = 100 and alpha = 0.25 what should I pass in
"IBITMAP_RGBtoNative()" this function to get its native value which I will write in destination bitmap.
Waiting for reply.
Thank you.
-Rajni

Hi Prabhat,
I have some questions regarding hex value format.
Suppose if I have R=210 B = 190 G = 100 and alpha = 0.25 what should I pass in
"IBITMAP_RGBtoNative()" this function to get its native value which I will write in destination bitmap.
Waiting for reply.
Thank you.
-Rajni

Hi Guys,
Thanks for publishing the image blending algorithm.
I have achieved the transparency / blending by using the algorithm publish in the forum.
Thanks
Swami

Hi Guys,
Thanks for publishing the image blending algorithm.
I have achieved the transparency / blending by using the algorithm publish in the forum.
Thanks
Swami