Easy and efficient way to get and set pixels

  • Thread starter Thread starter James Dean
  • Start date Start date
J

James Dean

I was wondering if anybody knew and easy way to read pixels. Is the
easiest way to read a byte in convert it to a Bitarray and then when
finished convert it back to Byte......I am looking in my monochrome
bitmap file now at the minute.....if a value is false then the pixel is
turned off and therefore its white......but this does not seem to be
true.....could anyone explain how exactly to use this bitarray.....i
have a monochrome bitmap file read in....it says the first byte reads
:false true false etc (01000010) which is "66" in decimal.......i am
looking at the screen and the position and its clearly meant to be white
whats wrong.....anybody know?........marcian u answered my questions
before maybe u know......and thanks to u too.....
 
Hi James,
I was wondering if anybody knew and easy way to read pixels. Is the
easiest way to read a byte in convert it to a Bitarray and then when
finished convert it back to Byte......I am looking in my monochrome
bitmap file now at the minute.....if a value is false then the pixel is
turned off and therefore its white......but this does not seem to be
true.....could anyone explain how exactly to use this bitarray.....i
have a monochrome bitmap file read in....it says the first byte reads
:false true false etc (01000010) which is "66" in decimal.......i am
looking at the screen and the position and its clearly meant to be white
whats wrong.....anybody know?........marcian u answered my questions
before maybe u know......and thanks to u too.....

I had wiritten some "fast" c# image processing classes... but
they have been working with 24bpp precission. So i don't
have any practise with other pixel formats.

Only thing i can recommad to You is to try using method:
Bitmap.LockBits(
Rectangle rect,
ImageLockMode flags,
PixelFormat format
);

It returns BitmapData with Scan0 property which returns
memory address of first byte of bitmap data.
....but from here becomes "UNSAFE" mode with pointers.

If You've got any experience in C/C++ programing then
You should menage with this.

But, If You want to work with files and streams then
make sure to get those files specification (if they
have any compression or particular byte direction?)
Good thing is to start with small files e.g. 16x16.

Usually if there's no compression, image data lies
at the end part of file. So if you know its size then
you can easily gets its bytes.

Cheers!

Marcin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top