Printing plette

This is a discussion on Printing plette within the Game Programming forums, part of the General Programming Boards category; When I've loaded an image I'm having difficulties to print the palette of it. Here's what I've done so far: ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    129

    Printing plette

    When I've loaded an image I'm having difficulties to print the palette of it. Here's what I've done so far:

    Code:
    PAL_START_X = 510,
    PAL_START_Y = 10,
    PAL_SCALE = 8,
    PAL_COLS = 16,
    PAL_ROWS = 16,
    
    ...
    	/*	Set the best color depth that we can find	*/
    	set_color_depth(16);
    	if(set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0) != 0)
    	{
    		set_color_depth(15);
    		if(set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0) != 0)
    		{
    			set_color_depth(32);
    			if(set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0) != 0)
    			{
    				set_color_depth(24);
    				if(set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0) != 0)
    				{
    					allegro_exit();
    					printf("Error setting graphics mode\n%s\n\n", allegro_error);
    					exit(1);
    				}
    			}
    		}
    	}
    
    	set_color_conversion(COLORCONV_TOTAL);
    ...
    	PALLETE pal;
    	BITMAP *bm = load_bitmap("foo.pcx", pal);
    	if(!bm)
    		exit(1);
    	get_palette(pal);
    	set_palette(pal);
    	print_palette(pal);
    	print_palette(pal);
    ...
    void print_palette(const PALLETE pal)
    {
    	int color = 0;
    	/*	Those `-1's are because the outline of that rectangle would go over what
    		is needed	*/
    	for(int j = 0;  j < PAL_ROWS;  j++)
    		for(int i = 0;  i < PAL_COLS;  i++, color++)
    		{
    			rectfill(screen, PAL_START_X+i*PAL_SCALE, PAL_START_Y+j*PAL_SCALE,
    			PAL_START_X+i*PAL_SCALE+PAL_SCALE-1,
    			PAL_START_Y+j*PAL_SCALE+PAL_SCALE-1,
    			makecol(pal[color].r, pal[color].g, pal[color].b));
    		}
    }
    This supposed to print palette while one color takes 8*8 pixels and as 16*16 table. However, even when I only load 211 color picture my palette prints out all wrong.
    kooma - t.h@iki.fi

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    129
    And heres the file. Oh, and this needs allegro to compile...
    Attached Files Attached Files
    kooma - t.h@iki.fi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C# Printing Problem
    By silverlight001 in forum C# Programming
    Replies: 0
    Last Post: 03-23-2009, 02:13 AM
  2. Printing Lines to .txt File
    By Programmer3922 in forum C Programming
    Replies: 2
    Last Post: 08-02-2008, 01:45 PM
  3. generic printing preferences dialog box
    By stanlvw in forum Windows Programming
    Replies: 8
    Last Post: 06-27-2008, 03:20 AM
  4. printing data to a file
    By coralreef in forum C Programming
    Replies: 3
    Last Post: 11-02-2006, 08:10 PM
  5. need help relating printing?
    By omarlodhi in forum Linux Programming
    Replies: 0
    Last Post: 03-03-2006, 04:46 AM

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