Question on 256 color allegro dos stuff

This is a discussion on Question on 256 color allegro dos stuff within the C Programming forums, part of the General Programming Boards category; BACKGROUND INFORMATION: Hi, I wrote a function that takes an rgb value, finds an un-used palette color and sets that ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    140

    Question on 256 color allegro dos stuff

    BACKGROUND INFORMATION:
    Hi, I wrote a function that takes an rgb value, finds an un-used palette color and sets that color to the specified rgb value then returns the color that it set, once it has set a certain color to a value it marks it as "USED" so that it wont be re-set to something else on further calls to the function. I also wrote a function which goes through the screen too try too free up some colors that were marked as "USED" but are no longer in use.

    THE QUESTION:
    Is there a faster way too free un-used colors, my way is pretty slow. I go pixel by pixel checking.

    thanks

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    What determines whether a colour is "unused"?

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    140
    an array with 256 elements, marked either 1 or 0, used or un used.
    Acos is good

  4. #4
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    No, I mean what affects whether a colour is no longer used/on the screen.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    140
    If they are on the screen, lets say I drew 3 pixels, red, blue, and white, if they were the first things to be drawn, then the first 3 elements of the array would be marked as used. Now, lets say a red rectangle were to draw over the white pixel, the FreeColors() function would notice that the white pixel is no longer on the screen and mark the point in the array that was marked used, as un-used. Basically if it is currently on the screen.
    Right now Im not worrying about other bitmaps or anything.
    Acos is good

  6. #6
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    You could create an array of ints that count each colour when it's plotted, then when you draw something over an existing colour, increment the array for each colour that is drawn and decrement this for each pixel that is drawn over. If any colour reaches zero then it can be marked as unused. That way you're only checking the areas that you're drawing rather than the whole screen.

    I think it would depend on how much of the screen was being re-drawn and how many times colours were repeated as to whether this would be any faster, though.

  7. #7
    Registered User
    Join Date
    Sep 2001
    Posts
    140
    hmmm, Ill try that.

    thanks
    Acos is good

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what does this warningmean???
    By kreyes in forum C Programming
    Replies: 5
    Last Post: 03-04-2002, 06:53 AM
  2. Question about efficiency... structures and stuff
    By rmullen3 in forum C++ Programming
    Replies: 2
    Last Post: 01-05-2002, 12:00 PM
  3. assembler and linker stuff...question
    By dirkduck in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 12-16-2001, 11:10 PM
  4. a question on server stuff
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 10-05-2001, 02:54 PM
  5. quick question about C Dos text menu pgm i was doing
    By Shadow in forum C Programming
    Replies: 2
    Last Post: 09-16-2001, 10:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21