Re: Signature control - 1 BPP bitmap
- From: "Timothy Dean" <tim.dean@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 3 Oct 2005 14:46:32 -0600
I am still having problems. When I execute the following code from within
my CWnd derived class:
CRect rDrawingSurface;
GetWindowRect(&rDrawingSurface);
ScreenToClient(&rDrawingSurface);
CBitmap ddbBitmap;
BOOL
bResult=ddbBitmap.CreateBitmap(rDrawingSurface.Width(),rDrawingSurface.Heigh
t(),1,1,NULL);
CDC dcMemDDB;
CDC *pDC=GetDC();
if (pDC)
{
if (dcMemDDB.CreateCompatibleDC(pDC))
{
CBitmap *pOldDDBBitmap=dcMemDDB.SelectObject(&ddbBitmap);
dcMemDDB.BitBlt(rDrawingSurface.left,rDrawingSurface.top,rDrawingSurface.Wid
th(),rDrawingSurface.Height(),pDC,0,0,SRCCOPY);
BITMAP bm;
::GetObject(ddbBitmap.GetSafeHandle(), sizeof(bm),(LPVOID)&bm);
}
}
When I look at bm.bmBits, it is NULL. If I try to do a dcMemDDB.GetPixel(),
they seem to all come out as 0. It seems like the BitBlt didn't work. What
am I missing? Thanks.
Timothy Dean
"Gary Daniels [MS]" <garydan@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:uwlI1y3xFHA.2932@xxxxxxxxxxxxxxxxxxxxxxx
> Blitting from a 1bpp surface interprets 0's as the background color and
1's
> as the foreground color on the destination surface, so if you blit a 1bpp
> bitmap to a 24bpp primary and the foreground/background colors are red and
> blue, then you'll see red and blue for the 1's/0's of the bitmap.
>
> What that means is blitting from a 1bpp bitmap to a 1bpp DIB results in a
> closest color match of the foreground/background colors to the DIB color
> table, not a direct copy of the 1's/0's. If you do a SetDIBColorTable on
the
> dib and set 1 to the foreground color and 0 to the background color then
the
> color conversion from the 1bpp DDB to the DIB should be what you expect.
>
> Gary Daniels
> Windows CE Multimedia and Graphics
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> You assume all risk for your use.
>
> "Timothy Dean" <tim.dean@xxxxxxxxxxxxxxxxxxx> wrote in message
> news:uREkpdkxFHA.2652@xxxxxxxxxxxxxxxxxxxxxxx
> >I have tried this but apparently I must be doing something wrong. I need
> >to
> > eventually end up in a DIB section so I can store it as a device
> > independant
> > bitmap. So I tried BitBlt to a bitmap (device dependant) and then to a
1
> > bpp DIBSection from there. Maybe Blt-ing to the DIBSection is still
doing
> > the color matching, I don't know. How would I go from the bitmap to the
> > dibsection? Do I need to copy the bits direclty? Is there a code
example
> > I
> > could look at? Thanks.
> >
> > Timothy Dean
> >
> > "Gary Daniels [MS]" <garydan@xxxxxxxxxxxxxxxxxxxx> wrote in message
> > news:uaspUHixFHA.3740@xxxxxxxxxxxxxxxxxxxxxxx
> >> FYI, by 1bpp Bitmap, i'm referring to a bitmap created using
> >> CreateBitmap,
> >> not CreateDIBSection.
> >>
> >> Gary Daniels
> >> Windows CE Multimedia and Graphics
> >>
> >> This posting is provided "AS IS" with no warranties, and confers no
> > rights.
> >> You assume all risk for your use.
> >>
> >> "Gary Daniels [MS]" <garydan@xxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:OirIHGixFHA.664@xxxxxxxxxxxxxxxxxxxxxxx
> >> > There's two behaviors for monochrome bitmaps. There's the DIB
behavior
> >> > where the closest match is picked (i don't remember the algorithm for
> > the
> >> > closest match), and then there's the 1bpp bitmap behavior where if
the
> >> > color matches the background color the pixel is 0, otherwise it's 1.
> >> > You
> >> > can either switch to using a 1bpp Bitmap, or you can adjust the DIB
> > color
> >> > table to get the results you want. If you adjust the DIB color table
> >> > and
> >> > blt from the dib back to a color surface you'll get the colors in the
> >> > color table for the pixels. You can always change the color table
after
> >> > you blt into the surface so the output is what you want though.
> >> >
> >> > I hope that helps,
> >> >
> >> > Gary Daniels
> >> > Windows CE Multimedia and Graphics
> >> >
> >> > This posting is provided "AS IS" with no warranties, and confers no
> >> > rights.
> >> > You assume all risk for your use.
> >> >
> >> >
> >> > "Timothy Dean" <tim.dean@xxxxxxxxxxxxxxxxxxx> wrote in message
> >> > news:e9H1EBixFHA.2232@xxxxxxxxxxxxxxxxxxxxxxx
> >> >> eVC++ 4.0 MFC
> >> >>
> >> >> I am trying to capture a window to a monochrome bitmap for a
signature
> >> >> control. When I BitBlt from the Windows DC into a 1 BPP DIBSection,
> >> >> it
> >> >> is
> >> >> doing color matching of the pixels instead of setting bits that
match
> > the
> >> >> background color to 0, and all others to 1. For example, if I set
the
> >> >> background color of the window to blue (RGB(0,0,255)) and set the
pen
> >> >> color
> >> >> to red (RGB(255,0,0)), when I BitBlt it to the monochrome
DIBSection,
> > all
> >> >> bits come out the same. I am assuming this is because both colors
are
> >> >> closer to black than white. If I set the pen color to white, it all
> >> >> comes
> >> >> out ok. Is there something I am doing wrong? Is there a good
sample
> >> >> that
> >> >> shows how to do this? Thanks.
> >> >>
> >> >> Timothy Dean
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>
.
- References:
- Re: Signature control - 1 BPP bitmap
- From: Timothy Dean
- Re: Signature control - 1 BPP bitmap
- Prev by Date: Re: let's hope PlatformMin and PlatformMax work on WM5...
- Next by Date: Re: Why won't DataSet work in DLL?
- Previous by thread: Re: Signature control - 1 BPP bitmap
- Next by thread: Re: Signature control - 1 BPP bitmap
- Index(es):
Relevant Pages
|