creating a .bmp file

C

colin

Hi,
I have all the components of a .bmp file in memory wich i need
to write to a .bmp file, (or other convenient image file)
ie i have 256 color pallete of RGBquads and array of 8bit pixels,

I can create a System.Drawing.Bitmap and it allows me to set the
witdh,height,bpp, and even the pixel data,
but it doesnt seem to let me set the color palette,
the palette property field is read/write
but requires a System.Drawing.Imaging.ColorPalette
but there seems to be no way of creating one of these,

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 ?

Colin =^.^=
 
P

Peter Duniho

I have all the components of a .bmp file in memory wich i need
to write to a .bmp file, (or other convenient image file)
ie i have 256 color pallete of RGBquads and array of 8bit pixels,

I can create a System.Drawing.Bitmap and it allows me to set the
witdh,height,bpp, and even the pixel data,
but it doesnt seem to let me set the color palette,
the palette property field is read/write
but requires a System.Drawing.Imaging.ColorPalette
but there seems to be no way of creating one of these,

I admit, I don't have any real experience using indexed color formats
in .NET. I do find it surprising that there's no good way to create a
palette.

However, the Microsoft knowledge base includes this suggestion to
create a dummy bitmap and grab the palette from that before disposing
the dummy bitmap:
http://support.microsoft.com/kb/319061

Also, it seems to me that if you've created an indexed-format Bitmap
instance, you should be able to just modify the palette that is created
with that instance, rather than replacing it altogether.

I would try the latter first.

And barring either of those methods working out for you, it's not like
it's really all that difficult to write the BMP file from scratch, even
if it is annoying. :)

Pete
 
C

colin

Peter Duniho said:
I admit, I don't have any real experience using indexed color formats in
.NET. I do find it surprising that there's no good way to create a
palette.

However, the Microsoft knowledge base includes this suggestion to create a
dummy bitmap and grab the palette from that before disposing the dummy
bitmap:
http://support.microsoft.com/kb/319061

Also, it seems to me that if you've created an indexed-format Bitmap
instance, you should be able to just modify the palette that is created
with that instance, rather than replacing it altogether.

I would try the latter first.

And barring either of those methods working out for you, it's not like
it's really all that difficult to write the BMP file from scratch, even if
it is annoying. :)

Pete

thanks, well I dont actually have an instance of a BMP image to start with,
but I do have the individual components wich are extracted from a texture
file, where one palette is shared by more than one pixel array.

I simply wish to put each image into a more easily displayed format.

il prob do the write the data to file directly,
seems a fag just becuase you cant actually create a palette.

Colin =^.^=
 
M

Michael Phillips, Jr.

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.
 
P

Peter Duniho

thanks, well I dont actually have an instance of a BMP image to start with,
but I do have the individual components wich are extracted from a texture
file, where one palette is shared by more than one pixel array.

Well, how did you expect to get the raw pixel data into a Bitmap instance?

Presumably you would be using LockBits. But LockBits requires a Bitmap
instance to be created in the first place.

So, presumably you were going to create a Bitmap instance, use LockBits
to set the pixel data for the image, and apply a palette to that
Bitmap. Well, just create the correct Bitmap format in the first
place, get the palette from the Palette property and modify that
palette directly.
I simply wish to put each image into a more easily displayed format.

And so you can.
il prob do the write the data to file directly,
seems a fag just becuase you cant actually create a palette.

I don't understand that comment. I just described TWO different ways
to "create a palette" (or at least to get one you can set
appropriately).

I can understand you deciding you'd rather not bother with those
alternatives. But don't say it can't be done. Obviously it can, at
least according to the documentation.

Is there something about the methods I described that don't work as advertised?

Pete
 
C

colin

Peter Duniho said:
Well, how did you expect to get the raw pixel data into a Bitmap instance?

with the Bitmap constructor, it allows you to provide all but the palette...

IntPtr
scan=Marshal.UnsafeAddrOfPinnedArrayElement(mip.DataArray.ToArray(),0);
Bitmap bmp = new Bitmap(mip.USize, mip.VSize, ((mip.USize+3)/4)*4,
PixelFormat.Format8bppIndexed, scan);
Presumably you would be using LockBits. But LockBits requires a Bitmap
instance to be created in the first place.

So, presumably you were going to create a Bitmap instance, use LockBits to
set the pixel data for the image, and apply a palette to that Bitmap.
Well, just create the correct Bitmap format in the first place, get the
palette from the Palette property and modify that palette directly.


And so you can.


I don't understand that comment. I just described TWO different ways to
"create a palette" (or at least to get one you can set appropriately).

