nanogui: PNG and transparency
Subject:
Re: [nanogui] PNG and transparency
From:
Bajimohanreddy Bandi ####@####.####
Date:
4 Aug 2009 11:32:02 -0000
Message-Id: <6eca7d50908040431o38153e2fpf394cd5ae62ef1fc@mail.gmail.com>
alpha = (cr >>24 );
//printf("%s:In Function %s Alpha=%d
\n",__FILE__,__func__,alpha);
if (alpha != 0) { /* skip if pixel is fully
transparent*/
if (clip == CLIP_VISIBLE || GdClipPoint(psd,
x, y)) {
switch (psd->pixtype) {
case MWPF_PALETTE:
default:
pixel = GdFindColor(psd, cr);
break;
case MWPF_TRUECOLOR8888:
pixel = COLOR2PIXEL8888(cr);
break;
case MWPF_TRUECOLOR0888:
case MWPF_TRUECOLOR888:
// printf("MWPF_TRUECOLOR888\n\n");
pixel = COLOR2PIXEL888(cr);
break;
case MWPF_TRUECOLOR565:
// printf("\nMWPF_TRUECOLOR565:\n\n");
pixel = COLOR2PIXEL565(cr);
break;
case MWPF_TRUECOLOR555:
pixel = COLOR2PIXEL555(cr);
break;
case MWPF_TRUECOLOR332:
pixel = COLOR2PIXEL332(cr);
break;
/*case MWPF_TRUECOLOR233:
pixel = COLOR2PIXEL233(cr);
break;*/
}
//alpha=0xFF;
gr_background = psd->ReadPixel(psd, x, y);
if(psd->pixtype==MWPF_TRUECOLOR8888 ||
psd->pixtype==MWPF_TRUECOLOR0888 ||psd->pixtype==MWPF_TRUECOLOR888){
rb = (((pixel& 0x00ff00ff) * (alpha))
+((gr_background & 0x00ff00ff) * (0xff-alpha))) & 0xff00ff00;
g = (((pixel& 0x0000ff00) * (alpha)) +((gr_background &
0x0000ff00) * (0xff-alpha))) & 0x00ff0000;
pixel=(pixel& 0xff000000) | ((rb | g) >> 8);
}
else if(psd->pixtype==MWPF_TRUECOLOR565
||psd->pixtype==MWPF_TRUECOLOR555)
{
bs=pixel &0x1f;
bb=gr_background & 0x1f;
gs=(pixel>>5) & 0x3f;
gb=(gr_background>>5)&0x3f;
rs=(pixel>>11)&0x1f;
rb=(gr_background>>11)&0x1f;
blue=(alpha * (bs-bb) >> 8) + bb;
red=(alpha * (rs-rb) >> 8) + rb;
green=(alpha * (gs-gb) >> 8) + gb;
pixel= blue | (green << 5)|(red << 11);
}
psd->DrawPixel(psd, x, y,pixel);
this alpa blending concept working fine with png images.
it showing all transparency.
this changes in engine/devdraw.c file in GdDrawImage function.
regards,
Mohan.
On Thu, Jul 23, 2009 at 8:25 PM, BRACH Vincent ####@####.#### wrote:
> Hello,
>
> I try to draw transparency PNG images in my nano-X application but all
> the time the transparency's part of it is displayed in black..
> I tried to display it on an window created by
> GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, 480, 640, 0, WHITE, BLACK);
>
> I tried with GrLoadImageFromFile plus GrDrawImageToFit and with
> GrDrawImageFromFile too, and same result.
> When I convert this image in .xpm and use the same code (just changing
> th extension of the file to load) everything gonna be ok.
>
> Can anybody help me please ?
>
> Regards,
>
> Vincent BRACH
>
>
>
>
>
>
>