nanogui: Patch: Images with Alpha channel, 8bpp grayscale


Previous by date: 19 Jun 2005 19:22:37 +0100 Re: mouse pointer is hided on my arm box, Alain Volmat
Next by date: 19 Jun 2005 19:22:37 +0100 Re: geting a WM_ERASEBKGND message right after each WM_PAINT message, Greg Haerr
Previous in thread: 19 Jun 2005 19:22:37 +0100 Re: Patch: Images with Alpha channel, 8bpp grayscale, Greg Haerr
Next in thread:

Subject: Aw: Re: [nanogui] Patch: Images with Alpha channel, 8bpp grayscale
From: ####@####.####
Date: 19 Jun 2005 19:22:37 +0100
Message-Id: <23908531.1119205354228.JavaMail.ngmail@webmail-03.arcor-online.net>

Hi Greg,

>     This patch looks pretty good. 
Thanks :-)

> Which image decoder are you using that sets MWIMAGE_ALPHA_CHANNEL?
> Currently, only the tif decoder does this.  Are you sending in
> your own bits through another mechanism?

Yes, I decode pngs at client side. Nevertheless there's  a small code snipped for testing it, it's not a very clever piece of code, but easy to copy-and-paste :-)

> Also, is it just the jpeg decoder that you're using for greyscale
> images, by setting the last parm to 1 in the decoder?  

I convert colored images to greyscale in my app to use them in inactive windows.

> Ultimately, although slow, this patch does finally allow Microwindows
> to display alpha blended images without hardware support.

It would be faster and much more affective to have a PutPixel with Alpha channel support in the drivers. Even without hardware support it would need less function calls and make possible more optimal code. But the feature is not very important, I guess. Keep it in mind for the next redesign of the drivers...

> I think we need support for alpha channel in more decoders than just
> TIF, though.

At least for PNG it shouldn't be too complicated and quite useful. At the moment I'm quiet busy with other topics, but maybe I'll have a look at it later.

With regards,

Thomas

Here's the test code:
   {
      static GR_GC_ID gc;
      static MWCOLORVAL bitmap[256][256];
      static GR_IMAGE_HDR header;
      int x, y, a;
      
      if (!gc)
      {
         gc = GrNewGC();
         
         for (x = 0; x < 256; x++)
         {
            a = 255 - x;
            for (y = 0; y < 64; y++)
            {
               /* black bar, left opaque, right transparent */
               bitmap[y][x] = MWARGB(a, 0, 0, 0);
            }
            for (; y < 128; y++)
            {
               /* red bar, left opaque, right transparent */
               bitmap[y][x] = MWARGB(a, 255, 0, 0);
            }
            for (; y < 192; y++)
            {
               /* green bar, left opaque, right transparent */
               bitmap[y][x] = MWARGB(a, 0, 255, 0);
            }
            for (; y < 256; y++)
            {
               /* blue bar, left opaque, right transparent */
               bitmap[y][x] = MWARGB(a, 0, 0, 255);
            }
         }
         header.width = 256;
         header.height = 256;
         header.planes = 1;
         header.bpp = 32;
         header.pitch = 256 * 4;
         header.bytesperpixel = 4;
         header.compression = MWIMAGE_ALPHA_CHANNEL;
         header.palsize = 0;
         header.transcolor = -1;
         header.palette = NULL;
         header.imagebits = (MWUCHAR*)bitmap;
      }
      /* draw a checker as background */
      for (y = 0; y < 280; y += 8)
      {
         for (x = 0; x < 280; x += 8)
         {
            a = ((y + x) & 8) ? 255 : 0;
            GrSetGCForeground(gc, MWRGB(a, a, a));
            GrFillRect(fl_xid(p_main_window), gc, x, y, 8, 8);
         }
      }
      GrDrawImageBits(wid, gc, 10, 10, &header);
   }


Machen Sie aus 14 Cent spielend bis zu 100 Euro!
Die neue Gaming-Area von Arcor - über 50 Onlinespiele im Angebot.
http://www.arcor.de/rd/emf-gaming-1

Previous by date: 19 Jun 2005 19:22:37 +0100 Re: mouse pointer is hided on my arm box, Alain Volmat
Next by date: 19 Jun 2005 19:22:37 +0100 Re: geting a WM_ERASEBKGND message right after each WM_PAINT message, Greg Haerr
Previous in thread: 19 Jun 2005 19:22:37 +0100 Re: Patch: Images with Alpha channel, 8bpp grayscale, Greg Haerr
Next in thread:


Powered by ezmlm-browse 0.20.