I re read the link to the gif file, and saw the answer,
it was rather long and didnt seem to apply,
it seemed quicker to do it the dirty way,
however this didnt work and rather than spend ages debuging i re read what
you wrote a few times.

I failed to see how to actually modify the palette before re-reading a few
times lol.
for (x = 0; x < 256; x++)
{
bmp.Palette.Entries[x] = Color.FromArgb(palette[x].R, palette[x].G,
palette[x].B);
}
thanks it works now, although i think ive got my rows/cols messed up somehow
as it looks odd
but im kinda guesing at the format ive got.

Colin =^.^=
 
P

Peter Duniho

[...]
thanks it works now, although i think ive got my rows/cols messed up somehow
as it looks odd
but im kinda guesing at the format ive got.

Glad to hear that you were able to figure out what I meant.

As far as how it looks, I would guess you've got something wrong with
the stride somehow (that usually being the issue when someone says
their bitmap "looks odd" :) ), but it's hard to say for sure without
having all the information.

Pete
 
C

colin

This is the coode I have so far ...

IntPtr scan =
Marshal.UnsafeAddrOfPinnedArrayElement(mip.DataArray.ToArray(), 0);
Bitmap bmp = new Bitmap(mip.VSize, mip.USize, mip.VSize ,
PixelFormat.Format8bppIndexed, scan);
int x;
//System.Drawing.Imaging.ColorPalette pal = bmp.Palette;
for (x = 0; x < 256; x++)
{
FColor c = palette.Colors[x];
bmp.Palette.Entries[x] = System.Drawing.Color.FromArgb(c.R, c.G, c.B);
}
bmp.Save(filename + i.ToString() + ".bmp");


However the file seems to be saved in .png format,
256x256 8bpp file is only 22k insterad of at least 65k.
but my data isnt compressed,
wich is probably why its looking weird lol.

how can i specify/force it to use .BMP type format rather than png ?

Colin =^.^=
 
C

colin

Michael Phillips said:
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/skyscraper/windows/364/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 =^.^=
 
P

Peter Duniho

[...]
However the file seems to be saved in .png format,
256x256 8bpp file is only 22k insterad of at least 65k.
but my data isnt compressed,
wich is probably why its looking weird lol.

Probably not. You can tell for sure by displaying the bitmap before
you save it (which is trivial to do in .NET), but the act of
compressing a bitmap for saving as PNG wouldn't normally change how the
image looks, since decompressing it again to turn it back into a Bitmap
instance would just reverse the original compression.
how can i specify/force it to use .BMP type format rather than png ?

You have to specify a codec in the call to Save(). PNG is the default
that's used when you use a Save() overload that doesn't include an
ImageCodecInfo parameter.

I don't know if there's a better way, but the MSDN samples say that you
have to use ImageCodecInfo.GetImageEncoders() to get an array of
encoders, and then enumerate them to look for the format you want
(checking the MimeType property), using the encoder with that format.

This is the method I use in my programs and it works fine.

Pete
 
C

colin

Peter Duniho said:
[...]
However the file seems to be saved in .png format,
256x256 8bpp file is only 22k insterad of at least 65k.
but my data isnt compressed,
wich is probably why its looking weird lol.

Probably not. You can tell for sure by displaying the bitmap before you
save it (which is trivial to do in .NET), but the act of compressing a
bitmap for saving as PNG wouldn't normally change how the image looks,
since decompressing it again to turn it back into a Bitmap instance would
just reverse the original compression.
how can i specify/force it to use .BMP type format rather than png ?

You have to specify a codec in the call to Save(). PNG is the default
that's used when you use a Save() overload that doesn't include an
ImageCodecInfo parameter.

I don't know if there's a better way, but the MSDN samples say that you
have to use ImageCodecInfo.GetImageEncoders() to get an array of encoders,
and then enumerate them to look for the format you want (checking the
MimeType property), using the encoder with that format.

This is the method I use in my programs and it works fine.

Pete

hmm wel ive found the BMP codec, its the first one,
it seems to need a parameter, ive pased null,
but cant find out where the info for this is,
but it produces a .bmp file wich has 'BM' as first 2 bytes.

it stil produces the same weird output however,
but I did manage to debug my directly aproach
and the .bmp file looks fine.

the 2 files look nothing alike whatsoever in a hex viewer.

the colours are weird too, its actually a boring grey rock surface texture,
but the weird one looks like a colourful tartan pattern.

gues il stick with the direct aproach but id be interested in
finding out why this doesnt work.

Colin =^.^=
 
C

colin

colin said:
Michael Phillips said:
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/skyscraper/windows/364/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]);
}

well i compared the output from this to a similar sized bmp file
and determined that the 3rd write was pushing everything out by 4 bytes,
so i removed it and it works fine.
either ive misinterpreted that web page or its wrong
or the format has changed lol.

