By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,910 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,910 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 Red.....is 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
below.

bitmap = new
Bitmap(PageSizeInPixels.Width,PageSizeInPixels.Hei ght,System.Drawing.Ima
ging.PixelFormat.Format8bppIndexed);

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
bytes
// 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,
PixelFormat.Format8bppIndexed);

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
then
{
pPixel->RedValue = GetBitmapColorValue[0];
pPixel->GreenValue = GetBitmapColorValue[1];
pPixel->BlueValue = GetBitmapColorValue[2];
}
pPixel++;
}

}

}

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

*** Sent via Devdex http://www.devdex.com ***
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.