DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Palette Mapping

  1. #1
    Join Date
    Jan 2008

    Palette Mapping

    I have no idea where to start being fairly new to c++. I'm using MS Visual Studio C++ 2005 and am working on a project which will have a custom pallete. I'd like certian images in the project to be remappable. I've made a custom pallete complete with rgb values and palette indexes but I need to figure out how to swap colors within a specified area from one array of indexed colors to another array of indexed colors from the same palette, or i could just specify the rgb values assign them to an array, and use that array as a variable.

    I can't seem to find any related libs, or for that matter, and libs at all that pertain to 2d palette mapping.

    Any assistance would be greatly appreciated.

    Thanks in advance,
    Some guy.

  2. #2
    Join Date
    Dec 2003
    What do you actually have? And rgb array / image or an array of indexes into a pallet? Also, do you want two pallets active at the same time (subregions) ?? That is beyond normal use of pallets, and I do not know of a library that will do that off the top of my head. But it is easy enough. I will help but need a little more info on what you have and what you really want to accomplish.

  3. #3
    Join Date
    Jan 2008
    the app uses a singular coherent palette for everything. All graphical resources for the app adhere to the same palette. The machine I write on is elsewhere, so I can't exactly give you a verbatim code. More over hopefully a proper expilation of what I'm trying to do might help.

    I have the palette file which is a simple text file of tabular data read and each line has an array made of it and the array is labelled by palette index which also happens to be the line number. the first element in the array is the red value, second element is the green value, and third element is the blue value. The palette file looks something like this

    0 0 0
    14 14 14
    117 11 11
    208 21 14
    206 113 87
    15 15 15
    30 30 30
    45 45 45
    60 60 60
    75 75 75
    90 90 90
    255 255 255

    from here what I need to do is read the file and dump it to arrays. I'm fairly certain I'm capable of figuring that out myself as i should be able to do that with standard includes like fstream, string, etc. The key part of what I'm trying to do is be able to specify a certain x,y position and width and height within the dialog box and within that area only, swap colors by indexed palette order on say a Compuserve Gif file. That way user's can dynamicaly remap the colors without me having to make a lot of gif images of the same thing with different colors. More specificly perhaps, what I'm trying to do is within the palette I have say index 46, 47, 48, 49, 50, 51, 52, and 53,
    within the specified area i want to swap the rgb values of the afore-mentioned palette to say 146, 147, 148, 149, 150, 151, 152, and 153. If I were using python I'd be able to use getpixel and putpixel, but that doesn't seem to have an equivelent in c++. I'm not trying to write the file or reinvent the gif, all I need to do is load the gif and remap the colors, something people have been doing for years. If my super-nintendo games can do it, i'm sure c++ can. I just haven't a clue how to do it.

  4. #4
    Join Date
    Dec 2003
    one last question, is it a gui app that uses the built in things to display an image or can you actually get to the rgb array? If you can get to the rgb array directly, its going to be very easy. If not, it may be fairly difficult.

    *Hopefully you decompress the gif yourself into a simple rgb array*

  5. #5
    Join Date
    Jan 2008
    it is a gui app on a win32 platform, though currently I'm not using any form of descriptor for the gif. The ability to read it and put the image in form of a string of arrays is something i don't have at the moment, though it would certianly make it easier and is rather difficult for me to figure out how to acheive this goal.

  6. #6
    Join Date
    Dec 2003
    If possible that is where I would start. First make sure your tool cannot do what you want (the library that you use to open gif and display it.)

    If that tool cannot do what you need, lose it and try this:
    Open the file and extract the data into an rgb or rgba array. Its actually best to use a single dimensional array of bytes for this, usually. You can try 2d but the micro management gets old fast. Once you have that, use bitblt to display it in your program, and then we can play with the colors (it will be easy now!).

Similar Threads

  1. Replies: 1
    Last Post: 03-01-2006, 12:00 AM
  2. Access Castor mapping file in a different jar
    By tarun.arora in forum XML
    Replies: 0
    Last Post: 02-15-2006, 11:06 PM
  3. How to make a floating tool palette
    By Wesley Long in forum VB Classic
    Replies: 2
    Last Post: 10-18-2002, 12:35 PM
  4. mapping datatype to control
    By sbtw in forum VB Classic
    Replies: 0
    Last Post: 09-28-2000, 12:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center