Colin =^.^=
 
P

Peter Duniho

hmm wel ive found the BMP codec, its the first one,
it seems to need a parameter, ive pased null,
but cant find out where the info for this is,

You can start with the doc page for Image.Save(). I don't recall
exactly where these are documented, but I know that when I looked them
up before, that's where I started. It was a matter of following the
right links to find sample code that illustrated how to use the codecs.

That said, I think null is a valid value for the EncoderParameters
parameter. The defaults for the file type will be used. There's not
much you could specify for a BMP file anyway; maybe CompressionRle
would be useful, but otherwise BMP are pretty straight-forward. I
don't even know for sure that CompressionRle is supported for the BMP
encoder; it ought to be, but I've never tried it myself and the docs
only mention TIFF.
but it produces a .bmp file wich has 'BM' as first 2 bytes.

it stil produces the same weird output however,
but I did manage to debug my directly aproach
and the .bmp file looks fine.

the 2 files look nothing alike whatsoever in a hex viewer.

the colours are weird too, its actually a boring grey rock surface texture,
but the weird one looks like a colourful tartan pattern.

Does the palette actually include any color? If the palette is a
general-purpose palette and you know that only the grey colors are
actually used, then it's possible you've some wrong pixel values that
are using the wrong colors in the palette. Alternatively, if the
palette itself is wrong, you could have the right pixel values and
still get colors instead of the grey shades you're expecting.

Also, did you display the bitmap before saving it? Did it look correct
then? Or was it already wrong at that point?

Pete
 
C

colin

Peter Duniho said:
On 2007-11-17 19:20:50 -0800, "colin" <[email protected]>
said:
...

Does the palette actually include any color? If the palette is a
general-purpose palette and you know that only the grey colors are
actually used, then it's possible you've some wrong pixel values that are
using the wrong colors in the palette. Alternatively, if the palette
itself is wrong, you could have the right pixel values and still get
colors instead of the grey shades you're expecting.

Also, did you display the bitmap before saving it? Did it look correct
then? Or was it already wrong at that point?

I never actually viewed the bmp file before saving,
at the momnent im just trying to get the file import
working, saving them all to disc and viewing them is
an easy way to see if theres any anomolies,
the boring images had about 15 greyscale values in the 256 color table,
the badly saved images had a full color table full of seemingly random
colours.

also the pixel tsble seemed to bear no relation whatsoever to the value
given to the constructor.

there are other images wich do have plenty of colour and these look pretty
much the same
weird tartan pattern, my direct aproach seems to display all these
beutifully however,
despite they are so dammed dark, but this seems to be a 'feature' of the
game they come from
(unreal), i might play around with the gamma of the color table.

the images will ultimatly be used as textures for a 3d surface.
but this is also an editor so a list will be displayed to be able to select
the desired pattern.

I dont know how the palette is so wrong as im putting in the right vallues
unless im just
getting a copy of the palette to wich my changes are just simply thrown
away.
wich is why i thought i couldnt change the palette in the first place.

but the bitmap data is so wrong too, maybe my pinned array isnt behaving as
I expect.
I use marshaleing elsewhere in the program and I suspect it is cuasing weird
problems,
although it does seem to do what its suposed to.
I may try and avoid unsafe totaly code if i can.

thanks
Colin =^.^=
 
C

colin

colin said:
colin said:
Michael Phillips said:
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/skyscraper/windows/364/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]);
}

well i compared the output from this to a similar sized bmp file
and determined that the 3rd write was pushing everything out by 4 bytes,
so i removed it and it works fine.
either ive misinterpreted that web page or its wrong
or the format has changed lol.

Colin =^.^=

