LECTURE 3 ¹õ¡¢Çò°Ê³°¤Î¿§¤ò»È¤¦

¡û ¤Ï¤¸¤á¤Ë

LECTURE 1 ¤Î xwin.c ¤Ç¥¦¥£¥ó¥É¥¦¤òɽ¼¨¤·¤¿ºÝ¤Ë¡¢¥Ü¡¼¥À¤Î¿§¤È¥¦¥£¥ó¥É¥¦¤ÎÇØ·Ê¿§¤Ë¤½¤ì¤¾¤ì¹õ¤ÈÇò¤Î¥Ô¥¯¥»¥ëÃͤòÀßÄꤷ¤Þ¤·¤¿¡£¤³¤Î¤è¤¦¤Ë¡¢¿§¤òÀßÄꤹ¤ë»þ¤Ë¤Ï¥Ô¥¯¥»¥ëÃͤò»È¤¤¤Þ¤¹(¥Ô¥¯¥»¥ëÃͤˤĤ¤¤Æ¤Ï LECTURE 2 ¤ÇÀâÌÀ¤·¤Þ¤·¤¿)¡£¹õ¤ÈÇò¤Î¥Ô¥¯¥»¥ëÃͤˤĤ¤¤Æ¤Ï¡¢¥Ç¥£¥¹¥×¥ì¥¤¥Þ¥¯¥í

black = BlackPixel( dpy, screen );
white = WhitePixel( dpy, screen );

¤ò»È¤Ã¤Æ¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤·¤Þ¤·¤¿¡£¤Ç¤Ï¡¢Â¾¤Î¿§¤ò»È¤¤¤¿¤¤¾ì¹ç¤Ë¤Ï¤É¤Î¤è¤¦¤Ë¤·¤Æ¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤¹¤ë¤Î¤Ç¤·¤ç¤¦¤«? ¤³¤³¤Ç¤Ï¡¢¤½¤ÎÊýË¡¡¢¤ª¤è¤Ó¿§´ØÏ¢¤Î¤¤¤¯¤Ä¤«¤Î´Ø¿ô¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à(¿§Ì¾¤ò»ØÄꤷ¤Æ¥Ô¥¯¥»¥ëÃͤò¼èÆÀ)

¥¦¥£¥ó¥É¥¦¤ÎÇØ·Ê¿§¤òÎп§¤Ë¤·¤Æɽ¼¨¤¹¤ë¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à xcolor.c ¤Ç¤¹¡£xwin.c ¤ò´ðËܤȤ·¤Æ¡¢É¬Íפʽ¤Àµ¤ò²Ã¤¨¤Æ¤¤¤Þ¤¹¡£¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤«¤é¡¢Á´¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò¸Ç¤á¤¿ tar ¥Ü¡¼¥ë¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£

xwin.c ¤Î»þ¤ÈƱÍͤ˥³¥ó¥Ñ¥¤¥ë¤·¤Æ¼Â¹Ô¤¹¤ë¤È¡¢Î理òÇØ·Ê¿§¤È¤·¤Æ¥¦¥£¥ó¥É¥¦¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£²¿¤«¥­¡¼¤ò²¡¤¹¤È¥×¥í¥°¥é¥à¤¬½ªÎ»¤·¤Þ¤¹¡£

003color.jpg

--- xcolor.c ---

    1	#include <X11/Xlib.h>
    2	
    3	#define WIN_W  400  /* ¥¦¥£¥ó¥É¥¦¤ÎÉý   */
    4	#define WIN_H  300  /* ¥¦¥£¥ó¥É¥¦¤Î¹â¤µ */
    5	#define WIN_X  100  /* ¥¦¥£¥ó¥É¥¦É½¼¨°ÌÃÖ(X) */
    6	#define WIN_Y  100  /* ¥¦¥£¥ó¥É¥¦É½¼¨°ÌÃÖ(Y) */
    7	#define BORDER 2    /* ¥Ü¡¼¥À¤ÎÉý      */
    8	
    9	
   10	int 
   11	main( void )
   12	{
   13		Display*       dpy;          /* ¥Ç¥£¥¹¥×¥ì¥¤ */
   14		Window         root;         /* ¥ë¡¼¥È¥¦¥£¥ó¥É¥¦ */
   15		Window         win;          /* ɽ¼¨¤¹¤ë¥¦¥£¥ó¥É¥¦ */
   16		int            screen;       /* ¥¹¥¯¥ê¡¼¥ó */
   17		unsigned long  black, white; /* ¹õ¤ÈÇò¤Î¥Ô¥¯¥»¥ëÃÍ */
   18		XEvent         evt;          /* ¥¤¥Ù¥ó¥È¹½Â¤ÂÎÊÑ¿ô */
   19	
   20		Colormap       cmap;         /* ¥«¥é¡¼¥Þ¥Ã¥× */
   21		XColor         color, exact; 
   22		unsigned long  green;        /* ÎФΥԥ¯¥»¥ëÃÍ */
   23	
   24	
   25		/* X¥µ¡¼¥Ð¤ÈÀܳ¤¹¤ë */
   26		dpy = XOpenDisplay( "" );
   27	
   28	
   29		/* ¥Ç¥£¥¹¥×¥ì¥¤ÊÑ¿ô¤Î¼èÆÀ */
   30		root   = DefaultRootWindow( dpy );
   31		screen = DefaultScreen( dpy );
   32	
   33	
   34		/* XAllocNamedColor() ¤Î¤¿¤á¤Ë¥«¥é¡¼¥Þ¥Ã¥×¤ò¼èÆÀ */
   35		cmap   = DefaultColormap( dpy, screen ); 
   36	
   37	
   38		/* Çò¡¢¹õ¤Î¥Ô¥¯¥»¥ëÃͤò¼èÆÀ */
   39		white  = WhitePixel( dpy, screen );
   40		black  = BlackPixel( dpy, screen );
   41	
   42	
   43		/* Îп§¤Î¥Ô¥¯¥»¥ëÃͤò¼èÆÀ */
   44		XAllocNamedColor( dpy, cmap, "green", &color, &exact );
   45		green = color.pixel;
   46	
   47	
   48		/* ¥¦¥£¥ó¥É¥¦¤òºîÀ®¤¹¤ë¡£¤³¤Î»þÅÀ¤Ç¤Ï¤Þ¤À²èÌ̤Ëɽ¼¨¤µ¤ì¤Ê¤¤¡£*/
   49		win = XCreateSimpleWindow( dpy, root,
   50			   WIN_X, WIN_Y, WIN_W, WIN_H, BORDER, black, green );
   51	
   52	
   53		/* X¥µ¡¼¥Ð¤«¤éÄÌÃΤ·¤Æ¤â¤é¤¦¥¤¥Ù¥ó¥È¤ò»ØÄê
   54		   ¤³¤³¤Ç¤Ï¥­¡¼²¡²¼¥¤¥Ù¥ó¥È¤òÁªÂò¤·¤Æ¤¤¤ë */
   55		XSelectInput( dpy, win, KeyPressMask );
   56	
   57	
   58		/* ¥¦¥£¥ó¥É¥¦¤ò²èÌ̤Ëɽ¼¨¤¹¤ë(¥Þ¥Ã¥×¤¹¤ë)¡£ */
   59		XMapWindow( dpy, win );
   60	
   61	
   62		/* X¥µ¡¼¥Ð¤«¤é¥¤¥Ù¥ó¥È¤òÆɤߤ³¤ó¤Ç¿ï»þ½èÍý¤·¤Æ¤¤¤¯¥¤¥Ù¥ó¥È¥ë¡¼¥× */
   63		while( 1 ) {
   64			XNextEvent( dpy, &evt );
   65	
   66			switch ( evt.type ) {
   67				case KeyPress:
   68					/* ¥ê¥½¡¼¥¹¤Î²òÊü */
   69					XDestroyWindow( dpy, win );
   70					XCloseDisplay( dpy );
   71					return 0;
   72			}
   73		}
   74	}
   75	
   76	/* End of xcolor.c */

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÀâÌÀ

