473,385 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Not setting Bitmap data correctly whats wrong?


I use the following to read in the decompressed data first. Then when
this is all read in i use a method to try to set the relevant pixels to
their relevant color. When i output this bitmap its just all
black.....what is the problem?.
public struct EightPixelsData
{
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(EightPixelsData);
if (width % 4 != 0)
{
width = 4 * (width / 4 + 1);
}

bitmapData =
bitmap[bitmap_Count - 1].LockBits(bounds, ImageLockMode.ReadWrite,
PixelFormat.Format24bppRgb);

pBase = (Byte*) bitmapData.Scan0.ToPointer();
}
public void MakeBitmap(byte[] LineData)
{
//Copying a Decompressed line of data into the LineDataStoreArray
Buffer.BlockCopy(LineData,0,LineDataStore,(this.Ge tCurrYPos *
LineData.Length),LineData.Length);
}
public void Make24BppBitmap()
{
Point size = PixelSize;
LockBitmap();
int ByteWidth = (size.X + 7)/8;
byte bMask = (byte)0x00;
byte CurrByte = 0x0;
int byteWidthCount = 0;
int SetOrNot = 0;
/*After all lines of data are copied into the Line array.
*We now search through this array to check what bits were set
*/
fixed(byte* ThisData = LineDataStore)
{
/*StartLineSettingPosition is the first line with data to be set.
GetCurrYPos was the last line that we decompressed
*/
for(int y = this.StartLineSettingPosition ; y <=
this.GetCurrYPos;y++)
{
byte* CurrLine = ThisData + (y * ByteWidth);
EightPixelsData* pPixel = PixelAt(0, y);
byteWidthCount = 0;
for (int x = 0; x < size.X; x++)
{

if(x % 8 == 0)
{
CurrByte = *CurrLine;;
bMask = (byte)0x80;
byteWidthCount++;
CurrLine++;
if(byteWidthCount == 123)
{
bMask = (byte)0x80;
}
}
SetOrNot = bMask & CurrByte;
if(SetOrNot == 0)
{
pPixel->RedValue = this.GetBitmapColorValue[0];
pPixel->GreenValue = this.GetBitmapColorValue[1];
pPixel->BlueValue = this.GetBitmapColorValue[2];
}
pPixel++;
bMask >>= 1;
}
}
}
bMask >>= 1;
}

public EightPixelsData* PixelAt(int x, int y)
{
return ( EightPixelsData*) (pBase + y * widthinbytes + x * sizeof(
EightPixelsData));
}
public void UnlockBitmap()
{
bitmap[bitmap_Count - 1].UnlockBits(bitmapData);
bitmap[bitmap_Count - 1].Save("ThisTojpeg.jpg",ImageFormat.Jpeg);
bitmapData = null;
pBase = null;
}
public void SetBitmapColor(int colorValue)
{
bitmap_Color = colorValue;
}
public byte[] GetBitmapColorValue
{
get
{
RGBValues[0] = ColorPalette.bPalette_glbl[bitmap_Color,0];
RGBValues[1] = ColorPalette.bPalette_glbl[bitmap_Color,1];
RGBValues[2] = ColorPalette.bPalette_glbl[bitmap_Color,2];
return RGBValues;
}
}
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
0 1074

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kirk Quinbar | last post by:
hi, I have the following sample .NET 1.0 code which converts a metafile to a bitmap: Dim tmpImage As Bitmap 'System.Drawing.Image Dim streamX As New System.IO.MemoryStream() Dim fs As...
9
by: Mark Johnson | last post by:
How can you save all or a portion of the Grafics object to a Image/Bitmap ? I am try to save the Images from Cards.dll to a BitMap file. I can read in the Images to the Grafics, but when I try this...
1
by: James Dean | last post by:
I get the following message when i try to set a pixel in the bitmap.......whats wrong and how can i fix it....... "Additional information: SetPixel is not supported for images with indexed pixel...
8
by: James Dean | last post by:
I have 1 bit per pixel information and i have the width and height of this data.Each bit corresponds to a 24 bit colour value. I want to convert this to 24bit per pixel bitmap. Do i need to...
0
by: James Dean | last post by:
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...
4
by: James Dean | last post by:
I am trying to directly set the pixels in a 32ARGB image but for some reason i am not setting them correctly. I have a struct 4 bytes in size... public struct PixelData { public byte Blue;...
4
by: Jon Slaughter | last post by:
Whats is there any reason to use a Bitmap(Image) over an Image(Bitmap)? I'm making a container to hold bitmaps sorta like the ImageList class(that doesn't fix the sizes) but I'm not sure if I...
12
by: active | last post by:
I've been looking on the Internet for a way to convert a DIB to a Bitmap without success. Now I'm wondering if that is the approach I should be taking. All I want to do is display the DIB or...
7
by: RB0135 | last post by:
Hi All, I have some Windows BMP, 1BPP, monochrome files that I need to get the raw data from to load a graphics buffer on a Roll Printer (which I know can be done). Lets forget about the Roll...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.