or maybe the (((UInt32)1078 + mip.USize * mip.VSize) is being written as an
int64
even though usize and vsize are ints and its on a 32 bit mchine.
I had intended the cast to aply to the final results but
looks like i missed a couple of parenthesis.

Colin =^.^=
 
M

Michael Phillips, Jr.

A bitmap's scanline must be aligned on a dword boundary.

The width in bytes of one scanline is:
uint WidthBytes = (((Width * bpp) + 31) >> 5) << 2;

The size of the bitmap's pixels as specified in the BITMAPINFOHEADER
biSizeImage is:
biSizeImage = WidthBytes * Height; // write this struct member to the stream
writer.Write((UInt32)1078 + mip.USize * mip.VSize);
writer.Write((UInt32)1078 + biSizeImage);

In addition to writing the structures correctly, the image bytes must be
written in scanline order where each scanline is aligned on a dword
boundary.
for (x = 0; x < mip.USize * mip.VSize;x++ )
{
writer.Write(mip.DataArray[x]); // each scanline must be dword aligned
and padded, if necessary.
}

Finally, do not forget to rewind the stream. The Bitmap decoder assumes
that the stream starts at position 0 where is will read the signature bytes
'BM'.


colin said:
Michael Phillips said:
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/skyscraper/windows/364/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 =^.^=
 
C

colin

Michael Phillips said:
A bitmap's scanline must be aligned on a dword boundary.

The width in bytes of one scanline is:
uint WidthBytes = (((Width * bpp) + 31) >> 5) << 2;

The size of the bitmap's pixels as specified in the BITMAPINFOHEADER
biSizeImage is:
biSizeImage = WidthBytes * Height; // write this struct member to the
stream
writer.Write((UInt32)1078 + mip.USize * mip.VSize);
writer.Write((UInt32)1078 + biSizeImage);

In addition to writing the structures correctly, the image bytes must be
written in scanline order where each scanline is aligned on a dword
boundary.
for (x = 0; x < mip.USize * mip.VSize;x++ )
{
writer.Write(mip.DataArray[x]); // each scanline must be dword aligned
and padded, if necessary.
}

Finally, do not forget to rewind the stream. The Bitmap decoder assumes
that the stream starts at position 0 where is will read the signature
bytes 'BM'.

thanks, yes good points, for now all my images seem to be 256x256 or at
least multiples of 4
and 256 colors, so it is easy to ignore most of that, but if I find one
diferent il have to adapt,
although its not that difficult, im just so surprised there isnt a straight
forward
CLI function wich does it all for you.

I had to put my scan lines in reverse order to as they viewed upside down.

I write them all to file mainly to view with an external program,
but I also use an html window control on my form for coloured text,
in wich I could also view the images by just specifying the filenames.

im not sure what format i need them in eventually to use as a texture
for the XNA game side of things.

however I think it was this line that was throwing me ...
I think it was writing a 64 bit value, as removing the folowing 4byte
reserved field made it all work.
I doubt the size will ever extend beyond 32 bits.

Colin =^.^=
 
C

colin

Michael Phillips said:
A bitmap's scanline must be aligned on a dword boundary.

The width in bytes of one scanline is:
uint WidthBytes = (((Width * bpp) + 31) >> 5) << 2;

The size of the bitmap's pixels as specified in the BITMAPINFOHEADER
biSizeImage is:
biSizeImage = WidthBytes * Height; // write this struct member to the
stream
writer.Write((UInt32)1078 + mip.USize * mip.VSize);
writer.Write((UInt32)1078 + biSizeImage);

In addition to writing the structures correctly, the image bytes must be
written in scanline order where each scanline is aligned on a dword
boundary.
for (x = 0; x < mip.USize * mip.VSize;x++ )
{
writer.Write(mip.DataArray[x]); // each scanline must be dword aligned
and padded, if necessary.
}

Finally, do not forget to rewind the stream. The Bitmap decoder assumes
that the stream starts at position 0 where is will read the signature
bytes 'BM'.

ive got tons of .bmp files generated now,
ive looked into importing them as Texture2d object
to use as textures on the XNA game developer
to display my 3d models, after a bit of mesing about

basicEffect.Texture = Texture2D.FromFile(graphics.GraphicsDevice,
"Textures\\Skaarj.A_a2c_0.bmp");
basicEffect.TextureEnabled = true;
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Begin();
graphics.GraphicsDevice.DrawPrimitives(
PrimitiveType.TriangleFan,0,Cnt);
}

however when I display it the colours look odd,
the red and blue seem true, but the green seems to be missing,
evrything has a purpleness to it,
yet it displays fine in explorer/paint,
other images dont seem to display too wel either,
they seem toget far more than just the colour wrong.


at first it didnt even work at all, giving a strange operation error,
i did have the biPlanes field set to zero as per the text,
but the number mentioned 1, the image viewed in explorer ok,
but not in paint, fliping the image clockwise and back
made it work in paint ok, and the only change was this bit set to 1,
now i changed my code it works betetr
and loads in paint and in xna texture2d object too.
but with a wierd colour.

the RGBA A field seems to be set to ff after this rotation too.

I dont see how it can be the bmp file,
is there some way of messing up using Texture2d
in the XNA drawing primitives ? (using triangle fan)

Colin =^.^=
 
C

colin

however when I display it the colours look odd,
the red and blue seem true, but the green seems to be missing,
evrything has a purpleness to it,
yet it displays fine in explorer/paint,
other images dont seem to display too wel either,
they seem toget far more than just the colour wrong.

ah no problem, id copied one of the tutorials,
and it had a colour filter set lol
works quite wel now :D

Colin =^.^=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top