Black&White

Black&White

Post by Christoph » Fri, 23 May 2003 15:28:16



Hi,

Is anybody know how to use DIBdata under VB when you've got a B&W bitmap.
My probleme is that one pixel equal one bit, so when you want to make
something on one  or more pixel you're obliged to read or write a bit in a
byte.
And the other trouble is that when you want to scale a B&W Bitmap you're
obliged to make an AND or OR to calculate the new pixel.
(in a function like strechtblt).
In the height no troubles, but in the width !!

is anybody have an exemple to use bit level in VB ?

Christophe

 
 
 

Black&White

Post by Mike D Sutto » Fri, 23 May 2003 20:09:10


Quote:> Is anybody know how to use DIBdata under VB when you've got a B&W bitmap.
> My probleme is that one pixel equal one bit, so when you want to make
> something on one  or more pixel you're obliged to read or write a bit in a
> byte.
> And the other trouble is that when you want to scale a B&W Bitmap you're
> obliged to make an AND or OR to calculate the new pixel.
> (in a function like strechtblt).
> In the height no troubles, but in the width !!

> is anybody have an exemple to use bit level in VB ?

Sure, here's one I wrote recently (Have a look at the SetPixel1() function
at the bottom):
http://groups.google.co.uk/groups?selm=Oz%24J9UbCDHA.2384%40TK2MSFTNG...
You can implement a GetPixel1() method in much the same way.
Rather than dealing with the 1-bit data directly though, it's far easier to
just create a 1-BPP DDB and use StretchBlt() / GetPixel() / SetPixelV() to
manipulate the data, or use GetDIBits() to read the data out at 8-BPP which
is easier and quicker to manipulate since it byte aligns (You may even want
to investigate performing a fast 1->8->1 bit conversion yourself if you're
going to be working with the data for any amount of time.)
Hope this helps,

    Mike

 - Microsoft Visual Basic MVP -

WWW: Http://www.mvps.org/EDais/

 
 
 

Black&White

Post by Christoph » Fri, 23 May 2003 21:54:41


Thanks a lot
Christophe


Quote:> > Is anybody know how to use DIBdata under VB when you've got a B&W
bitmap.
> > My probleme is that one pixel equal one bit, so when you want to make
> > something on one  or more pixel you're obliged to read or write a bit in
a
> > byte.
> > And the other trouble is that when you want to scale a B&W Bitmap you're
> > obliged to make an AND or OR to calculate the new pixel.
> > (in a function like strechtblt).
> > In the height no troubles, but in the width !!

> > is anybody have an exemple to use bit level in VB ?

> Sure, here's one I wrote recently (Have a look at the SetPixel1() function
> at the bottom):

http://groups.google.co.uk/groups?selm=Oz%24J9UbCDHA.2384%40TK2MSFTNG...
.gbl

- Show quoted text -

> You can implement a GetPixel1() method in much the same way.
> Rather than dealing with the 1-bit data directly though, it's far easier
to
> just create a 1-BPP DDB and use StretchBlt() / GetPixel() / SetPixelV() to
> manipulate the data, or use GetDIBits() to read the data out at 8-BPP
which
> is easier and quicker to manipulate since it byte aligns (You may even
want
> to investigate performing a fast 1->8->1 bit conversion yourself if you're
> going to be working with the data for any amount of time.)
> Hope this helps,

>     Mike

>  - Microsoft Visual Basic MVP -

> WWW: Http://www.mvps.org/EDais/

 
 
 

1. Convert Black&White to Red&White?

After I have converted a photo to line art (Black and White 1-bit
depth), can I convert it to full color but where all the black pixels
get turned into a color of my choice, like pure red? or blue? or
yellow?
I would want all the white pixels to stay white, of course.  If there
is a way, could someone show me which tabs and options it would be
under?  littleberry

2. What do attendees of SIGGRAPH wear?

3. That Old Black&White Clip Art

4. WWW Link Directory (Computers)

5. WANTED: Gif Viewer for XWindows, BLACK&WHITE

6. Learning BMRT

7. Black&White -> Monochrome

8. libfgl documentation?

9. Black&White

10. Error saving file when scanning black&white!!!

11. Good color to black&white tutorial

12. Changing images from colour to black&white/greyscale or sepia