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!