Thread: palette from bitmap

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    201

    palette from bitmap

    Is there a way to load a bitmap and then generate a palette from that bitmap with any win32 function?

  2. #2
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    why would you want to do that?

    or are you meaning mask.

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    201
    I make embedded gambling games. We need to put all bitmaps in 1 large bitmap and then generate a palette from it. Right now we do this manually with gimp, but I wanted to make a windows tool to automate this. That's why. But I'm beginning to think this is not possible with standard win32 API functions. right?

  4. #4
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Not if you're after what I think you're after, no. The best GDI can do is map whatever images you have to the default halftone palette (256 colours) or basic palette (16 colours). If you want to pick the colours in a different fashion you'll have to do it yourself.

    Standard algorithms are median cut or octree.

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You should theoretically create your bitmaps from a palette you have designed to contain all the colors you need. Then you save the bitmap and palette with it.

    At load-time you load the bitmap and palette, switch the palette, and then load the bitmap. You are doing it backwards and there is no guarantee that your bitmaps can be broken into the exact number of colors you need and yet still maintain image integrity. Normally it's possible, but it's much easier to reverse this process and create your own palette.

    This is how the old school VGA games worked. The artists created the palette which were then loaded into memory and the code would then tell the VGA hardware what the new palette was. Then the bitmap could be properly displayed as long as the palette did not change. Often times different levels and areas had different palettes. For instance, DOOM 1 was completely programmed in DOS using 256 color VGA graphics. And what they accomplished was nothing short of amazing in the small color space they were given.
    Last edited by VirtualAce; 07-19-2006 at 02:26 AM.

  6. #6
    Registered User
    Join Date
    Jun 2004
    Posts
    201
    yeah, the problem is that this hardware works with 3 layers

    on the bottom layer things are drawn in 16-bit, so you can directly draw non palettized bitmaps on it.

    The other 2 layers are palletized and you have to have 1 palette for it. An artist doesnt know on what layers things will come, and sometimes images are put on another layer for some reason. So we agreed that artists always deliver in 24 bit bmp's and when a programmer knows what images come on same layer he puts them all on one bitmap and generates an optimum palette. If images are moved to other layers that palette has to be recreated.
    For another project only 1 palette was chosen, but then the quality of the artwork was way worse. We dont have doom's artists here
    So a tool to generate palettes from bitmaps would be pretty handy. I gave up on trying it with win32 functions though

  7. #7
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Very odd device. May I inquire as to what device it is?

  8. #8
    Registered User
    Join Date
    Jun 2004
    Posts
    201

  9. #9
    Registered User
    Join Date
    Jun 2004
    Posts
    201

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  2. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 09:43 AM
  3. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  4. Loading a Bitmap resource for OpenGL Texture[x]
    By the dead tree in forum Game Programming
    Replies: 4
    Last Post: 08-26-2004, 01:12 PM
  5. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM