"Michael Phillips, Jr." <(E-Mail Removed)0m> wrote in message
news:(E-Mail Removed)...
>> there must be a way surly am I missing something or do
>> I have to go and create the wheel all over again and
>> write my own BITMAPFILEHEADER,BITMAPINFOHEADER,etc
>> and write those to the file ?
>
> The easiest and most efficient way is the create a MemoryStream object
> and write to it in this order:
> 1) Write the BITMAPFILEHEADER to the stream.
> 2) Write the BITMAPINFOHEADER to the stream.
> 3) Write the color palette to the stream.
> 4) Write the pixels to the stream.
> 5) Rewind the stream to position 0.
> 6) Create your Bitmap with System.Drawing.Bitmap using the stream
> constructor.
>
> Streams are extremely efficient as the BITMAP decoder reads the signature
> first and only creates memory for its internal structures when the
> bitmap's bits are actually accessed.
hi thanks,
once ive done that Ive basicaly created a bmp file from scratch,
I only want to make a file copy anyway,
I had the folowing code but it didnt work and I havnt managed to figure out
why yet,
windows viewer just complains it cant display it
the various numbers was taken from
http://www.fortunecity.com/skyscrape.../bmpffrmt.html
BinaryWriter writer=new BinaryWriter(file);
writer.Write((UInt16)19778);
writer.Write((UInt32)1078 + mip.USize * mip.VSize);
writer.Write((UInt32)0);
writer.Write((UInt32)1078);
writer.Write((UInt32)40);
writer.Write((UInt32)mip.USize);
writer.Write((UInt32)mip.VSize);
writer.Write((UInt16)1);
writer.Write((UInt16)8);
writer.Write((UInt32)0);
writer.Write((UInt32)0);
writer.Write((UInt32)0);
writer.Write((UInt32)0);
writer.Write((UInt32)0);
writer.Write((UInt32)0);
int x;
for (x = 0; x < 256; x++)
{
writer.Write(palette.Colors[x].B);
writer.Write(palette.Colors[x].G);
writer.Write(palette.Colors[x].R);
writer.Write((Byte)0);
}
for (x = 0; x < mip.USize * mip.VSize;x++ )
{
writer.Write(mip.DataArray[x]);
}
Colin =^.^=