Discussion:
Using BBitmap::SetBits
(too old to reply)
Dan Pidcock
2004-02-09 10:17:51 UTC
Permalink
Anybody still here??

I have some problems with using SetBits. I thought that the following
is the way to do it:
uint8 pixel[3]; // is ushort also 8 bits??
pixel[0] = 255; // red?
pixel[1] = 0; // green?
pixel[2] = 255; // blue?
// data length offset mode
bitmap->SetBits(pixel, 3, 100, B_RGB32)

I expected this to set the pixel to a magenta colour but it doesn't.
Changing the colours I can't yet work out what is going on and the
BeBook doesn't really explain this. I guess I have misunderstood the
byte to colour mapping?

Oh yes I intend to use Bits() in the long run but though it would be
easier to first get it working with SetBits().

Thanks,

Dan
Jøhnny Fävòrítê (it means "genetic antagonism")
2004-02-09 15:59:31 UTC
Permalink
Post by Dan Pidcock
Anybody still here??
just me, marco, and the spammers, i think. ask a tcp/ip question, that
would determine if donn cave is still reading.
Post by Dan Pidcock
I have some problems with using SetBits. I thought that the following
uint8 pixel[3]; // is ushort also 8 bits??
pixel[0] = 255; // red?
pixel[1] = 0; // green?
pixel[2] = 255; // blue?
// data length offset mode
bitmap->SetBits(pixel, 3, 100, B_RGB32)
I expected this to set the pixel to a magenta colour but it doesn't.
have a closer look at the BBitmap documentation, it answers your
question handily. you've got the RGB components in the wrong order.
Dan Pidcock
2004-02-09 18:44:08 UTC
Permalink
The problem was I was using ushort instead of uint8.
I thought I had tried uint8 too but obviously not.

Dan
Post by Dan Pidcock
Anybody still here??
I have some problems with using SetBits. I thought that the following
uint8 pixel[3]; // is ushort also 8 bits??
pixel[0] = 255; // red?
pixel[1] = 0; // green?
pixel[2] = 255; // blue?
// data length offset mode
bitmap->SetBits(pixel, 3, 100, B_RGB32)
I expected this to set the pixel to a magenta colour but it doesn't.
Changing the colours I can't yet work out what is going on and the
BeBook doesn't really explain this. I guess I have misunderstood the
byte to colour mapping?
Oh yes I intend to use Bits() in the long run but though it would be
easier to first get it working with SetBits().
Thanks,
Dan
revol
2004-02-11 09:44:12 UTC
Permalink
***@hotmail.com (Dan Pidcock) writes:

Yeah ushort is 2 bytes.
Btw, unless you really need high throughput the prefered method
to draw on a BBitmap is to attach a BView to it, and draw on
that BView. That will hold you from internal format changes and
endianness issues.
Btw, drawing a 1 pixel point on BView can be done by drawing
a 1x1 rect, as in:
theview->FillRect(BRect(x,y,x,y));

François.
Post by Dan Pidcock
The problem was I was using ushort instead of uint8.
I thought I had tried uint8 too but obviously not.
Dan
Post by Dan Pidcock
Anybody still here??
I have some problems with using SetBits. I thought that the following
uint8 pixel[3]; // is ushort also 8 bits??
pixel[0] = 255; // red?
pixel[1] = 0; // green?
pixel[2] = 255; // blue?
// data length offset mode
bitmap->SetBits(pixel, 3, 100, B_RGB32)
I expected this to set the pixel to a magenta colour but it doesn't.
Changing the colours I can't yet work out what is going on and the
BeBook doesn't really explain this. I guess I have misunderstood the
byte to colour mapping?
Oh yes I intend to use Bits() in the long run but though it would be
easier to first get it working with SetBits().
Thanks,
Dan
Loading...