Jump to content
  • Advertisement
Sign in to follow this  

[MDX] Replacing palette of Bitmap and loading into Texture

This topic is 4518 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It's been a long time since I had the chance to work on my private project. At the moment, I load a base image, change a certain range of palette entries(8), update the palette and then load it bitmap as a Texture. However, in my executable, the original bitmap shows up, even tho I changed the palette. This is my code:
            Color c = Color.Green;
            Bitmap b = new Bitmap("images/quad.bmp");
            System.Drawing.Imaging.ColorPalette pal = b.Palette;

            for (int i = 0; i < 7; ++i)
                int red = (int)(c.R * (8.0 - i) / 8.0);
                int green = (int)(c.G * (8.0 - i) / 8.0);
                int blue = (int)(c.B * (8.0 - i) / 8.0);

                pal.Entries[142 + i] = Color.FromArgb(0xff, red, green, blue);
            b.Palette = pal;

            t = new Texture(engine.Device, b, Usage.None, Pool.Managed);

I don't understand why it doesn't update the palette. It doesn't matter if I change b.Palette.Entries or in pal, it bitmap doesn't show up with changed colors. My question is: Why is this? And how can I force the bitmap to update it's palette? I tried this in an application that used a picturebox, and apparantly, it works fine there... Toolmaker

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!