[<<] [<] Page 1 of 2 [>] [>>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
How to draw pixmap with transparency
From: "shin woojai" ####@####.#### Date: 22 Jan 2002 13:52:09 -0000 Message-Id: <OE581WO5ajXPsJZMgFl00011e6d@hotmail.com> I like to draw image (or pixmap) except one color. In other word, sprite effect of game programing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] How to draw pixmap with transparency
From: Jordan Crouse ####@####.#### Date: 22 Jan 2002 16:17:39 -0000 Message-Id: <E16T3ZA-0001ry-00@ns.censoft.com> You can draw any image type that supports transparency with the GrDrawImage*. However, at this point you can't blit (ie GrCopyArea) an image with transparent parts, but that will be coming soon. Jordan On Tuesday 22 January 2002 06:50, shin woojai mentioned: > I like to draw image (or pixmap) except one color. > In other word, sprite effect of game programing. > > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] How to draw pixmap with transparency
From: Julian Smart ####@####.#### Date: 27 Feb 2002 10:20:16 -0000 Message-Id: <4.2.0.58.20020227100945.03875940@pop> At 09:10 AM 1/22/02 -0700, Jordan Crouse wrote: >You can draw any image type that supports transparency with the >GrDrawImage*. >However, at this point you can't blit (ie GrCopyArea) an image with <br> >transparent parts, but that will be coming soon. > >Jordan Has anyone perhaps used a series of GrCopyArea calls with different ROPs to draw a pixmap transparently using another pixmap as mask? This is what's done in the wxWindows WIN32 port (if the native Windows masked drawing isn't implemented). I could try it myself but it would mostly be guesswork since the ROPs for Nano-X are likely to be slightly different from WIN32's. I'm at the point with the wxWindows for Nano-X port where transparent pixmap drawing is needed in order for the widget set to render properly... A separate question -- is there a Nano-X-approved to way to convert font sizes expressed in points to a height in pixels? I currently use the pixels-per-cm value to calculate it but I get > 40 pixels for a point size of 12, which is a bit excessive. Thanks, Julian -- Red Hat UK Ltd, Unit 200 Rustat House, 62 Clifton Road, Cambridge, UK. CB1 7EG Tel: +44 (1223) 271063 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] How to draw pixmap with transparency
From: Alex Holden ####@####.#### Date: 27 Feb 2002 11:23:21 -0000 Message-Id: <3C7CC06B.6080005@linuxhacker.org> Julian Smart wrote: > Has anyone perhaps used a series of GrCopyArea calls with different ROPs > to draw a pixmap transparently using another pixmap as mask? This is > what's done in the wxWindows WIN32 port (if the native Windows masked drawing isn't > implemented). I could try it myself but it would mostly be guesswork since the ROPs > for Nano-X are likely to be slightly different from WIN32's. I'm not sure. There are quite a few ROPs available, look for MWROP_* in include/mwtypes.h. I may have a look at this later if I get a chance, it's been on my TODO list for a while. > A separate question -- is there a Nano-X-approved to way to convert font sizes expressed > in points to a height in pixels? I currently use the pixels-per-cm value to calculate it > but I get > 40 pixels for a point size of 12, which is a bit excessive. I think you should be able to do a GrGetFontInfo() and look at the height field of the GR_FONT_INFO structure. -- ------------ Alex Holden - http://www.linuxhacker.org ------------ If it doesn't work, you're not hitting it with a big enough hammer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] How to draw pixmap with transparency
From: Julian Smart ####@####.#### Date: 27 Feb 2002 13:31:25 -0000 Message-Id: <4.2.0.58.20020227132645.038b5220@pop> At 11:18 AM 2/27/02 +0000, Alex Holden wrote: >I'm not sure. There are quite a few ROPs available, look for MWROP_* in >include/mwtypes.h. I may have a look at this later if I get a chance, >it's been on my TODO list for a while. That would be great, I'm sure there must be one or two other people who could use the ability draw pixmaps transparently :-) I suppose I could do it a pixel at a time, checking against the mask to see if I need to draw that pixel, but... ugh... >> A separate question -- is there a Nano-X-approved to way to convert font >sizes expressed >> in points to a height in pixels? I currently use the pixels-per-cm value >to calculate it >> but I get > 40 pixels for a point size of 12, which is a bit excessive. > >I think you should be able to do a GrGetFontInfo() and look at the >height field of the GR_FONT_INFO structure. Thanks, though unfortunately I need to convert the other way around (the wxWindows wxFont constructor takes a font size expressed in points). I may need to set a global fudge factor to get the size right. Regards, Julian -- Red Hat UK Ltd, Unit 200 Rustat House, 62 Clifton Road, Cambridge, UK. CB1 7EG Tel: +44 (1223) 271063 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] How to draw pixmap with transparency
From: Alex Holden ####@####.#### Date: 27 Feb 2002 13:52:28 -0000 Message-Id: <3C7CE364.9040006@linuxhacker.org> Julian Smart wrote: > That would be great, I'm sure there must be one or two other people who > could use the ability draw pixmaps transparently :-) I suppose I could do Myself included. > it a pixel at a time, checking against the mask to see if I need to draw > that pixel, but... ugh... That would be way too slow. If you're looking for a temporary kludge, it would be quicker to do a GrReadArea(), copy the image onto to it yourself, and then a GrArea() to put it back. > Thanks, though unfortunately I need to convert the other way around > (the wxWindows wxFont constructor takes a font size expressed > in points). I may need to set a global fudge factor to get the size > right. Oh, I see. Is the problem that the dpcm values are wrong? Currently I don't think there's any way to change it other than to hack the source (see scr_* ins src/drivers/). -- ------------ Alex Holden - http://www.linuxhacker.org ------------ If it doesn't work, you're not hitting it with a big enough hammer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] How to draw pixmap with transparency
From: Julian Smart ####@####.#### Date: 27 Feb 2002 14:44:06 -0000 Message-Id: <4.2.0.58.20020227143514.023b8e70@pop> At 01:47 PM 2/27/02 +0000, Alex Holden wrote: >> Thanks, though unfortunately I need to convert the other way around >> (the wxWindows wxFont constructor takes a font size expressed >> in points). I may need to set a global fudge factor to get the size >> right. > >Oh, I see. Is the problem that the dpcm values are wrong? Currently I >don't think there's any way to change it other than to hack the source >(see scr_* ins src/drivers/). It could just be that these values will rarely reflect reality given Nano-X can't know the actual screen size... In case you experiment with transparent drawing, here a fragment from the wxWindows WIN32 code which uses a temporary bitmap and several BitBlts to achieve transparency. In wxWindows masks, the transparent areas are black and the rest is white. Regards, Julian // create a temp buffer bitmap and DCs to access it and the mask dc_mask = ::CreateCompatibleDC(GetHdcOf(*source)); dc_buffer = ::CreateCompatibleDC(GetHdc()); buffer_bmap = ::CreateCompatibleBitmap(GetHdc(), width, height); HGDIOBJ hOldMaskBitmap = ::SelectObject(dc_mask, (HBITMAP) mask->GetMaskBitmap()); HGDIOBJ hOldBufferBitmap = ::SelectObject(dc_buffer, buffer_bmap); // copy dest to buffer if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, GetHdc(), xdest, ydest, SRCCOPY) ) { wxLogLastError(wxT("BitBlt")); } // copy src to buffer using selected raster op (usually SRCCOPY) if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, GetHdcOf(*source), xsrc, ysrc, dwRop) ) { wxLogLastError(wxT("BitBlt")); } // set masked area in buffer to BLACK (pixel value 0) COLORREF prevBkCol = ::SetBkColor(GetHdc(), RGB(255, 255, 255)); COLORREF prevCol = ::SetTextColor(GetHdc(), RGB(0, 0, 0)); if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height, dc_mask, xsrcMask, ysrcMask, SRCAND) ) { wxLogLastError(wxT("BitBlt")); } // set unmasked area in dest to BLACK ::SetBkColor(GetHdc(), RGB(0, 0, 0)); ::SetTextColor(GetHdc(), RGB(255, 255, 255)); if ( !::BitBlt(GetHdc(), xdest, ydest, (int)width, (int)height, dc_mask, xsrcMask, ysrcMask, SRCAND) ) { wxLogLastError(wxT("BitBlt")); } ::SetBkColor(GetHdc(), prevBkCol); // restore colours to original values ::SetTextColor(GetHdc(), prevCol); // OR buffer to dest success = ::BitBlt(GetHdc(), xdest, ydest, (int)width, (int)height, dc_buffer, 0, 0, SRCPAINT) != 0; if ( !success ) { wxLogLastError(wxT("BitBlt")); } // tidy up temporary DCs and bitmap ::SelectObject(dc_mask, hOldMaskBitmap); ::SelectObject(dc_buffer, hOldBufferBitmap); ::DeleteDC(dc_mask); ::DeleteDC(dc_buffer); ::DeleteObject(buffer_bmap); -- Red Hat UK Ltd, Unit 200 Rustat House, 62 Clifton Road, Cambridge, UK. CB1 7EG Tel: +44 (1223) 271063 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] How to draw pixmap with transparency
From: Jordan Crouse ####@####.#### Date: 27 Feb 2002 15:38:01 -0000 Message-Id: <1014823804.5896.14.camel@cosmic> > Has anyone perhaps used a series of GrCopyArea calls with different ROPs > to draw a pixmap transparently using another pixmap as mask? This is > what's done in the wxWindows WIN32 port (if the native Windows masked drawing isn't > implemented). I could try it myself but it would mostly be guesswork since the ROPs > for Nano-X are likely to be slightly different from WIN32's. We have a good amount of ROPS, so that might work. I'm not sure of the appropriate combinations. > I'm at the point with the wxWindows for Nano-X port where transparent pixmap drawing > is needed in order for the widget set to render properly... > > A separate question -- is there a Nano-X-approved to way to convert font sizes expressed > in points to a height in pixels? I currently use the pixels-per-cm value to calculate it > but I get > 40 pixels for a point size of 12, which is a bit excessive. Font sizes internally are expressed in pixels (ie, GrGetFontInfo() returns ascent and height). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] How to draw pixmap with transparency
From: ####@####.#### Date: 28 Feb 2002 13:26:05 -0000 Message-Id: <OF17BDA500.CC1C9E33-ON80256B6E.00477B90@diamond.philips.com> Hi, > Thanks, though unfortunately I need to convert the other way around > (the wxWindows wxFont constructor takes a font size expressed > in points). I may need to set a global fudge factor to get the size > right. Here's how I'm doing the points->pixels conversion: A "point" is defined as 1/72 inch. A common screen resolutions is 72 DPI (dots per inch). So 1 point is 1 pixel at 72 DPI. If that doesn't look right for your application, try playing with the DPI value - maybe increase it to 96 DPI, which gives 1 point = 1.333 pixels. Kind regards, Jon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] How to draw pixmap with transparency
From: Julian Smart ####@####.#### Date: 28 Feb 2002 13:47:00 -0000 Message-Id: <4.2.0.58.20020228134222.00a11e60@pop> At 01:12 PM 2/28/02 +0000, ####@####.#### wrote: >Hi, > >> Thanks, though unfortunately I need to convert the other way around >> (the wxWindows wxFont constructor takes a font size expressed >> in points). I may need to set a global fudge factor to get the size >> right. > >Here's how I'm doing the points->pixels conversion: > >A "point" is defined as 1/72 inch. > >A common screen resolutions is 72 DPI (dots per inch). > >So 1 point is 1 pixel at 72 DPI. > >If that doesn't look right for your application, try playing with the DPI >value - maybe increase it to 96 DPI, which gives 1 point = 1.333 pixels. Thanks a lot! I did try using the 72 dpi, which gave a similar result to getting the pixels-per-cm from Nano-X. Regards, Julian GR_SCREEN_INFO screenInfo; GrGetScreenInfo(& screenInfo); int yPixelsPerCM = screenInfo.ydpcm; // A point is 1/20 of an inch. // An inch is 2.541 cm. // So pixelHeight = (pointSize / 20) (inches) * 2.541 (for cm) * yPixelsPerCM (for pixels) // I don't know why this is necessary, but otherwise fonts // are just too big. float fudgeFactor = 0.6 ; int pixelHeight = (int) ( (((float)pointSize) / 20.0) * 2.541 * (float) yPixelsPerCM * fudgeFactor) ; // An alternative: assume that the screen is 72 dpi. // This gets a similar result to above (pre-fudge factor) //int pixelHeight = (int) (((float)pointSize / 20.0) * 72.0) ; -- Red Hat UK Ltd, Unit 200 Rustat House, 62 Clifton Road, Cambridge, UK. CB1 7EG Tel: +44 (1223) 271063 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[<<] [<] Page 1 of 2 [>] [>>] |