By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,516 Members | 929 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,516 IT Pros & Developers. It's quick & easy.

Trouble displaying bitmap

P: n/a

I have trouble displaying a bitmap. I have 1bpp information. I also have
a command telling me what color i need to set the bytes to when the
colour is switched on. The trouble is i do all this but it will not
display properly. I convert this to 8bpp information. I set the relevant
pixel to for example "255,0,0" for this right?....i set the
Red byte to 255 and the other two values set to 0. I think the Bitmap
data class i am using is not working properly. Have a look at the data

bitmap = new
Bitmap(PageSizeInPixels.Width,PageSizeInPixels.Hei ght,System.Drawing.Ima

public struct PixelData
public byte RedValue;
public byte GreenValue;
public byte BlueValue;

public void LockBitmap()
GraphicsUnit unit = GraphicsUnit.Pixel;
RectangleF boundsF = bitmap[bitmap_Count - 1].GetBounds(ref unit);
Rectangle bounds = new Rectangle((int) boundsF.X,
(int) boundsF.Y,
(int) boundsF.Width,
(int) boundsF.Height);

// Figure out the number of bytes in a row
// This is rounded up to be a multiple of 4
// bytes, since a scan line in an image must always be a multiple of 4
// in length.
width = (int) boundsF.Width * sizeof(PixelsData);
if (width % 4 != 0)
width = 4 * (width / 4 + 1);
bitmapData =
bitmap[bitmap_Count - 1].LockBits(bounds, ImageLockMode.ReadWrite,

pBase = (Byte*) bitmapData.Scan0.ToPointer();

public void Make24BppBitmap()

//LineDataStore stores the 1bpp information
fixed(byte* ThisData = LineDataStore)
byte* CurrLine = ThisData + (y * ByteWidth);
PixelData* pPixel = PixelAt(0, y);
for (int x = 0; x < size.X; x++)
//check to see if bit is set by using masking
if it is set
pPixel->RedValue = GetBitmapColorValue[0];
pPixel->GreenValue = GetBitmapColorValue[1];
pPixel->BlueValue = GetBitmapColorValue[2];



For the above i only get a black bitmap......whats the problem.......

*** Sent via Devdex ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.