Puzzled: could someone give me a brief lesson on PALETTE? 
Author Message
 Puzzled: could someone give me a brief lesson on PALETTE?

        In my numerous and asundry adventures in QB programming, I have
just recently ventured into the deeper realms of graphics porogramming.
Most of it is pretty straight-forward, but I'm still puzzled by some
things. Primarily, what the heck does PALETTE do? The QB help section
isn't helpful, and I've tried looking at source code, but that didn't
help much either. So if any experienced user would care to give an
in-depth explanation on the finer point of setting the PALETTE, I would
appreciate any help.
        While I'm at it, I should probably explain what I'm thinking of.
While looking through the ABC packets, I came across a lot of code for
bitmaps and PCX viewers. Unfortunately, they were all fairly slow, and
complicated at that. So I thought: Why not come up with a very simple
graphics format? Each byte would hold two colors: the first four bits
would represent one, the last four bits the other. That would give me a
total of 16 colors to work with. But I would like the format to be
flexible, so it would be nice to change the palette; one file could be
all gray-scale, for example, while another could be pastels. You get the
idea. But as I said before, I'm rather new at this graphics business, so
I have no idea how to set the palette. Also, is this even a good idea?
Is BLOAD the fastest option there is? It's just that I really hate using
BLOAD (again, lack of experience and uncertainty as to what in the heck
I'm doing) and would just like to have some graphics option that is
super-fast (I'm thinking about doing an over-head RPG), easy, and
flexible. Comments, suggestions welcomed. No dirty jokes.
        Peter

 _____

   |__/        
 / |eter        
 | |              
 \___lark      



Tue, 06 Jul 1999 03:00:00 GMT  
 Puzzled: could someone give me a brief lesson on PALETTE?



Peter,

An on-the-fly, in a nutshell  answer is this:

Basic has a default set of  colors in its palette. if my memory
serves me correct, the first nine default colors are:
0=black; 1=blue; 2=green; 3=cyan; 4=red; 5=magenta; 6=gold;
7=light gray; 8=dark gray

depending on the screen mode, there may be up to 256 colors in the
palette for that screen mode. you can look them up. the point is,
each default palette contains a series of colors assigned to a
series of numbers. i believe Basic refers to these series of
numbers as attributes.

the PALETTE statement lets you reassign those colors with colors
of your choice. the trick is calculating the values to subsequently
assign to the attributes.

Basic has its own way of representing a color. a color in Basic is
the sum of 3 values, calculated thusly:

colorValue = BlueIntensity * 65536 + GreenIntensity * 256 + RedIntensity

where any of the three  intensities are numbers in the set [0, 63]
This results in a maximum possiblity of 64^3 colors which amounts to
256K colors.

In screen mode 13, you can create and assign up to 256 of these color
values and assign them to be used in the program. In screen mode 12,
you can only create and assign 16 color values. (A pity, since screen
mode 12 is much higher resolution, but thats the way it is.)

It is impossible for me to go much deeper than this in a mere article
reply, and I am spewing all this at you from memory. But you can try
this for starters:

'' grays.bas
DIM pal&(0 TO 255)
SCREEN 13
CLS
FOR i& = 0 TO 63
  pal&(i&) = i& * (65536 + 256 + 1)
NEXT i&
PALETTE USING pal&(0)
FOR attrib& = 0 TO 255
  COLOR attrib&
  PRINT STRING$(2, CHR$(219));
NEXT attrib&
'' end of grays.bas

Each pair of characters printed should represent a different
shade of gray. i and attrib may not need to be long integers,
but i didnt want to chance offering you an overflow or out of
range problem. I hope this helps you with  what the Basic
PALETTE statement does.

cheers,
Randy

Quote:
>    In my numerous and asundry adventures in QB programming, I have
>just recently ventured into the deeper realms of graphics porogramming.
>Most of it is pretty straight-forward, but I'm still puzzled by some
>things. Primarily, what the heck does PALETTE do? The QB help section
>isn't helpful, and I've tried looking at source code, but that didn't
>help much either. So if any experienced user would care to give an
>in-depth explanation on the finer point of setting the PALETTE, I would
>appreciate any help.
>    While I'm at it, I should probably explain what I'm thinking of.
>While looking through the ABC packets, I came across a lot of code for
>bitmaps and PCX viewers. Unfortunately, they were all fairly slow, and
>complicated at that. So I thought: Why not come up with a very simple
>graphics format? Each byte would hold two colors: the first four bits
>would represent one, the last four bits the other. That would give me a
>total of 16 colors to work with. But I would like the format to be
>flexible, so it would be nice to change the palette; one file could be
>all gray-scale, for example, while another could be pastels. You get the
>idea. But as I said before, I'm rather new at this graphics business, so
>I have no idea how to set the palette. Also, is this even a good idea?
>Is BLOAD the fastest option there is? It's just that I really hate using
>BLOAD (again, lack of experience and uncertainty as to what in the heck
>I'm doing) and would just like to have some graphics option that is
>super-fast (I'm thinking about doing an over-head RPG), easy, and
>flexible. Comments, suggestions welcomed. No dirty jokes.
>    Peter

> _____

>   |__/            
> / |eter    
> | |                  
> \___lark  



Wed, 07 Jul 1999 03:00:00 GMT  
 Puzzled: could someone give me a brief lesson on PALETTE?

Please, don't use PALETTE to change VGA RGB values.  It is
extremely slow.  Use this way simpler and easier to understand
piece of code rather than PALETTE.

OUT &H3C8, TheColor%  'What color you want to alter.
OUT &H3C9, REDLEVEL%  'Red's light level (0-63)
OUT &H3C9, GREENLEVEL%  'Green's light level (0-63)
OUT &H3C9, BLUELEVEL%  'Blue's light level (0-63)

Mike



Sun, 11 Jul 1999 03:00:00 GMT  
 Puzzled: could someone give me a brief lesson on PALETTE?

All,
        There are a few bits and pieces on tutorials (plus a large
section on it) in the Basix Fanzine (issue 6 or 7 I believe).. To get
the fanzine:

        http://www.trenham.demon.co.uk/fanzine/

Cheers,
--
Peter Cooper



Sun, 25 Jul 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Give me a little COM lesson :-)

2. Palette problems in vb can someone help

3. Could someone please give me a simple example...

4. Can someone give me...

5. If everyday I needed to give someone a wake up call

6. Maybe Someone can give me a hand????

7. Could someone give me an idea about doing VB and Oracle

8. Giving my program to someone without VB 5.O

9. Could someone give me a hand at this??

10. Could someone give me some API names

11. New Word FAQ site - brief FAQ

12. *BRIEF* stupid ADO question

 

 
Powered by phpBB® Forum Software