NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/46189: wsfb/genfb red and blue colours are reversed on bit depths 15 16 24 and 32



The following reply was made to PR kern/46189; it has been noted by GNATS.

From: Nat Sloss <nathanialsloss%yahoo.com.au@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/46189: wsfb/genfb red and blue colours are reversed on bit 
depths 15 16 24 and 32
Date: Wed, 25 Apr 2012 23:16:22 +1000

 Hi.
 
 I have written a little curses colour bar program, and I thought it would 
 assist with testing:
 
 #include <curses.h>
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <sys/time.h>
 #include <sys/types.h>
 
 main() {
        char colourNames[8][8] = {
            {"Black  "},
            {"Red    "},
            {"Green  "},
            {"Yellow "},
            {"Blue   "},
            {"Magenta"},
            {"Cyan   "},
            {"White  "}
        };
 
        int colourOK;
        int colour, line, spacing, xpos, offsetx, labeloffsety, labeloffsetx; 
        int numcolours = 8;
        int labelwidth = 8;
 
        initscr();
        colourOK = has_colors();
        spacing = COLS / numcolours;
        offsetx = (COLS - (spacing * numcolours)) / 2;
        labeloffsetx = spacing / 2;
        labeloffsety = (LINES - 1 - labelwidth) / 2;
 
        if (COLS < 45 || LINES < 10) {
                endwin();
                printf("\nTerminal size must be at least 45x10.");
                printf("\n");
                return;
        }
 
        if (colourOK) {
                start_color();
  
                init_pair( 0, COLOR_WHITE, COLOR_BLACK );
                init_pair( 1, COLOR_WHITE, COLOR_RED );
                init_pair( 2, COLOR_WHITE, COLOR_GREEN );
                init_pair( 3, COLOR_WHITE, COLOR_YELLOW );
                init_pair( 4, COLOR_WHITE, COLOR_BLUE );
                init_pair( 5, COLOR_WHITE, COLOR_MAGENTA );
                init_pair( 6, COLOR_WHITE, COLOR_CYAN );
                init_pair( 7, COLOR_WHITE, COLOR_WHITE );
        }
 
        clear();
 
        move(0, 0);
 
        for (colour = COLOR_BLACK; colour < numcolours; colour++) {
                if (colourOK)
                        attrset(COLOR_PAIR(colour));
                for (line = 0; line < LINES - 1; line++) {
                        for (xpos = (spacing * colour); xpos < (spacing       \
                            * (colour + 1)); xpos++) 
                                mvprintw(line, xpos + offsetx, " ");
                }
 
                if (colourOK)
                        attrset(COLOR_PAIR(0));
                for (line = labeloffsety; line < labeloffsety + labelwidth; \
                    line++) {
                        if (colourNames[colour][line - labeloffsety] != ' ')
                                mvprintw(line, (spacing * colour) + offsetx \
                                    + labeloffsetx, "%c",                   \
                                    colourNames[colour][line - labeloffsety]);
                }
        }
 
        if (colourOK)
                attrset(COLOR_PAIR(0));
        mvprintw(LINES - 1, 0, "ANSI Colour chart - Press any key to exit: ");
         refresh();
 
        getch();
 
        endwin();
 
        return;
 }
 
 Maybe it's a fun one to add to the games collection.
 
 I hope this helps.
 
 Regards,
 
 Nat.
 
 PS: No sooner did i write this email that I realize that some of the included 
 files are not necessary.  Nevertheless it will compile and demonstrate the 
 reversed colours with genfb.
 


Home | Main Index | Thread Index | Old Index