¤Ç¤Ï¡¢¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£xwin.c ¤ÈƱ¤¸²Õ½ê¤Ë¤Ä¤¤¤Æ¤Ï¡¢ÀâÌÀ¤ò¾Êά¤·¤Þ¤¹¡£

  • 20 ¡Á 22 ¹ÔÌÜ

    º£²ó¿·¤·¤¯Äɲäˤʤä¿ÊÑ¿ô¤Ç¤¹¡£¤¤¤º¤ì¤â¡¢¹õ¡¢Çò°Ê³°¤Î¿§¤ò»ØÄꤷ¤Æ¼èÆÀ¤¹¤ë¤¿¤á¤ËɬÍ× ¤ÊÊÑ¿ô¤Ç¤¹¡£Colormap ·¿¤Ï¡¢LECTURE 2 ¤ÇÀâÌÀ¤·¤¿¥«¥é¡¼¥Þ¥Ã¥×¤òɽ¤¹ÊÑ¿ô·¿¡¢XColor ·¿¤Ï ¿§¤Î RGB Ãͤä¥Ô¥¯¥»¥ëÃͤ¬³ÊǼ¤µ¤ì¤ëÊÑ¿ô·¿¤Ç¤¹¡£unsigned long ·¿¤Î green ¤Ï¡¢ÇØ·Ê¿§¤ò »ØÄꤹ¤ë¤¿¤á¤Î¥Ô¥¯¥»¥ëÃͤò³ÊǼ¤¹¤ë¤¿¤á¤ÎÊÑ¿ô¤Ç¤¹¡£

  • 34 ¡Á 35 ¹ÔÌÜ

    ¼¡¤ÇÀâÌÀ¤¹¤ë XAllocNamedColor() ¤Ç»ÈÍѤ¹¤ë¤¿¤á¤Ë¡¢¥«¥é¡¼¥Þ¥Ã¥×¤Î ID ¤ò¥Ç¥£¥¹¥×¥ì¥¤¥Þ ¥¯¥í DefaultColormap ¤Ç¼èÆÀ¤·¤Æ¤¤¤Þ¤¹¡£

  • 43 ¡Á 45 ¹ÔÌÜ

    ¤³¤³¤¬º£²ó¤Î¥á¥¤¥ó¤È¤Ê¤ë²Õ½ê¤Ç¡¢"green" ¤È¤¤¤¦¿§Ì¾¤ÇÎ理ò»ØÄꤷ¡¢¤½¤Î¿§¤ËÂбþ¤¹¤ë¥Ô ¥¯¥»¥ëÃͤò¼èÆÀ¤·¤ÆÊÑ¿ô green ¤Ë³ÊǼ¤·¤Æ¤¤¤Þ¤¹¡£

    ¿§Ì¾¤ò»ØÄꤷ¤ÆÂбþ¤¹¤ë¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤¹¤ë¤Ë¤Ï¡¢´Ø¿ô XAllocNamedColor() ¤ò»È¤¤¤Þ¤¹¡£

      Status XAllocNamedColor( Display* display, 
                               Colormap colormap,
                               char*    color_name, 
                               XColor*  screen_def_return,
                               XColor*  exact_def_return
                             );
    
      colormap          : »ÈÍѤ¹¤ë¥«¥é¡¼¥Þ¥Ã¥×¤Î ID
      color_name        : ¥Ô¥¯¥»¥ëÃͤòÃΤꤿ¤¤¿§¤Î̾Á°
      screen_def_return : ¥¹¥¯¥ê¡¼¥ó¤Ëɽ¼¨²Äǽ¤Ê¡¢»ØÄ꿧̾¤ËºÇ¤â¶á¤¤¿§¾ðÊó
      exact_def_return  : ¥Ç¡¼¥¿¥Ù¡¼¥¹¾å¤ÎÀµ³Î¤Ê¿§¾ðÊó
    
    

    color_name ¤Ë»ØÄê¤Ç¤­¤ë̾Á°¤Ï¿§¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹( /usr/lib/X11/rgb.txt )¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë ̾Á°¤Ç¤¹( kterm ¤Ê¤É¤Ç showrgb ¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤¹¤ë¤È¡¢ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë̾Á°¤ò±ÜÍ÷¤¹¤ë¤³¤È ¤¬¤Ç¤­¤Þ¤¹)¡£¥¹¥¯¥ê¡¼¥ó¤Ëɽ¼¨²Äǽ¤Ç¤¢¤ê¡¢¤«¤Ä»ØÄꤷ¤¿¿§Ì¾¤ËºÇ¤â¶á¤¤¿§¤Î RGB Ãͤȥԥ¯ ¥»¥ëÃͤ¬ XColor ¹½Â¤ÂÎÊÑ¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿ screen_def_return ¤¬¼¨¤¹Îΰè¤Ë³ÊǼ¤µ¤ì¤Þ¤¹¡£

      typedef struct {
          unsigned long  pixel;            /* ¿§¤Î¥Ô¥¯¥»¥ëÃÍ */
          unsigned short red, green, blue; /* ¿§¤ÎRGBÃÍ */
          char     flags;                  /* DoRed¡¢DoGreen¡¢DoBlue */
      } XColor;  
    
    

    red¡¢green¡¢blue ¤Ë¤Ï¿§¤Î RGB Ãͤ¬Æþ¤ê¡¢pixel ¤Ë¤Ï¤½¤Î RGB ÃͤËÂбþ¤¹¤ë¥Ô¥¯¥»¥ëÃͤ¬ ³ÊǼ¤µ¤ì¤Þ¤¹¡£flags ¤Ë¤Ï red¡¢green¡¢blue ¤Î¤¦¤Á¤É¤ì¤ËÃͤòÀßÄꤷ¤¿¤«¤¬³ÊǼ¤µ¤ì¤Þ¤¹¡£ exact_def_return ¤Ë¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÀµ³Î¤Ê RGB Ãͤ¬³ÊǼ¤µ¤ì¤Þ¤¹¡£ colormap ¤Ï¥«¥é¡¼¥Þ¥Ã¥× ID ¤ò»ØÄꤷ¤Þ¤¹¤¬¡¢Ä̾ï¤Ï¥Ç¥£¥¹¥×¥ì¥¤¥Þ¥¯¥í DefaultColormap ¤Ç¼èÆÀ¤·¤¿¥Ç¥Õ¥©¥ë¥È¤Î¥«¥é¡¼¥Þ¥Ã¥×¤ò»ØÄꤷ¤Þ¤¹¡£

    XAllocNamedColor() ¤Ï¡¢¥«¥é¡¼¥Þ¥Ã¥×¾å¤Ë¥«¥é¡¼¥»¥ë¤ò³ä¤êÅö¤Æ¤ë¤³¤È¤¬½ÐÍ褿¾ì¹ç(»ØÄê ¤·¤¿¿§¤¬»ÈÍѲÄǽ¤Ç¤¢¤ë)¤Ë¤Ï 0 ¤Ç¤Ê¤¤ÃͤòÊÖ¤·¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð 0 ¤òÊÖ¤·¤Þ¤¹ ( Status ·¿¤Ï #define Status int ¤È¤·¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹)¡£

  • 48 ¡Á 50 ¹ÔÌÜ

    XCreateSimpleWindow() ¤Ç¥¦¥£¥ó¥É¥¦¤òºîÀ®¤·¤Æ¤¤¤Þ¤¹¤¬¡¢ÇØ·Ê¿§¤Î»ØÄêÍѤΰú¿ô¤ËÀèÄø¼è ÆÀ¤·¤¿Îп§¤Î¥Ô¥¯¥»¥ëÃÍ ( green ) ¤ò»ØÄꤷ¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ë¤è¤Ã¤Æ¡¢ÇØ·Ê¿§¤¬Îп§¤Ç¤¢¤ë ¥¦¥£¥ó¥É¥¦¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£

°Ê¾å¤Ç xcolor.c ¤Î²òÀâ¤Ï½ª¤ï¤ê¤Ç¤¹¡£xcolor.c ¤Ç¤Ï¡¢¿§Ì¾¤ò»ØÄꤹ¤ë¤³¤È¤Ë¤è¤Ã¤Æ´õ˾¤Î¿§¤Î¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤·¤Þ¤·¤¿¤¬¡¢¤³¤Î¾¤Ë¤â RGB Ãͤò»ØÄꤹ¤ë¤³¤È¤Ç¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£¤Þ¤¿¡¢¿§Ì¾¤ËÂбþ¤¹¤ë RGB ÃͤòÌ䤤¹ç¤ï¤»¤¿¾å¤Ç¤½¤Î RGB Ãͤò»ØÄꤷ¤Æ¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤¹¤ë¤È¸À¤¦ÊýË¡¤â¤¢¤ê¤Þ¤¹¡£¤³¤ì¤é¤Ë¤Ä¤¤¤Æ°Ê¹ß¤ÇÀâÌÀ¤·¤Þ¤¹¡£

¡û RGB Ãͤò»ØÄꤷ¤Æ¥Ô¥¯¥»¥ëÃͤò¼èÆÀ

xcolor.c ¤Ç¤Ï¡¢XAllocNamedColor() ¤Ë¤è¤Ã¤Æ¿§Ì¾¤ò»ØÄꤷ¤Æ¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤·¤Þ¤·¤¿¡£¤½¤ì¤ËÂФ·¤Æ¡¢RGB Ãͤò»ØÄꤷ¤Æ¤½¤ì¤ËÂбþ¤¹¤ë¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£¤³¤Î¾ì¹ç¤Ë¤Ï XAllocColor() ¤ò»È¤¤¤Þ¤¹¡£

Status XAllocColor( Display* display, Colormap colormap, XColor* screen_in_out );

¼èÆÀ¤·¤¿¤¤¿§¤Î RGB Ãͤò screen_in_out->red¡¢screen_in_out->green¡¢screen_in_out->blue ¤Î¤½¤ì¤¾¤ì¤ËÀßÄꤷ¤Æ¼Â¹Ô¤·¤Þ¤¹¡£RGB ÃÍ¤Ï 4 ·å¤Î 16 ¿Ê¿ô¤Ç»ØÄꤷ¤Þ¤¹¡£Î㤨¤ÐÀÖ¤ò»ØÄꤷ¤¿¤¤¤È¤­¤Ë¤Ï

screen_in_out->red   = 0xffff;
screen_in_out->green = 0x0;
screen_in_out->blue  = 0x0;

¤È¤·¤Þ¤¹¡£¤Þ¤¿¡¢XAllocColor() ¤Î¾ì¹ç¤Ï XColor ¹½Â¤ÂΤΠflags ¥á¥ó¥Ð¤Ï»ÈÍѤµ¤ì¤Þ¤»¤ó¡£

¤Ê¤ª¡¢ 4 ·å̤Ëþ¤Î¿ô¤ò»ØÄꤷ¤¿¾ì¹ç¤Ï¤½¤ÎÃͤ¬ÀßÄꤵ¤ì¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¤Î¤ÇÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤(Î㤨¤Ð 0xa ¤ò»ØÄꤷ¤¿¾ì¹ç¡¢0xffff ¤Î 10/15 ÈÖÌܤÎÃÍ¡¢¤¹¤Ê¤ï¤Á 0xaaaa ¤òɽ¤¹¤È¥Þ¥Ë¥å¥¢¥ë¤Ë½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢¤½¤ì°Ê³°¤ÎÍÍ¡¹¤Ê¥±¡¼¥¹¤ËÂФ·¤Æ¤É¤¦¤Ê¤ë¤Î¤«Ëͼ«¿È¤ÏÎɤ¯Ê¬¤«¤Ã¤Æ¤¤¤Þ¤»¤óm(__)m)¡£

¾åµ­¤ÎÂǤÁ¾Ã¤·ÀþÉôʬ¤ÎÆâÍƤˤĤ¤¤Æ¡¢ÀèÆüÄ̤ꤹ¤¬¤ê¤µ¤ó¤«¤é "¤½¤ì¤Ï¤Ä¤Þ¤ê¡¢RGBÃͤϡ¢¾¯¤Ê¤¯¤È¤â0x1000¤Î¿ôÃͤò»ý¤Ã¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¤È¤¤¤¦¤³¤È¤À¤í¤¦¤«¡£" ¤È¤¤¤¦¤´°Õ¸«¥á¡¼¥ë¤ò¤¤¤¿¤À¤­¤Þ¤·¤¿¡£¤½¤ì¤Çµ×¤·¤Ö¤ê¤ËËÜ¥Ú¡¼¥¸¤ò¼«Ê¬¤ÇÆɤó¤Ç¤ß¤¿¤Î¤Ç¤¹¤¬¡¢¤¹¤ß¤Þ¤»¤ó¡¢¼«Ê¬¤Ç½ñ¤¤¤Æ¤¤¤ëÆâÍƤΰÕÌ£¤¬¤è¤¯Ê¬¤«¤ê¤Þ¤»¤ó¡Ä

²¿¤Î¥Þ¥Ë¥å¥¢¥ë¤À¤«ËܤÀ¤«¤òÆɤó¤À¤Î¤«³Ð¤¨¤Æ¤¤¤Ê¤¤¤Î¤Ç¤¹¤¬¡¢º£¹Í¤¨¤ëʬ¤Ë¤Ï X ¤Î RGB ÈÏ°Ï 0 ¡Á 0xffff¡Ê65535¡Ë¤òǤ°Õ¤Ë»ØÄꤷ¤ÆÎɤµ¤½¤¦¤Êµ¤¤¬¤·¤Þ¤¹¡£¼ÂºÝ LECTURE 17 DIB ( Device-Independent Bitmap ) ¤Îɽ¼¨ ¤Ç¤Ï¡¢¾åµ­¤ÎÍͤÊÀ©¸Â¤Ï²¿¤â¹Í¤¨¤º¤Ë XAllocColor() ¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡Ä

¤³¤³¤Ç¤Ï "¼èÆÀ¤·¤¿¤¤¿§¤Î RGB Ãͤò X ¤Î RGB ÈÏ°Ï 0 ¡Á 0xffff (65535) ¤ÎÈϰϤǻØÄꤹ¤ë" ¤ÈÄûÀµ¤·¤¿¤¤¤È»×¤¤¤Þ¤¹¡£¤â¤·¤³¤Îɽ¸½¤¬´Ö°ã¤Ã¤Æ¤¤¤Æ¡¢Àµ¤·¤¤ÆâÍƤò¤´Â¸ÃΤÎÊý¤Ë¤³¤Îʸ½ñ¤ò¸«¤Æ¤¤¤¿¤À¤±¤¿¾ì¹ç¤Ï¡¢¤¼¤ÒÃø¼Ô°¸¤Ë¥á¡¼¥ë¤Ç¤ª¶µ¤¨¤¯¤À¤µ¤¤¡£¤è¤í¤·¤¯¤ª´ê¤¤¤·¤Þ¤¹¡Ê2007/07/06¡Ë¡£

XAllocColor() ¤ÏÀ®¸ù»þ¤Ë¤Ï 0 ¤Ç¤Ê¤¤ÃͤòÊÖ¤·¡¢¼ºÇÔ»þ¤Ë¤Ï 0 ¤òÊÖ¤·¤Þ¤¹¡£¤³¤ÎÆ°ºî¤Ï¡¢»ÈÍѤ·¤Æ¤¤¤ë¥Ó¥¸¥å¥¢¥ë¤Ë¤è¤Ã¤Æ°Û¤Ê¤ê¤Þ¤¹¡£Æɤ߽ñ¤­Î¾ÍѤΥӥ¸¥å¥¢¥ë¤Î¾ì¹ç¡¢Í׵ᤵ¤ì¤¿Àµ³Î¤Ê RGB ÃͤΥ«¥é¡¼¥»¥ë¤Ø¤Î³ä¤êÅö¤Æ¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¡¢0 ¤ò ÊÖ¤·¤Þ¤¹¡£

¤³¤ì¤ËÂФ·¤ÆÆɤ߽Ф·ÀìÍѤΥӥ¸¥å¥¢¥ë¤Î¾ì¹ç¡¢»ØÄꤷ¤¿Ãͤ˺Ǥâ¶á¤¤¿§¤Î¥«¥é¡¼¥»¥ë¤Î¥Ô¥¯¥»¥ëÃͤȡ¢¼ÂºÝ¤Ë»ÈÍѤµ¤ì¤ë RGB Ãͤ¬ÊÖ¤µ¤ì¤Þ¤¹¡£

¡û ¿§Ì¾¤ËÂбþ¤¹¤ë RGB ÃͤòÌ䤤¹ç¤ï¤»¤ë

¿§Ì¾¤ò»ØÄꤷ¤ÆÂбþ¤¹¤ë¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤¹¤ë´Ø¿ô¤È¤·¤Æ XAllocNamedColor() ¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤·¤¿¡£¤³¤Î´Ø¿ô¤Î·çÅÀ(¤È¤¤¤¦¤Û¤É¤Ç¤â̵¤¤¤Ç¤¹¤¬)¤È¤·¤Æ¡¢¼Â¹Ô·ë²Ì¤¬¼ºÇԤ˽ª¤ï¤Ã¤¿¾ì¹ç¤Ë¿§Ì¾¤Îǧ¼±¤Ë¼ºÇÔ¤·¤¿¤Î¤«¡¢RGB ÃͤËÂбþ¤¹¤ë¥«¥é¡¼¥»¥ë¤Î³ä¤êÅö¤Æ¤Ë¼ºÇÔ¤·¤¿¤Î¤«¤¬¶èÊ̤Ǥ­¤Þ¤»¤ó¡£

¤³¤ì¤òÈò¤±¤ë¤¿¤á¤Ë¡¢¿§Ì¾¤ò»ØÄꤷ¤ÆÂбþ¤¹¤ë RGB Ãͤò¼èÆÀ¤¹¤ë´Ø¿ô XParseColor() ¤¬ÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

Status XParseColor( Display* display, 
                    Colormap colormap, 
                    char*    spec, 
                    XColor*  exact_def_return
                  );

spec             : ¿§¤Î̾Á°¤òɽ¤¹Ê¸»úÎó¡£Âçʸ»ú/¾®Ê¸»ú¤ò¶èÊ̤·¤Ê¤¤¡£
exact_def_return : Àµ³Î¤Ê RGB Ãͤ¬ÊÖ¤µ¤ì¤ë

¤³¤Î´Ø¿ô¤Ï¡¢»ØÄꤷ¤¿¥«¥é¡¼¥Þ¥Ã¥×¤ËÂбþ¤¹¤ë¥¹¥¯¥ê¡¼¥ó¤Ë´Ø¤·¤Æ¡¢»ØÄꤷ¤¿¿§Ì¾¤ËÂбþ¤¹¤ë RGB Ãͤò exact_def_return ¤ËÊÖ¤·¤Þ¤¹¡£¤½¤ì¤ÈƱ»þ¤Ë DoRed / DoGreen / DoBlue ¤¬ exact_def_return->flags ¤ËÀßÄꤵ¤ì¤Þ¤¹¡£¿§¤Î²ò·è¤¬¤Ç¤­¤Ê¤¤¾ì¹ç¤Ï Status ¤È¤·¤Æ 0 ¤òÊÖ¤·¤Þ¤¹¡£

XParseColor() ¤ò»È¤Ã¤Æ¿§¤Î²ò·è¤ËÀ®¸ù¤·¤¿¸å¤Ë¡¢ÆÀ¤é¤ì¤¿ RGB Ãͤò XAllocColor() ¤ËÅϤ·¤ÆÂбþ¤¹¤ë¥Ô¥¯¥»¥ëÃͤòÆÀ¤ë¤È¤¤¤¦¼ê½ç¤òƧ¤á¤Ð¡¢¥Ô¥¯¥»¥ëÃͼèÆÀ¤Ë¼ºÇÔ¤·¤¿ºÝ¤Ë - ¿§Ì¾¤Î²ò·è / ¥«¥é¡¼¥»¥ë¤Î³ä¤êÅö¤Æ - ¤È¤¤¤¦É÷¤ËÌäÂê¤òÀÚ¤êʬ¤±¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

¡û ¥Ô¥¯¥»¥ëÃͤËÀßÄꤵ¤ì¤Æ¤¤¤ë RGB ÃͤòÌ䤤¹ç¤ï¤»¤ë

¤³¤³¤Þ¤Ç¤Ï¡¢¿§(̾Á°¤â¤·¤¯¤Ï RGB ÃÍ)¤ò»ØÄꤷ¤ÆÂбþ¤¹¤ë¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤¹¤ë¤¿¤á¤Î´Ø¿ô¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤­¤Þ¤·¤¿¤¬¡¢¤â¤Á¤í¤ó¤½¤ÎµÕ¤ò¹Ô¤¦´Ø¿ô¤â¸ºß¤·¤Þ¤¹¡£¥Ô¥¯¥»¥ëÃͤò»ØÄꤷ¤Æ¡¢¤½¤Î¥Ô¥¯¥»¥ëÃͤ˸½ºßÀßÄꤵ¤ì¤Æ¤¤¤ë RGB ÃͤòÌ䤤¹ç¤ï¤»¤ë¤¿¤á¤Ë XQueryColor()¡¢XQueryColors() ¤È¤¤¤¦´Ø¿ô¤¬¤¢¤ê¤Þ¤¹¡£

XQueryColor( Display* display, Colormap colormap, XColor* def_in_out );
def_in_out : »ØÄꤵ¤ì¤Æ¤¤¤ë¥Ô¥¯¥»¥ëÃͤËÀßÄꤵ¤ì¤Æ¤¤¤ë RGB Ãͤ¬ÊÖ¤µ¤ì¤ë

XQueryColors( Display* display,
              Colormap colormap,
              XColor   defs_in_out[],
              int      ncolors
            );

defs_in_out : XQueryColor() ¤Î def_in_out ¤ÎÇÛÎó
ncolors     : defs_in_out ¤ÎÇÛÎó¤ÎÍ×ÁÇ¿ô(¿§¿ô)

XQueryColor() ¤Ï¡¢def_in_out ¤¬¼¨¤¹ XColor ¹½Â¤ÂÎÊÑ¿ô¤Ë RGB ÃͤòÃΤꤿ¤¤¥Ô¥¯¥»¥ëÃͤòÀßÄꤷ¤Æ¼Â¹Ô¤¹¤ë¤È¡¢ÀßÄꤵ¤ì¤Æ¤¤¤ë RGB Ãͤ¬³ÊǼ¤µ¤ì¤Þ¤¹¡£¤½¤ì¤ÈƱ»þ¤Ë DoRed / DoGreen / DoBlue ¤¬ def_in_out->flags ¤ËÀßÄꤵ¤ì¤Þ¤¹¡£¤Þ¤¿¡¢XQueryColors() ¤Ï XQueryColor() ¤Î½èÍý¤òÊ£¿ô¥Ô¥¯¥»¥ëÃͤËÂФ·¤Æ¹Ô¤¤¤Þ¤¹¡£