Anyone have a BitBlt function to convert Color -> B/W

Anyone have a BitBlt function to convert Color -> B/W

Post by Gofredd » Mon, 16 Feb 1998 04:00:00



I am trying to make buttons like ie4.  Ive got everything working except
that i have one property for the color picture and one for the b/w picture
(in the ie4 toolbar, when the user moves the mouse over the toolbar button
it goes from b/w to color).  I want to get rid of the b/w picture property
and do the color->b/w conversion myself.  I am sort of new to bitblt so I
really don't know how to write the function myself or I would.  Any ideas?

-GMG

 
 
 

Anyone have a BitBlt function to convert Color -> B/W

Post by Jim Deutc » Tue, 17 Feb 1998 04:00:00


here's a code snippet I have used to convert a color picture to monochrome.
 As written, it takes a colored image from picture1 and blits a black and
white copy to picture2.

  btmp = CreateBitmap(Form1.Picture1.ScaleWidth,
Form1.Picture1.ScaleHeight, 1, 1, 0&)
  chdc = CreateCompatibleDC(Form1.Picture1.hDC)
  x = SelectObject(chdc, btmp)
  l = BitBlt(chdc, 0, 0, Form1.Picture1.ScaleWidth,
Form1.Picture1.ScaleHeight, Form1.Picture1.hDC, 0, 0, SRCCOPY)
  l = BitBlt(Form1!Picture2.hDC, 0, 0, Form1.Picture1.ScaleWidth,
Form1.Picture1.ScaleHeight, chdc, 0, 0, SRCCOPY)
  Form1.Picture2.Refresh
  btmp = SelectObject(chdc, x)
  k = DeleteObject(btmp)
  retval = DeleteDC(chdc)

Jim Deutch
MS Dev MVP



Quote:> I am trying to make buttons like ie4.  Ive got everything working except
> that i have one property for the color picture and one for the b/w
picture
> (in the ie4 toolbar, when the user moves the mouse over the toolbar
button
> it goes from b/w to color).  I want to get rid of the b/w picture
property
> and do the color->b/w conversion myself.  I am sort of new to bitblt so I
> really don't know how to write the function myself or I would.  Any
ideas?

> -GMG