LECTURE 17 DIB ( Device-Independent Bitmap ) ¤Îɽ¼¨

¡û ¤Ï¤¸¤á¤Ë

DIB ( Device-Independent Bitmap )¤È¤Ï¡¢X Window System ¤Ë¤ª¤±¤ë Bitmap ¤Î¤³¤È¤Ç¤Ï¤Ê¤¯¡¢¥«¥é¡¼¾ðÊó¤ò¼«Ê¬¤Ç»ý¤Ã¤Æ¤¤¤ë Win32API Âбþ¤Î¥«¥é¡¼¥Ó¥Ã¥È¥Þ¥Ã¥×¤òɽ¤·¤Þ¤¹¡£À¤¤ÎÃæ¤Ç°ìÈÌŪ¤Ë¸À¤ï¤ì¤Æ¤¤¤ë¥Ó¥Ã¥È¥Þ¥Ã¥×¤È¤Ï¤³¤Î·Á¼°¤ò»Ø¤·¤Æ¤¤¤Þ¤¹¡£¤³¤³¤Ç¤Ï¡¢¤³¤Î DIB ¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ó¤Ç²èÌ̤Ëɽ¼¨¤¹¤ë DIB Viewer ¤òºîÀ®¤·¤Þ¤¹¡£

¡û DIB ¥Õ¥¡¥¤¥ë¤Î·Á¼°

¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÁ°¤Ë¡¢DIB ¥Õ¥¡¥¤¥ë¤Î·Á¼° ( ¥Õ¥©¡¼¥Þ¥Ã¥È )¤Ë¤Ä¤¤¤ÆɬÍפÊÉôʬ¤Ë¤Ä¤¤¤Æ¤Î¤ß´Êñ¤ËÀâÌÀ¤·¤Þ¤¹¡£

DIB ¥Õ¥¡¥¤¥ë¤Ï°Ê²¼¤ÎÍͤ˹½À®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤Ê¤ª¡¢³Æ¹½Â¤ÂÎ¤Ï Windows ¾å¤Î¥Ø¥Ã¥À¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¤¢¤ë¤³¤È¤ËÃí°Õ¤·¤Æ²¼¤µ¤¤¡£

  • BITMAPFILEHEADER ¹½Â¤ÂÎ ( ¥Õ¥¡¥¤¥ë¥Ø¥Ã¥À )
  • BITMAPINFOHEADER ¹½Â¤ÂÎ ( ¾ðÊó¥Ø¥Ã¥À )
  • RGBQUAD ¹½Â¤ÂÎ ( ¿§¾ðÊó )
  • ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿

BITMAPFILEHEADER ¹½Â¤ÂÎ¤Ï 14 bytes¡¢BITMAPINFOHEADER ¹½Â¤ÂÎ¤Ï 40 bytes ¤Ç¤¢¤ê¡¢·× 54 bytes ¤¬ DIB ¥Õ¥¡¥¤¥ë¤Î¥Ø¥Ã¥À¤È¤Ê¤ê¤Þ¤¹¡£¤³¤ÎÀèƬ 54 bytes ¤ÎÃæ¤Ç¤Ï°Ê²¼¤Î¾ðÊó¤ò»ÈÍѤ·¤Þ¤¹¡£

¥ª¥Õ¥»¥Ã¥È(byte) ¥µ¥¤¥º(byte) ¼±ÊÌ̾(¹½Â¤ÂΤΥá¥ó¥Ð̾) ¥Ç¡¼¥¿¤ÎÆâÍÆ
0 2 bfType "BM" ¤È¤¤¤¦Ê¸»úÎó¤Ç¤¢¤ì¤Ð¡¢¥Ó¥Ã¥È¥Þ¥Ã¥×¥Õ¥¡¥¤¥ë
10 4 bfOffBits ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤«¤é¥Ô¥¯¥»¥ë¥Ç¡¼¥¿Îΰè¤ÎÀèƬ¤Þ¤Ç¤Î¥ª¥Õ¥»¥Ã¥È¡£ ²¼¤Ë¤¢¤ë biBitCount ¤¬ 16 °Ê¾å¤Î¾ì¹ç¤Ï¾ï¤Ë 54¡£
18 4 biWidth ²èÁü¤ÎÉý(¥Ô¥¯¥»¥ëñ°Ì)
22 4 biHeight ²èÁü¤Î¹â¤µ(¥Ô¥¯¥»¥ëñ°Ì)
28 2 biBitCount 1 ¥Ô¥¯¥»¥ë¤¢¤¿¤ê¤Î¥«¥é¡¼¥Ó¥Ã¥È¿ô
30 4 biCompression ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤Î°µ½Ì¤Î¼ïÎà¡£0 ( BI_RGB )¡¢1 ( BI_RLE8 )¡¢2 ( BI_RLE4 )¡¢ 3 ( BI_BITFIELDS )¤Î¤¤¤º¤ì¤«¤ÎÃͤȤʤ롣BI_RGB ¤Î¾ì¹ç¤Ï̵°µ½Ì¡¢BI_RLE4¤Ï 4 ¥Ó¥Ã¥È¥«¥é¡¼ÍѤΥé¥ó¥ì¥ó¥°¥¹°µ½Ì¡¢BI_RLE8 ¤Ï 8 ¥Ó¥Ã¥È¥«¥é¡¼ÍѤΥé¥ó¥ì¥ó¥°¥¹ °µ½Ì¤È¤Ê¤ë¡£BI_BITFIELDS ¤Î¾ì¹ç¤Ï¡¢°µ½Ì¤Ï¤µ¤ì¤Æ¤¤¤Ê¤¤¤¬¥«¥é¡¼¥Þ¥¹¥¯¤¬ ÀßÄꤵ¤ì¤Æ¤¤¤ë¡£BI_BITFIELDS ¤Ï 16 ¥Ó¥Ã¥È¥«¥é¡¼¤¢¤ë¤¤¤Ï 32 ¥Ó¥Ã¥È¥«¥é¡¼¤Î¾ì¹ç¤Ë¤Î¤ßÍ­¸ú¡£
46 4 biClrUsed biBitCount < 16 ¤Ç¤¢¤ì¤Ð¡¢biClrUsed ¤Ï¿§¿ô¤È¤Ê¤ë¡£biClrUsed ¤¬ 0 ¤Ç¤¢¤ì¤Ð¡¢ biBitCount ¤ËÂбþ¤·¤¿ºÇÂ翧¿ô¤¬»È¤ï¤ì¤Æ¤¤¤ë¤³¤È¤Ë¤Ê¤ë¡£biBitCount >= 16 ¤Î¾ì¹ç¤Ï Windows ¤Ç»²¾È¤µ¤ì¤ëÆüì¤Ê°ÕÌ£¤ò»ý¤Ä¤¬¡¢Æä˵¤¤Ë¤·¤Ê¤¯¤Æ¤è¤¤¡£

54 bytes ¤Î¥Ø¥Ã¥À¤¬½ª¤Ã¤¿¸å¤Ï¡¢¿§¿ô¤Ë±þ¤¸¤Æ RGBQUAD ¹½Â¤ÂΤ¬Â³¤­¤Þ¤¹¡£RGBQUAD ¹½Â¤ÂΤÎÆâÍƤϼ¡¤ÎÄ̤ê¤Ç¤¹¡£

¥ª¥Õ¥»¥Ã¥È(byte)¥µ¥¤¥º(byte)ÆâÍÆ
01ÀĤε±ÅÙ ( 0 ¡Á 255 )
11ÎФε±ÅÙ ( 0 ¡Á 255 )
21À֤ε±ÅÙ ( 0 ¡Á 255 )
31ͽÈ÷

¥Ø¥Ã¥À¾ðÊó¤Î biBitCount ¤¬ 8 °Ê²¼¤Î¾ì¹ç¤Ï¡¢RGBQUAD ¹½Â¤ÂΤ¬¿§¿ô¸ÄʤӤޤ¹¡£16 °Ê¾å¤Î¾ì¹ç¤Ï¡¢¸å½Ò¤Î¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¼«¿È¤¬¿§¾ðÊó¤òɽ¤·¤Æ¤¤¤ë¤¿¤á¡¢RGBQUAD ¹½Â¤ÂÎÎΰè¤Ï»ÈÍѤµ¤ì¤Þ¤»¤ó( 0 ¸Ä )¡£

RGBQUAD ¹½Â¤ÂΤ¬Ê¤ó¤À¸å¤Ï¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤¬Â³¤­¤Þ¤¹¡£°ìÈÌŪ(¤È»×¤ï¤ì¤ë)¤Ê½ç½ø¤È¤ÏµÕ¤Ë¡¢²èÁü¤Î²¼¹Ô¤«¤é½ç¤Ë 1 ¹Ô¤º¤Ä¤Î¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤¬Ê¤٤é¤ì¤Æ¤¤¤Þ¤¹¡£¤Þ¤¿¡¢³Æ¹Ô¤Î¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤Î¥µ¥¤¥º¤¬ 4 ¥Ð¥¤¥È¶­³¦¤ËËþ¤¿¤Ê¤¤¾ì¹ç¤Ï¡¢Â­¤ê¤Ê¤¤Éôʬ¤¬Ëä¤á¤é¤ì¤Æ¤¤¤Þ¤¹¡£

¤³¤Î¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤Ï¡¢¥Ø¥Ã¥À¾ðÊó¤Î biBitCount ¤¬ 8 °Ê²¼¤Î¾ì¹ç¤Ï biCompression ¤¬ BI_RGB ¤Ç¤¢¤ì¤Ð³Æ¥Ô¥¯¥»¥ë¤Î¥Ç¡¼¥¿¤ËÂбþ¤¹¤ë¿§ÈÖ¹æ ( Á°½Ò¤Î RGBQUAD ¹½Â¤ÂÎÎΰè¤Ëʤ٤é¤ì¤¿¿§¤Î²¿ÈÖÌܤ理«¤òɽ¤¹ )¤¬ 1 ¥Ð¥¤¥È¤º¤Äʤ٤é¤ì¤Æ¤¤¤Þ¤¹¡£biCompression ¤¬ BI_RLE4 ¤â¤·¤¯¤Ï BI_RLE8 ¤Î¾ì¹ç¤Ï¡¢¥«¥é¡¼¥Ó¥Ã¥È¿ô¤Ë±þ¤¸¤¿¥é¥ó¥ì¥ó¥°¥¹°µ½Ì¤¬¤«¤±¤é¤ì¤Æ¤¤¤Þ¤¹¡£¥é¥ó¥ì¥ó¥°¥¹°µ½Ì¤Ë¤Ä¤¤¤Æ¤Ï¤³¤³¤Ç¤Ï¤Õ¤ì¤Þ¤»¤ó¡£

biBitCount ¤¬ 16 °Ê¾å¤Î¾ì¹ç¤Ï¡¢³Æ¥Ô¥¯¥»¥ëËè¤ËÀÄ¡¢ÎС¢À֤νç¤Ëµ±ÅÙ¤¬Ê¤٤é¤ì¤Æ¤¤¤Þ¤¹¡£biCompression ¤¬ BI_RGB ¤Ç¤¢¤ë¾ì¹ç¡¢16 bpp ( biBitCount = 16 )¤Î¾ì¹ç¤ÏÀÄ¡¢ÎС¢ÀÖ¤½¤ì¤¾¤ì 5 ¥Ó¥Ã¥È¤Çɽ¤µ¤ì(»Ä¤ê 1 ¥Ó¥Ã¥È¤Ï°Ọ̵̃¤·)¡¢24 / 32 bpp ¤Î¾ì¹ç¤Ï 8 ¥Ó¥Ã¥È¤Ç³Æ¿§¤¬É½¸½¤µ¤ì¤Þ¤¹(32 bpp ¤Î¾ì¹ç¤Î»Ä¤ê 1 ¥Ð¥¤¥È¤Ï°Ọ̵̃¤·)¡£

biCompression ¤¬ BI_BITFIELDS ¤Î¾ì¹ç¡¢Æȼ«¤Î¥«¥é¡¼¥Þ¥¹¥¯¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Þ¤¹¡£¥«¥é¡¼¥Þ¥¹¥¯¤ÎÂ礭¤µ¤Ï 4 ¥Ð¥¤¥È¤Ç¤¢¤ê¡¢biBitCount ¤¬ 8 °Ê²¼¤Î¾ì¹ç¤Ë RGBQUAD ¹½Â¤ÂΤ¬Ê¤٤é¤ì¤ë°ÌÃÖ¤Ë 3 ¤Äʤ٤é¤ì¤Æ¤¤¤Þ¤¹( ¤½¤ì¤¾¤ìÀÄ¡¢ÎС¢ÀÖ¿§ÍÑ)¡£¤³¤Î¥«¥é¡¼¥Þ¥¹¥¯¤È¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤Î¥Þ¥¹¥¯¤ò¤È¤Ã¤Æ¡¢¼ÂºÝ¤Î¿§Ãͤò¼èÆÀ¤¹¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à

256 ¿§°Ê²¼¤Î DIB ¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ó¤Ç²èÌ̤Ëɽ¼¨¤¹¤ë DIB Viewer ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à xdib.c ¤Ç¤¹¡£²èÁü¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß¤ä½ñ¤­¹þ¤ß¤ò¹Ô¤¦¾ì¹ç¤Ï¡¢¤½¤Î¤¿¤á¤ËºîÀ®¤µ¤ì¤Æ¤¤¤ë¥é¥¤¥Ö¥é¥ê¤ò»È¤¦¤Î¤¬°ìÈÌŪ¤À¤È»×¤¤¤Þ¤¹¤¬¡¢¤³¤³¤Ç¤Ï DIB ¤òÆɤ߹þ¤àÉôʬ¤«¤éºîÀ®¤·¤Þ¤¹¡£

¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤«¤é¡¢Á´¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò¸Ç¤á¤¿ tar ¥Ü¡¼¥ë¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£

ËÁƬ¤Ë¤¢¤ë¤è¤¦¤Ë¡¢DIB ¥Õ¥¡¥¤¥ë¤Ï 256 ¿§°Ê²¼¤Î¿§¿ô¤Î¤â¤Î¤òÂоݤȤ·¤Þ¤¹¡£¥Ô¥¯¥»¥ë¥Ç¡¼¥¿Éô¤Ï̵°µ½Ì¤Ç¤¢¤ë¤³¤È¤òÁ°Äó¤È¤·¤Þ¤¹( biCompression ¤¬ BI_RGB )¡£¤Þ¤¿¡¢¥¹¥¯¥ê¡¼¥ó¤Î¿¼¤µ¤Ï 16¡¢32 bpp ¤Ç¤¢¤ë¤³¤È¤òÁ°Äó¤È¤·¤Þ¤¹¡£¤½¤ì°Ê³°¤Î¿¼¤µ¤Î¥¹¥¯¥ê¡¼¥ó¤Ç¼Â¹Ô¤·¤¿¾ì¹ç¤ä¡¢256 ¿§¤è¤ê¿§¿ô¤Î¿¤¤¡¢¤¢¤ë¤¤¤Ï biCompression ¤¬ BI_RGB ¤Ç¤Ê¤¤ DIB ¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ó¤À¾ì¹ç¤Ë¤Ï¤½¤³¤Ç½ªÎ»¤·¤Þ¤¹¡£

¡Ê24 bpp ¤Î¾ì¹ç¤ÏÀµ¾ï¤ËÆ°ºî¤·¤Ê¤¤¾ì¹ç¤¬¤¢¤ê¤Þ¤·¤¿¡£Î¦¤µ¤ó¡¢¤¢¤ê¤¬¤È¤¦¤´¤¶¤¤¤Þ¤·¤¿¡£2004/11/28¡Ë

¥³¥ó¥Ñ¥¤¥ë¤ò½ª¤¨¤¿¤é¡¢DIB ¥Õ¥¡¥¤¥ë̾¤ò°ú¿ô¤ËÍ¿¤¨¤Æ¼Â¹Ô¤·¤Æ¤ß¤Æ²¼¤µ¤¤¡£DIB ¥Õ¥¡¥¤¥ë¤¬²èÌ̤Ëɽ¼¨¤µ¤ì¤ë¤È»×¤¤¤Þ¤¹¡£¤Á¤Ê¤ß¤Ë²¼¿Þ¤ÏÃΤê¹ç¤¤¤Î¼Ö¤ò¥Ç¥¸¥«¥á¤Ç¼Ì¤·¤¿ DIB ¥Õ¥¡¥¤¥ë¤òɽ¼¨¤µ¤»¤¿²èÌ̤ò¥­¥ã¥×¥Á¥ã¤·¤¿¤â¤Î¤Ç¤¹¡£

017dib.jpg

--- xdib.c ---

    1	#include <X11/Xlib.h>
    2	#include <X11/Xutil.h>
    3	#include <stdio.h>
    4	#include <stdlib.h>
    5	#include <string.h>
    6	
    7	#define WIN_X   100  /* ¥¦¥£¥ó¥É¥¦É½¼¨°ÌÃÖ(X) */
    8	#define WIN_Y   100  /* ¥¦¥£¥ó¥É¥¦É½¼¨°ÌÃÖ(Y) */
    9	
   10	
   11	/* DIB ¥Õ¥¡¥¤¥ë¤Î²èÁü¾ðÊó¤ò³ÊǼ¤¹¤ë¹½Â¤ÂÎ */
   12	typedef struct _DIBImage_t
   13	{
   14	    int            width;           /* ²èÁü¤ÎÉý */
   15	    int            height;          /* ²èÁü¤Î¹â¤µ */
   16	    int            n_color;         /* ²èÁü¤Î¿§¿ô */
   17	    unsigned char  palette[256][3]; /* ¥Ñ¥ì¥Ã¥È¾ðÊó */
   18	    unsigned char* data;            /* ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿ */
   19	}
   20	DIBImage;
   21	
   22	
   23	static Display* dpy;        /* ¥Ç¥£¥¹¥×¥ì¥¤ */
   24	static Window   root, win;  /* ¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ª¤è¤Óɽ¼¨¥¦¥£¥ó¥É¥¦ */
   25	static int      screen;     /* ¥¹¥¯¥ê¡¼¥ó */
   26	static int      depth;      /* ¥¹¥¯¥ê¡¼¥ó¤Î¿¼¤µ */
   27	static Pixmap   pixmap;     /* ¥Ô¥¯¥¹¥Þ¥Ã¥× */
   28	static GC       gc;         /* ¥°¥é¥Õ¥£¥Ã¥¯¥¹¥³¥ó¥Æ¥­¥¹¥È */
   29	static XColor*  colors;     /* DIB ¥Õ¥¡¥¤¥ë¤Î¥Ñ¥ì¥Ã¥È¾ðÊó¤ò³ÊǼ¤¹¤ëÎΰè */
   30	
   31	
   32	static int  xdib_readFile( char* fname, DIBImage* dib_image );
   33	static void xdib_setup( DIBImage* dib_image );
   34	
   35	
   36	int 
   37	main( int argc, char** argv )
   38	{
   39		XEvent   evt;
   40		DIBImage dib_image;
   41	
   42	
   43		/* »ØÄꤵ¤ì¤¿ DIB ¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ó¤Ç²èÁü¾ðÊó¤òÊݸ¤¹¤ë */
   44		if ( xdib_readFile( argv[1], &dib_image ) == 0 ) {
   45			printf( "Failed to read specified DIB file : %s\n", argv[1] );
   46			return 1;
   47		}
   48	
   49		dpy = XOpenDisplay( "" );
   50	
   51		root   = DefaultRootWindow( dpy );
   52		screen = DefaultScreen( dpy );
   53		depth  = DefaultDepth( dpy, screen );
   54	
   55		/* depth ¤¬ 16¡¢32 °Ê³°¤Î¾ì¹ç¤Ï¤³¤³¤Ç½ªÎ»¤¹¤ë */
   56		if ( depth != 16 && depth != 32 ) {
   57			XCloseDisplay( dpy );
   58			printf( "Screen depth is not 16 nor 32 bpp.\n" );
   59			return 1;
   60		}
   61	
   62	
   63		win = XCreateSimpleWindow( dpy, root, WIN_X, WIN_Y, 
   64					   dib_image.width,
   65					   dib_image.height,
   66					   0,
   67					   BlackPixel( dpy, screen ), 
   68					   BlackPixel( dpy, screen ) );
   69	
   70		gc = XCreateGC( dpy, win, 0, NULL );
   71	
   72		/* Æɤ߹þ¤ó¤À DIB ¥Õ¥¡¥¤¥ë¾ðÊó¤òɽ¼¨¤Ç¤­¤ë¤è¤¦¤ËÀßÄꤹ¤ë */
   73		xdib_setup( &dib_image );
   74	
   75		XSelectInput( dpy, win, ExposureMask | KeyPressMask );
   76		XMapWindow( dpy, win );
   77	
   78		while( 1 ) {
   79			XNextEvent( dpy, &evt );
   80	
   81			switch( evt.type ) { 
   82				case Expose:
   83					if ( evt.xexpose.count == 0 ) {
   84						/* ¥Ô¥¯¥¹¥Þ¥Ã¥×¤ò¥¦¥£¥ó¥É¥¦¤Ë¥³¥Ô¡¼¤¹¤ë */
   85						XCopyArea( dpy, pixmap, win, gc, 
   86							   0, 0,
   87							   dib_image.width,
   88							   dib_image.height,
   89							   0, 0 );
   90						XFlush( dpy );
   91					}
   92					break;
   93	
   94				case KeyPress:
   95					free( colors );
   96					XFreePixmap( dpy, pixmap );
   97					XDestroyWindow( dpy, win );
   98					XCloseDisplay( dpy );
   99					return 0;
  100			}
  101		}
  102	}
  103	
  104	
  105	/* 
  106	 * »ØÄꤷ¤¿ DIB ¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ß¡¢²èÁü¾ðÊó¤ò dib_image ÊÑ¿ô
  107	 * ¤Ë³ÊǼ¤¹¤ë¡£¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤òÊݸ¤¹¤ë¤¿¤á¤Î dib_image.data 
  108	 * Îΰè¤Ï´Ø¿ôÆâ¤Ç³ÎÊݤ¹¤ë¡£¤½¤Î¤¿¤áËÜ´Ø¿ô¤òÍøÍѤ¹¤ëºÝ¤Ë¤Ï¡¢
  109	 * dib_image.data ¤¬Ì¤³ÎÊݤǤ¢¤ë dib_image ÊÑ¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò
  110	 * °ú¿ô¤Ë»ØÄꤹ¤ë¤³¤È¡£
  111	 * Æɤ߹þ¤ß½èÍý¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¤Ï 0 ¤ò¡¢À®¸ù¤·¤¿¾ì¹ç¤Ï¤½¤ì°Ê³°¤ÎÃͤòÊÖ¤¹¡£
  112	 */
  113	static int 
  114	xdib_readFile( char* fname, DIBImage* dib_image )
  115	{
  116		unsigned char buf[4];    
  117		FILE* fp;
  118		int   i;
  119		int   dib_depth;
  120		int   offset;
  121		int   bw;
  122		int   index;
  123	
  124	
  125		if ( ( fp = fopen( fname, "r" ) ) == NULL ) {
  126			printf( "Failed to open %s.\n", fname );
  127			return 0;
  128		}
  129	
  130	
  131		/* ÀèƬ 2 ¥Ð¥¤¥È¤¬ "BM" ¤Ç¤¢¤ì¤Ð¡¢BMP ¥Õ¥¡¥¤¥ë */
  132		fread( buf, 2, 1, fp );
  133	
  134		if ( strncmp( ( char* )buf, "BM", 2 ) != 0 ) {
  135			printf( "Specified file is not DIB file.\n" );
  136			return 0;
  137		}
  138	
  139	
  140		/* ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤«¤é 28 ¥Ð¥¤¥È¤Î°ÌÃ֤˰ÜÆ° */
  141		fseek( fp, 28, SEEK_SET );
  142	
  143		/* 1 ¥Ô¥¯¥»¥ë¤¢¤¿¤ê¤Î¥Ó¥Ã¥È¿ô¤ò¼èÆÀ */
  144		fread( buf, 2, 1, fp );
  145		dib_depth = buf[0] + ( buf[1] << 8 );
  146	
  147		/* 256 ¿§°Ê²¼¤Î¥Õ¥¡¥¤¥ë¤¬ÂÐ¾Ý */
  148		if ( dib_depth > 8 ) {
  149			printf( "Specified file is more than 8 bpp ( %d bpp ).\n", dib_depth );
  150			return 0;
  151		}
  152	
  153	
  154		/* ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤«¤é 30 ¥Ð¥¤¥È¤Î°ÌÃ֤˰ÜÆ° */
  155		fseek( fp, 30, SEEK_SET );
  156		fread( buf, 4, 1, fp );
  157	
  158		/* Æɤ߹þ¤ó¤ÀÃͤ¬ 0 ¤Ç¤Ê¤±¤ì¤Ð¡¢biCompression ¤¬ BI_RGB ¤Ç¤Ê¤¤
  159		   (¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤¬°µ½Ì¤µ¤ì¤Æ¤¤¤ë)¤Î¤Ç¡¢¤³¤³¤Ç½ªÎ»¤¹¤ë¡£*/
  160	
  161		if ( buf[0] != 0 ) {
  162			printf( "Specified DIB file is compressed\n" );
  163	      		return 0;
  164		}
  165	
  166	
  167		/* ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤«¤é 46 ¥Ð¥¤¥È¤Î°ÌÃ֤˰ÜÆ° */
  168		fseek( fp, 46, SEEK_SET );
  169		fread( buf, 4, 1, fp );
  170	
  171		/* Æɤ߹þ¤ó¤ÀÃͤ¬ 0 ¤Ç¤Ê¤±¤ì¤Ð¡¢depth ¤Ë¤è¤Ã¤Æ¿§¿ô¤¬·è¤Þ¤ë¡£
  172		   256 ¿§°Ê²¼¤Î¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¤¿¤á¡¢ºÇ½é¤Î 1 ¥Ð¥¤¥È¤Î¤ß¤ò¹Í¤¨¤ì¤ÐÎɤ¤ */
  173		if ( buf[0] == 0 ) {
  174			dib_image->n_color = 1 << dib_depth;
  175		}
  176		else {
  177			dib_image->n_color = buf[0];
  178		}
  179	
  180	
  181		/* ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤«¤é 10 ¥Ð¥¤¥È¤Î°ÌÃ֤˰ÜÆ° */
  182		fseek( fp, 10, SEEK_SET );
  183	
  184		/* ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤«¤é¥Ô¥¯¥»¥ë¥Ç¡¼¥¿Îΰè¤ÎÀèƬ¤Þ¤Ç¤Î¥ª¥Õ¥»¥Ã¥È¤ò¼èÆÀ */
  185		fread( buf, 2, 1, fp );
  186		offset = buf[0] + ( buf[1] << 8 );
  187	
  188	
  189	       	/* ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤«¤é 18 ¥Ð¥¤¥È¤Î°ÌÃ֤˰ÜÆ° */
  190		fseek( fp, 18, SEEK_SET );
  191	
  192		/* ²èÁü¤ÎÉý¤ò¼èÆÀ */
  193		fread( buf, 4, 1, fp );
  194	
  195		dib_image->width  = buf[0] + ( buf[1] << 8 ) + 
  196			( buf[2] << 16 ) + ( buf[3] << 24 );
  197	
  198		/* ²èÁü¤Î¹â¤µ¤ò¼èÆÀ */
  199		fread( buf, 4, 1, fp );
  200	
  201		dib_image->height = buf[0] + ( buf[1] << 8 ) + 
  202			( buf[2] << 16 ) + ( buf[3] << 24 );
  203	
  204	    
  205		/* ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤«¤é 54 ¥Ð¥¤¥È¤Î°ÌÃ֤˰ÜÆ° */
  206		fseek( fp, 54, SEEK_SET );
  207	
  208		/* ¥Ñ¥ì¥Ã¥È¾ðÊó¤ò¼èÆÀ */
  209		for ( i = 0; i < dib_image->n_color; i ++ ) {
  210			fread( buf, 4, 1, fp );
  211			dib_image->palette[i][0] = buf[2];
  212			dib_image->palette[i][1] = buf[1];
  213			dib_image->palette[i][2] = buf[0];
  214		}
  215	
  216	
  217		/* ²èÁü¤Î 1 ¹Ôʬ¤Î¥Ð¥¤¥È¿ô¤Ï¡¢²èÁü¤ÎÉý¤Ë 1 Èֶᤤ 4 ¤ÎÇÜ¿ô¤Ë·«¤ê¾å¤²¤é¤ì¤ë */
  218		bw = ( dib_image->width + 3 ) & ~3;
  219	
  220	
  221		/* ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿Îΰè¤Î³ÎÊÝ */
  222		dib_image->data = 
  223			( unsigned char* )malloc( dib_image->width * dib_image->height );
  224	
  225		for ( i = 0; i < dib_image->height; i ++ ) {
  226			/* ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿Îΰè¤ÎÀèƬ¤«¤é 1 ¹Ô¤º¤ÄÆɤ߹þ¤à */
  227			fseek( fp, offset + bw * i, SEEK_SET );
  228	
  229			/* 
  230			 * DIB Æâ¤Î¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤Ï²¼¹Ô¤«¤é½ç¤ËµÍ¤á¤é¤ì¤Æ¤¤¤ë¡£
  231			 * dib_image->data ¤Ë¤Ï¾å¹Ô¤«¤é½ç¤ËµÍ¤á¤ë¤¿¤á¡¢Âбþ¤¹¤ë
  232			 * ¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò·×»»¤·¤Æ¤¤¤ë¡£
  233			 */
  234			index = dib_image->width * ( dib_image->height - i - 1 );
  235	
  236			/* 1 ¹ÔÆɤ߹þ¤ß */
  237			fread( &( dib_image->data[ index ] ), dib_image->width, 1, fp );
  238		}
  239	
  240		fclose( fp );
  241		return 1;
  242	}
  243	
  244	
  245	/*
  246	 * Æɤ߹þ¤ó¤À DIB ¥Õ¥¡¥¤¥ë¾ðÊó¤ò»È¤Ã¤Æ¡¢¼ÂºÝ¤Ë¥¦¥£¥ó¥É¥¦
  247	 * ¤Ëɽ¼¨¤Ç¤­¤ë¤è¤¦¤ËÀßÄê¤ò¹Ô¤¦
  248	 */
  249	static void 
  250	xdib_setup( DIBImage* dib_image )
  251	{
  252		/* 
  253		 * Æɤ߹þ¤ó¤À DIB ¥Õ¥¡¥¤¥ë¤Î²èÁü¾ðÊó¤ò¥¯¥é¥¤¥¢¥ó¥È¦¤Ç
  254		 * ÊÝ»ý¤¹¤ë¤¿¤á¤Î XImage ¹½Â¤ÂÎ
  255		 */
  256		XImage*  ximage;
  257	
  258		/* ¥¯¥é¥¤¥¢¥ó¥È¦¤«¤é X ¥µ¡¼¥Ð¤ËžÁ÷¤¹¤ë¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤ò³ÊǼ¤¹¤ëÎΰè */
  259		unsigned char* img_data;  
  260	
  261		int size;
  262		int i;
  263	
  264	
  265		/* DIBImage ·¿ÊÑ¿ô¤Ë³ÊǼ¤µ¤ì¤¿¥«¥é¡¼¥Ñ¥ì¥Ã¥È¾ðÊó¤ò¡¢XColor ¹½Â¤ÂΤÎ
  266		   ÇÛÎó·Á¼°¤ËÊÑ´¹¤¹¤ë */
  267		colors = ( XColor* )malloc( sizeof( XColor ) * dib_image->n_color );
  268	
  269		for ( i = 0; i < dib_image->n_color; i ++ ) {
  270			colors[i].red   = dib_image->palette[i][0] * 257;
  271			colors[i].green = dib_image->palette[i][1] * 257;
  272			colors[i].blue  = dib_image->palette[i][2] * 257;
  273			colors[i].flags = DoRed | DoGreen | DoBlue;
  274	
  275			XAllocColor( dpy, DefaultColormap( dpy, screen ), &colors[i] );
  276		}
  277	
  278	
  279		/* X ¥µ¡¼¥Ð¦¤Ç²èÁü¤òÊÝ»ý¤¹¤ë¤¿¤á¤Î¥Ô¥¯¥¹¥Þ¥Ã¥×¤òºîÀ®¤¹¤ë */
  280		pixmap = XCreatePixmap( dpy, win, 
  281					dib_image->width, 
  282					dib_image->height, 
  283					depth );
  284	
  285	
  286		/* ¥¹¥¯¥ê¡¼¥ó¤Î¿¼¤µ¤Ë¹ç¤ï¤»¤¿¡¢Å¾Á÷ÍÑ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤òºîÀ®¤¹¤ë */
  287		size     = dib_image->width * dib_image->height;
  288		img_data = ( unsigned char* )malloc( size * depth / 8 );
  289	
  290		memset( img_data, 0, size * depth / 8 );
  291	
  292	
  293		/* 
  294		 * DIBImage Æâ¤Î¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤Ï¡¢¥Ñ¥ì¥Ã¥È¾ðÊóÇÛÎó¤Î¤É¤ÎÍ×ÁǤ¬
  295		 * ¥Ô¥¯¥»¥ë¤ËÂбþ¤¹¤ë¿§¤Ç¤¢¤ë¤«¤òɽ¤·¤Æ¤¤¤ë¡£ žÁ÷ÍѤΥԥ¯¥»¥ë
  296		 * ¥Ç¡¼¥¿¤Ï¡¢ ¥¹¥¯¥ê¡¼¥ó¤Î¿¼¤µ¤ÈƱ¤¸¥Ó¥Ã¥È¿ô¤Çɽ¤µ¤ì¤¿³Æ¿§¤Î
  297		 * ¥Ô¥¯¥»¥ëÃͤǤʤ±¤ì¤Ð¤Ê¤é¤Ê¤¤¤Î¤Ç¡¢¤³¤³¤ÇÊÑ´¹¤ò¹Ô¤¦¡£
  298		 */
  299		for ( i = 0; i < size; i ++ ) {
  300			memcpy( img_data + i * ( depth / 8 ) , 
  301				&( colors[dib_image->data[i]].pixel ), depth / 8 );
  302		}
  303	
  304	
  305		/* ¥¯¥é¥¤¥¢¥ó¥È¦¤Î²èÁü¾ðÊóÊÝ»ýÎΰè¤Ç¤¢¤ë XImage ¹½Â¤ÂÎÊÑ¿ô¤òºîÀ®¤¹¤ë */
  306		ximage = XCreateImage( dpy, DefaultVisual( dpy, screen ),
  307				       depth, ZPixmap, 0, 
  308				       ( char* )img_data,
  309				       dib_image->width, 
  310				       dib_image->height,
  311				       /* 16 bpp ¤Î¾ì¹ç¤Ï 16¡¢24 / 32 bpp ¤Î¾ì¹ç¤Ï 32 ¤Ë¤¹¤ë */
  312				       ( depth == 16 ) ? 16 : 32, 
  313				       0 );
  314	
  315		/* ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤ò¥Ô¥¯¥¹¥Þ¥Ã¥×¤ËžÁ÷¤¹¤ë */
  316		XPutImage( dpy, pixmap, gc, ximage, 
  317			   0, 0, 
  318			   0, 0, 
  319			   dib_image->width, 
  320			   dib_image->height );
  321	
  322		XFlush( dpy );
  323		XDestroyImage( ximage );
  324		free( dib_image->data );
  325	}
  326	
  327	
  328	/* End of xdib.c */

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

¤Ç¤Ï¡¢¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

  • 11 ¡Á 20 ¹ÔÌÜ

    105 ¹ÔÌܤ«¤é¤Î DIB Æɤ߹þ¤ß´Ø¿ô xdib_readFile() ¤Ë¤è¤Ã¤ÆÆɤ߹þ¤ó¤À DIB ¥Õ¥¡¥¤¥ë¾ðÊó ¤ò³ÊǼ¤¹¤ë¤¿¤á¤Î¹½Â¤ÂÎ DIBImage ¤òÄêµÁ¤·¤Æ¤¤¤Þ¤¹¡£palette ¤Ï¡¢RGB ¤Îµ±ÅÙ ( 0 ¡Á 255 ) ¤òºÇÂç 256 ¿§Ê¬³ÊǼ¤¹¤ë¤¿¤á¤ÎÎΰè¤Ç¤¹¡£data ¤Ë¤Ï¡¢²èÁü¤Î³Æ¥Ô¥¯¥»¥ë¤ò palette ¤Ë³ÊǼ ¤µ¤ì¤Æ¤¤¤ë²¿ÈÖÌܤ理Çɽ¼¨¤¹¤ë¤«¤òɽ¤¹Èֹ椬¡¢²èÁü¤Î¾å¹Ô¤«¤é½ç¤Ë 1 ¥Ð¥¤¥È¤º¤Ä³ÊǼ¤µ¤ì ¤Þ¤¹¡£

  • 27 ¹ÔÌÜ

    ¤³¤³¤ÇÀë¸À¤µ¤ì¤Æ¤¤¤ë pixmap ¤Ë¤Ï¡¢¥¦¥£¥ó¥É¥¦¤Ëɽ¼¨¤¹¤ë²èÁü¤¬¥í¡¼¥É¤µ¤ì¤Þ¤¹¡£main() ¤ò¸«¤ëºÝ¤Ë¤Ï¡¢¤³¤Î pixmap ¤Ë²èÁü¤¬¥í¡¼¥É¤µ¤ì¤Æ¤¤¤ë¤«¤é¤½¤ì¤ò¥¦¥£¥ó¥É¥¦¤Ë¥³¥Ô¡¼¤·¤Æ²è Áü¤òɽ¼¨¤·¤Æ¤¤¤ë¤ó¤À¤Ê¤È»×¤Ã¤Æ²¼¤µ¤¤¡£pixmap ¤Ë²èÁü¤¬¥í¡¼¥É¤µ¤ì¤ë²áÄø¤Ë¤Ä¤¤¤Æ¤Ï main() ¤ÎÀâÌÀ¤Î¸å¤ÇÀâÌÀ¤·¤Þ¤¹¡£

  • 36 ¡Á 102 ¹ÔÌÜ ( main() )

    xdib.c ¤Î main ´Ø¿ô¤Ç¤¹¡£³Æ½èÍý¤Ë¤Ä¤¤¤Æ°Ê²¼¤ÇÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

    • 43 ¡Á 47 ¹ÔÌÜ

      xdib_readFile() ¤ò¼Â¹Ô¤·¤Æ¡¢°ú¿ô¤Ç»ØÄꤵ¤ì¤¿ DIB ¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ß¤Þ¤¹¡£Æɤ߹þ¤ß¤Ë¼º ÇÔ¤·¤¿¾ì¹ç¤Ï¤³¤³¤Ç½ªÎ»¤·¤Þ¤¹¡£

    • 55 ¡Á 60 ¹ÔÌÜ

      ľÁ°¤Ë¥Ç¥£¥¹¥×¥ì¥¤¥Þ¥¯¥í¤Ç¼èÆÀ¤·¤¿¥¹¥¯¥ê¡¼¥ó¤Î¿¼¤µ¤¬ 16¡¢32 bpp °Ê³°¤Î¾ì¹ç¤Ï¡¢¤³¤³¤Ç½ªÎ» ¤·¤Æ¤¤¤Þ¤¹¡£

    • 63 ¡Á 68 ¹ÔÌÜ

      ²èÁüɽ¼¨ÍѤΥ¦¥£¥ó¥É¥¦¤òºîÀ®¤·¤Æ¤¤¤Þ¤¹¡£´û¤ËÆɤ߹þ¤ßºÑ¤ß¤Î DIB ¥Õ¥¡¥¤¥ë¾ðÊó¤ò»È¤Ã¤Æ¥¦ ¥£¥ó¥É¥¦¤ÎÉý¤È¹â¤µ¤ò»ØÄꤷ¤Æ¤¤¤ëÅÀ¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£

    • 72 ¡Á 73 ¹ÔÌÜ

      xdib_setup() ¤ò¼Â¹Ô¤·¤Æ¡¢Æɤ߹þ¤ó¤À DIB ¥Õ¥¡¥¤¥ë¾ðÊó¤òºîÀ®¤·¤¿¥¦¥£¥ó¥É¥¦¤Ëɽ¼¨¤Ç¤­¤ë ¤è¤¦¤Ë¤¹¤ë¤¿¤á¤Î½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£½èÍýÆâÍƤò¤ª¤ª¤Þ¤«¤Ë¸À¤¦¤È¡¢Æɤ߹þ¤ó¤À DIB ¥Õ¥¡¥¤¥ë¤Î¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤È XImage ¹½Â¤ÂÎÊÑ¿ô¤ò´Ø·¸ÉÕ¤±¡¢¤½¤Î XImage ¹½Â¤ÂÎÊÑ¿ô¤ò»È¤Ã¤ÆºÇ½ªÅª¤Ë ¥¦¥£¥ó¥É¥¦¤Ëɽ¼¨¤¹¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë pixmap ¤Ë²èÁü¤ò¥í¡¼¥É¤·¤Æ¤¤¤Þ¤¹¡£¾ÜºÙ¤Ï¸å½Ò¤·¤Þ¤¹¡£

    • 82 ¡Á 92 ¹ÔÌÜ

      Expose ¥¤¥Ù¥ó¥È¤ËÂФ¹¤ë¥¤¥Ù¥ó¥È½èÍýÉô¤Ç¤¹¡£¤³¤³¤Ç¤Ï¡¢xdib_setup() ¤Ë¤è¤Ã¤Æ²èÁü¤¬ ¥í¡¼¥É¤µ¤ì¤¿ pixmap ¤ÎÆâÍƤò XCopyArea() ¤ò»È¤Ã¤Æ¤½¤Î¤Þ¤Þ¥¦¥£¥ó¥É¥¦¤Ë¥³¥Ô¡¼¤·¤Æ¤¤¤Þ¤¹¡£

  • 105 ¡Á 242 ¹ÔÌÜ ( xdib_readFile() )

    DIB ¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ó¤Ç¡¢DIBImage ·¿ÊÑ¿ô¤Ë¾ðÊó¤ò³ÊǼ¤¹¤ë´Ø¿ô¤Ç¤¹¡£¤³¤Î´Ø¿ôÆâ¤Ç¤Ï¡¢ DIB ¥Õ¥¡¥¤¥ë¤Î·Á¼° ¤Ë¤ª¤¤¤Æ¼è¤ê¾å¤²¤¿É¬ÍפʾðÊó¤òÆɤ߹þ¤ó¤Ç°ú¿ô ¤Ç»ØÄꤵ¤ì¤¿ DIBImage ·¿ÊÑ¿ôÎΰè¤ËÆâÍƤò³ÊǼ¤·¤Æ¤¤¤ë¤À¤±¤Ç¤¹¡£ÆäËÃí°Õ¤¹¤Ù¤­ÅÀ¤Ë¤Ä¤¤¤Æ¡¢ °Ê¹ß¤ÇÀâÌÀ¤·¤Þ¤¹¡£

    • 167 ¡Á 178 ¹ÔÌÜ

      DIB ¥Õ¥¡¥¤¥ë¤Î·Á¼° ¤Ç¼è¤ê¾å¤²¤¿ biClrUsed ¤¬ 0 ¤Î¾ì¹ç¤Ï¡¢¿§¿ô¤ò 2 ¤Î biOffBits ¾è¤È¤·¤Æ·×»»¤·¡¢biClrUsed ¤¬ 0 ¤Ç¤¢¤ë¾ì¹ç¤Ë¤Ï¤½¤ì¤ò¿§¿ô¤È¤·¤Æ¤¤¤Þ¤¹¡£

    • 205 ¡Á 214 ¹ÔÌÜ

      ¥«¥é¡¼¥Ñ¥ì¥Ã¥È¥Ç¡¼¥¿¤òÆɤ߹þ¤ó¤Ç¤¤¤Þ¤¹¡£DIB ¥Õ¥¡¥¤¥ëÆâ¤Î¥Ñ¥ì¥Ã¥È¥Ç¡¼¥¿¤Ç¤Ï¡¢µ±ÅÙ¤¬ÀÄ¡¢ ÎС¢À֤νç¤Ëʤó¤Ç¤¤¤ë¤Î¤ËÂФ·¤Æ DIBImage ¹½Â¤ÂΤΠpalette ¥á¥ó¥Ð¤Ë¤ÏÀÖ¡¢ÎС¢ÀĤνç¤Ë µÍ¤áľ¤·¤Æ¤¤¤ëÅÀ¤ËÃí°Õ¤·¤Æ²¼¤µ¤¤¡£

    • 217 ¡Á 218 ¹ÔÌÜ

      DIB ¥Õ¥¡¥¤¥ëÆâ¤Î¥Ô¥¯¥»¥ë¥Ç¡¼¥¿ 1 ¹Ôʬ¤Î¥Ð¥¤¥È¿ô¤ò·×»»¤·¤Æ¤¤¤Þ¤¹¡£DIB ¥Õ¥¡¥¤¥ëÆâ¤Ç¤Ï¡¢ 1 ¹Ô¤Î¥Ð¥¤¥È¿ô¤ò 4 ¥Ð¥¤¥È¶­³¦¤Ë¹ç¤ï¤»¤ë¤¿¤á¤Ë¥Ñ¥Ç¥£¥ó¥°¤µ¤ì¤Æ¤¤¤ë¤¿¤á¡¢²èÁüÉý¤Ë 1 Èֶᤤ 4 ¤ÎÇÜ¿ô¤È¤·¤Æ·×»»¤·¤Æ¤¤¤Þ¤¹¡£

          /* ²èÁü¤Î 1 ¹Ôʬ¤Î¥Ð¥¤¥È¿ô¤Ï¡¢²èÁü¤ÎÉý¤Ë 1 Èֶᤤ 4 ¤ÎÇÜ¿ô¤Ë·«¤ê¾å¤²¤é¤ì¤ë */
             bw = ( dib_image->width + 3 ) & ~3;
      
      

      ¾å¤Î¥³¡¼¥É¤Ç ~3 ( 2¿Ê¿ô¤Ç 11111100 )¤È AND ±é»»¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢¤³¤ì¤Ï 11111100 ¤È ¤Î AND ¤ò¼è¤ë¤³¤È¤Ç²¼°Ì 2 ¥Ó¥Ã¥È¤òÍ¤Æ¤¤¤Þ¤¹¡£dib_image->width + 3 ¤Ë¤è¤Ã¤Æ¡¢²èÁü ¤ÎÉý¤Ë 1 Èֶᤤ 4 ¤ÎÇÜ¿ô¤â¤·¤¯¤Ï¤½¤ì¤è¤ê 1 ¡Á 3 Â礭¤¤¿ôÃͤ¬ÆÀ¤é¤ì¤ë¤Î¤Ç¡¢ ¤½¤Î¿ôÃͤβ¼°Ì 2 ¥Ó¥Ã¥È¤òÍ( 0 ¡Á 3 ¤Î¿ôÃͤòÀڼΤƤë ) ¤³¤È¤Ë¤è¤Ã¤Æ 1 Èֶᤤ 4 ¤ÎÇÜ¿ô¤ò·×»»¤·¤Æ¤¤¤Þ¤¹¡£

    • 221 ¡Á 238 ¹ÔÌÜ

      ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤òÆɤ߹þ¤ó¤Ç¤¤¤Þ¤¹¡£DIB ¥Õ¥¡¥¤¥ëÆâ¤Ç¤Ï¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤Ï²¼¹Ô¤«¤é½ç¤ËµÍ¤á¤é¤ì¤Æ¤¤¤ë¤Î¤ËÂФ·¤Æ¡¢ DIBImage ¹½Â¤ÂΤΠdata ¥á¥ó¥Ð¤Ë¤Ï¾å¹Ô¤«¤é½ç¤ËµÍ¤á¤ë¤¿¤á¡¢Æɤ߹þ¤ó¤À¥Ç¡¼¥¿¤ò³ÊǼ¤¹¤ë ¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¤¢¤é¤«¤¸¤á·×»»¤·¤Æ¤«¤éÆɤ߹þ¤ß¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£

  • 245 ¡Á 325 ¹ÔÌÜ ( xdib_setup() )

    DIBImage ·¿ÊÑ¿ô¤ËÆɤ߹þ¤ó¤À²èÁü¾ðÊó¤ò pixmap ¤Ë¥í¡¼¥É¤·¤Æ¥¦¥£¥ó¥É¥¦¤Ë¥³¥Ô¡¼¤Ç¤­¤ë¤è¤¦¤Ë¤¹¤ë¤¿¤á¤Î ½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£

    Æɤ߹þ¤ó¤À¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤È¥Ñ¥ì¥Ã¥È¥Ç¡¼¥¿¤ò»È¤Ã¤Æ¡¢¥¦¥£¥ó¥É¥¦¤ËÂФ·¤Æ XDrawPoint() ¤ÇÁ´¤Æ¤ÎÅÀ¤òÉÁ²è¤·¤Æ¤âɽ¼¨¤Ç¤­¤ë¤Î¤Ç¤¹¤¬¡¢¤½¤ì¤Ç¤Ï¥Í¥Ã¥È¥ï¡¼¥¯ÃÙ±ä¤Ë¤è¤ë±Æ¶Á¤¬Â礭¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤¹¡£ ¤½¤ì¤òÈò¤±¤ë¤¿¤á¤Ë¡¢¤Þ¤º¥¯¥é¥¤¥¢¥ó¥È¦¤Ë¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤ò³ÊǼ¤Ç¤­¤ë XImage ¹½Â¤ÂΤòºîÀ®¤·¤Æ¡¢¤½¤³¤ËÆɤ߹þ¤ó¤À¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤ò³ÊǼ¤·¤Þ¤¹¡£¤½¤Î¸å¤Ç X ¥µ¡¼¥Ð¦¤Î Pixmap ¤Ë¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤ò°ìµ¤¤ËžÁ÷¤·¤Þ¤¹¡£

    ¤Ê¤ª¡¢Pixmap ¤Ç¤Ï¤Ê¤¯É½¼¨ÍÑ¥¦¥£¥ó¥É¥¦¤ËľÀÜžÁ÷¤·¤Æ¤â¹½¤¤¤Þ¤»¤ó¤¬¡¢¤½¤Î¾ì¹ç¡¢É½¼¨ÍÑ ¥¦¥£¥ó¥É¥¦¤¬Ê̤Υ¦¥£¥ó¥É¥¦¤Ë±£¤ì¤¿¤ê¤·¤ÆÉÁ²èÆâÍƤ¬¼º¤ï¤ì¤¿¾ì¹ç¤ËºÆÅÙ¥¯¥é¥¤¥¢¥ó¥È¦¤«¤é ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤òžÁ÷¤·¤Ê¤ª¤µ¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£Pixmap ¤ËžÁ÷¤·¤Æ¤ª¤±¤Ð¡¢¥µ¡¼¥Ð¦¤Ç¤ÎžÁ÷¤À¤±¤ÇºÑ¤ß¤Þ¤¹¡£

    ¶ñÂÎŪ¤Ê½èÍýÆâÍƤˤĤ¤¤Æ¤Ï¡¢°Ê¹ß¤ÇÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

    • 265 ¡Á 276 ¹ÔÌÜ

      DIBImage ·¿ÊÑ¿ô¤Ë³ÊǼ¤µ¤ì¤¿¥«¥é¡¼¥Ñ¥ì¥Ã¥È¥Ç¡¼¥¿¤ò¡¢XColor ·¿¤Î·Á¼°¤ËÊÑ´¹¤·¤Æ¤¤¤Þ¤¹¡£ ³Æ¸¶¿§¤Îµ±ÅÙ¤ò 257 Çܤ·¤Æ¤¤¤ë¤Î¤Ï¡¢DIBImage ¤Î¥Ñ¥ì¥Ã¥È¥Ç¡¼¥¿¤Îµ±ÅÙ¤¬ 0 ¡Á 255 ¤Ç¤¢¤ë¤Î¤ËÂФ·¤Æ¡¢ X ¤Î¥«¥é¡¼¥Þ¥Ã¥×¤Ç¤Ï 0 ¡Á 65535 ¤ÎÈϰϤǻØÄꤹ¤ë¤¿¤á¤Ç¤¹¡£

      XColor ·Á¼°¤ËÊÑ´¹¤·¤¿¸å¤Ï¡¢XAllocColor() ¤ÇÂбþ¤¹¤ë¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤·¤Æ¤¤¤Þ¤¹¡£

    • 286 ¡Á 302 ¹ÔÌÜ

      DIBImage ·¿ÊÑ¿ô¤Ë³ÊǼ¤µ¤ì¤¿¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤ò Pixmap ¤ËžÁ÷¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¸åÄø XImage ¹½Â¤ÂΤòºîÀ®¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¤¬¡¢¤½¤ÎºÝ¤ËɬÍפȤʤë¥Ô¥¯¥»¥ë¥Ç¡¼¥¿³ÊǼÎΰè¤òºîÀ®¤·¤Æ¤¤¤Þ¤¹¡£ ¥¹¥¯¥ê¡¼¥ó¤Î¿¼¤µ¤¬ 16¡¢32 bpp ¤Î¾ì¹ç¤Ï¤½¤ì¤¾¤ì 1 ¥Ô¥¯¥»¥ë¤ò 2¡¢4 ¥Ð¥¤¥È¤Ç³ÊǼ¤¹¤ë¤¿¤á¡¢ ¥µ¥ó¥×¥ë¤ÎÍͤʥ³¡¼¥É¤Î½ñ¤­Êý¤ò¤·¤Æ¤¤¤Þ¤¹¡£24 bpp ¤Î¾ì¹ç¤Ï¡¢3 ¥Ð¥¤¥È¤Çɽ¤¹¾ì¹ç¤ä 4 ¥Ð¥¤¥È¤Ç³ÊǼ¤¹¤ë¾ì¹ç¤¬¤¢¤ë¤¿¤á¡¢ ¾õ¶·¤Ë±þ¤¸¤Æ½ñ¤­Êý¤òÊѤ¨¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ ¤³¤ì¤Ë¤ÏÍøÍÑÃæ¤Î X ¥µ¡¼¥Ð¤Ç¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë Pixmap ¥Õ¥©¡¼¥Þ¥Ã¥È¤ò XListPixmapFormats Åù¤ÇÄ´¤Ù¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¤¬¡¢¤³¤³¤Ç¤Ï 16¡¢32 bpp ¤Ë´Ä¶­¤ò¸ÂÄꤷ¤ÆÏäò´Êñ¤Ë¤·¤Æ¤¤¤Þ¤¹¡£

      Φ¤µ¤ó¡¢¾ðÊ󤢤꤬¤È¤¦¤´¤¶¤¤¤Þ¤·¤¿¡ª(2004/11/28)

      DIBImage ·¿ÊÑ¿ô¤Ë³ÊǼ¤µ¤ì¤¿¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤Ï¡¢¥Ñ¥ì¥Ã¥È¥Ç¡¼¥¿¤Î²¿ÈÖÌܤ理Çɽ¼¨¤¹¤ë¤«¤òɽ¤·¤Æ¤¤¤Þ¤¹¡£ ¥Ñ¥ì¥Ã¥È¥Ç¡¼¥¿¤Î³Æ¿§¤ò¡¢¤½¤Î½çÈÖÄ̤ê¤Î¥Ô¥¯¥»¥ëÃͤdzÎÊݤǤ­¤ì¤ÐÎɤ¤¤Î¤Ç¤¹¤¬¡¢16 bpp °Ê¾å¤Î¿¼¤µ¤Î¥¹¥¯¥ê¡¼¥ó¤Î¾ì¹ç¤Ï¥«¥é¡¼¥Þ¥Ã¥×¤Î¹½Â¤¾åÉÔ²Äǽ¤Ç¤¹ ( 1 ¤Ä¤Î¥Ô¥¯¥»¥ëÃͤò²¿¥Ó¥Ã¥È¤º¤Ä¤«¤Ëʬ¤±¤Æ¡¢ ¤½¤ì¤¾¤ì¤¬ÀÖ¡¢ÎС¢ÀĤËÂбþ¤¹¤ë¥Ô¥¯¥»¥ëÃͤȤʤ뤫¤é¡£¤Ê¤ª 8 bpp °Ê²¼¤Î¾ì¹ç¤Ï²Äǽ¤Ç¤¹¤¬¡¢¤½¤Î¾ì¹çºÇÂç 256 ¿§¤ò³ÎÊݤ¹¤ë¤¿¤á¤Ë¤Ï¡¢ÀìÍѤΥ«¥é¡¼¥Þ¥Ã¥×¤òºîÀ®¤·¤Æ XStoreColor() ¤ÇǤ°Õ¤Î¥Ô¥¯¥»¥ëÃͤ˿§¤òÀßÄꤹ¤ëɬÍפ¬¤¢¤ê¤Þ¤¹)¡£

      ¤è¤Ã¤Æ¡¢XAllocColor() ¤ÇÆÀ¤¿³Æ¿§¤ËÂбþ¤¹¤ë¥Ô¥¯¥»¥ëÃͤò»È¤Ã¤Æ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤òÊÑ´¹¤·¤Æ¤¤¤Þ¤¹¡£ ÊÑ´¹¸å¤Î¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤Ï img_data ¤Ë³ÊǼ¤µ¤ì¤Þ¤¹¤¬¡¢³Æ¥Ô¥¯¥»¥ë¤Î¥Ô¥¯¥»¥ëÃͤò³ÊǼ¤·¤Æ¤¤¤ëÅÀ¤ËÃí°Õ¤·¤Æ²¼¤µ¤¤¡£

    • 305 ¡Á 313 ¹ÔÌÜ

      XCreateImage() ¤ò»È¤Ã¤Æ¡¢¥¯¥é¥¤¥¢¥ó¥È¦¤Ë¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤ò³ÊǼ¤¹¤ë¤¿¤á¤ÎÎΰè¤Ç¤¢¤ë XImage ¹½Â¤ÂΤòºîÀ®¤·¤Æ¤¤¤Þ¤¹¡£

          XImage* XCreateImage( Display*     dpy,
                                Visual*      visual,
                                unsigned int depth,
                                int          format,
                                int          offset,
                                char*        data,
                                unsigned int width,
                                unsigned int height,
                                int          bitmap_pad,
                                int          bytes_per_line
                              );
           
          depth          : ²èÁü¤Î¿¼¤µ
          format         : XYBitmap / XYPixmap / ZPixmap ¤Î¤¤¤º¤ì¤«
          offset         : ²èÁü¥Ç¡¼¥¿¤Î³ÆÁöººÀþ¤ÎÀèƬ¤Ç̵»ë¤¹¤ë¥Ô¥¯¥»¥ë¿ô
          data           : ²èÁü¥Ç¡¼¥¿Îΰè¤Ø¤Î¥Ý¥¤¥ó¥¿
          width          : ²èÁü¤ÎÉý
          height         : ²èÁü¤Î¹â¤µ
          bitmap_pad     : ²èÁü¥Ç¡¼¥¿¤Î¤¢¤ëÁöººÀþ¤ÎÀèƬ¤«¤é¼¡¤ÎÁöººÀþ¤ÎÀèƬ¤Þ¤Ç¤Î¥Ó¥Ã¥È¿ô
                           ¤¬ 8¡¢16¡¢32 ¤Î¤¤¤º¤ì¤Î¿ô¤Ç³ä¤êÀÚ¤ì¤ë¤«¤ò»ØÄꤹ¤ë
          bytes_per_line : ²èÁü¥Ç¡¼¥¿¤Î 1 ÁöººÀþ¤Î¥Ð¥¤¥È¿ô
      
      

      Âè 4 °ú¿ô¤Î format ¤Ë»ØÄꤹ¤ë XYBitmap / XYPixmap / ZPixmap ¤Ë¤Ä¤¤¤Æ¤Ç¤¹¤¬¡¢¤³¤ì¤ÏÂè 6 °ú¿ô¤Î data ¤Î·Á¼°¤ò»ØÄꤹ¤ëÃͤǤ¹¡£XYBitmap ¤Î¾ì¹ç¡¢data ¤ÎÃͤϥӥåȥޥåץǡ¼¥¿ ( 0 ¤â¤·¤¯¤Ï 1 ) ¤¬ÁöººÀþ½ç¤Ëʤó¤Ç¤¤¤ë¤È²ò¼á¤µ¤ì¤Þ¤¹¡£XYPixmap ¤Î¾ì¹ç¤Ï¡¢¥Ó¥Ã¥È¥Þ¥Ã¥×¤Î¥Ç¡¼¥¿¤¬ ¥×¥ì¡¼¥ó¤´¤È¤ËʤӤޤ¹¡£ZPixmap ¤ò»ØÄꤷ¤¿¾ì¹ç¡¢¥Ô¥¯¥»¥ëÃͤ¬ÁöººÀþ½ç¤Ëʤó¤Ç¤¤¤ë¤È²ò¼á¤µ¤ì¤Þ¤¹¡£ xdib.c ¤Ç¤Ï¥Ô¥¯¥»¥ëÃͤˤè¤Ã¤Æ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤ò»ØÄꤹ¤ë¤³¤È¤Ë¤·¤¿¤¿¤á¡¢ZPixmap ¤ò»ØÄꤷ¤Æ¤¤¤Þ¤¹¡£

      Âè 10 °ú¿ô¤Î bytes_per_line ¤Ï¡¢²èÁü¥Ç¡¼¥¿¤Î 1 ÁöººÀþ¤òɽ¤¹¤¿¤á¤Ë data ¤Ë³ÊǼ¤·¤Æ¤¤¤ë¥Ð¥¤¥È¿ô¤ò»ØÄꤷ¤Þ¤¹¡£¤³¤³¤ò 0 ¤ËÀßÄꤷ¤¿¾ì¹ç¡¢Â¾¤Î¥Ñ¥é¥á¡¼¥¿¤Ë½¾¤Ã¤Æ Xlib ¤¬¼«Æ°Åª¤Ë·×»»¤·¤Æ¤¯¤ì¤Þ¤¹¡£

    • 313 ¡Á 318 ¹ÔÌÜ

      XImage ·¿ÊÑ¿ô¤Ë³ÊǼ¤µ¤ì¤¿¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤ò¡¢XPutImage() ¤ò»È¤Ã¤Æ X ¥µ¡¼¥Ð¦¤Î¥Ô¥¯¥¹¥Þ¥Ã¥×¤ËžÁ÷¤·¤Æ¤¤¤Þ¤¹¡£ ¤³¤ì¤Ë¤è¤ê¡¢¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤òºÆÅÙ¥µ¡¼¥Ð¦¤ËžÁ÷¤¹¤ëɬÍפ¬Ìµ¤¯¤Ê¤ê¤Þ¤¹¡£ ¤³¤³¤Ç¥Ô¥¯¥¹¥Þ¥Ã¥×¤ÎÂå¤ï¤ê¤Ëɽ¼¨ÍÑ¥¦¥£¥ó¥É¥¦¤ËžÁ÷¤¹¤ì¤Ð¡¢Ä¾ÀÜɽ¼¨¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

          XPutImage( Display*     dpy, 
                     Drawable     d,
                     GC           gc,
                     XImage*      image,
                     int          src_x, src_y,
                     int          dest_x, dest_y,
                     unsigned int width, height
                   );
      
          src_x,  src_y   : žÁ÷¸µ¥¤¥á¡¼¥¸¤ÎžÁ÷Îΰ躸¾å³Ñ¤ÎºÂɸ
          dest_x, dest_y  : žÁ÷À襤¥á¡¼¥¸¤ÎžÁ÷Îΰ躸¾å³Ñ¤ÎºÂɸ
          width,  height  : žÁ÷Îΰè¤ÎÉý¤È¹â¤µ
      
      

    • 322 ¹ÔÌÜ

      XFlush() ¤ò¼Â¹Ô¤·¤Æ¥ê¥¯¥¨¥¹¥È¥Ð¥Ã¥Õ¥¡¤ò¥Õ¥é¥Ã¥·¥å¤µ¤»¡¢¥Ô¥¯¥¹¥Þ¥Ã¥×¤Ø¤ÎžÁ÷Í׵᤬¼ÂºÝ ¤Ë¥µ¡¼¥Ð¤ËÁ÷¤é¤ì¤ë¤Þ¤ÇÂԤäƤ¤¤Þ¤¹¡£

    • 323 ¡Á 324 ¹ÔÌÜ

      xdib_setup() Æâ¤Ç³ÎÊݤ·¤¿¥ê¥½¡¼¥¹¤Î¤¦¤Á¡¢ÉÔÍפˤʤ俤â¤Î¤ò²òÊü¤·¤Æ¤¤¤Þ¤¹¡£³ÎÊݤ·¤¿ XImage ¹½Â¤ÂΤϡ¢XDestroyImage() ¤ò»È¤Ã¤Æ²òÊü¤·¤Þ¤¹¡£

          XDestroyImage( XImage* ximage );
      
      

      XCreateImage()¡¢XGetImage()¡¢XGetSubImage() ¤Çºî¤Ã¤¿ XImage ·¿ÊÑ¿ôÎΰè¤ò²òÊü¤¹¤ë¾ì¹ç¡¢ XImage ·¿ÊÑ¿ôÎΰ褽¤Î¤â¤Î¤È data ¤Ç»ØÄꤵ¤ì¤ë¥Ç¡¼¥¿Îΰè¤ÎξÊý¤¬²òÊü¤µ¤ì¤Þ¤¹¡£¤³¤Î»þ¥Ç¡¼¥¿Îΰ褬 static Îΰè¤Ë³ÎÊݤµ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¥á¥â¥ê¤ò²òÊü¤Ç¤­¤Ê¤¤¤¿¤á¡¢data ¥á¥ó¥Ð¤Ë NULL ¤òÀßÄꤹ¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£

°Ê¾å¤Ç xdib.c ¤ÎÀâÌÀ¤Ï½ª¤ê¤Ç¤¹¡£°Ê¹ß¤Ç¤Ï¡¢¤³¤³¤Þ¤Ç¤Ç¾Ò²ð¤·¤Æ¤¤¤Ê¤¤ XImage ¹½Â¤ÂΥǡ¼¥¿ÁàºîÍѤΤ¤¤¯¤Ä¤«¤Î´Ø¿ô¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

¡û¥¦¥£¥ó¥É¥¦¤â¤·¤¯¤Ï¥Ô¥¯¥¹¥Þ¥Ã¥×¤Î²èÁü¥Ç¡¼¥¿¤ò¼èÆÀ¤¹¤ë

¥¦¥£¥ó¥É¥¦¤â¤·¤¯¤Ï¥Ô¥¯¥¹¥Þ¥Ã¥×¤Î²èÁü¥Ç¡¼¥¿¤ò¥¯¥é¥¤¥¢¥ó¥È¦¤Ë¼èÆÀ¤¹¤ë¤Ë¤Ï¡¢XGetImage() ¤ò»È¤¤¤Þ¤¹¡£

XImage* XGetImage( Display*      dpy, 
                   Drawable      d, 
                   int           x, y, 
                   unsigned int  width, height,
                   unsigned long plane_mask,
                   int           format
                 );

d             : ²èÁü¥Ç¡¼¥¿¤ò¼èÆÀ¤·¤¿¤¤ Drawable ¤ò»ØÄê
x, y          : ²èÁü¥Ç¡¼¥¿¤ò¼èÆÀ¤·¤¿¤¤Îΰè¤Îº¸¾å³Ñ¤ÎºÂɸ
width, height : ²èÁü¥Ç¡¼¥¿¤ò¼èÆÀ¤·¤¿¤¤Îΰè¤ÎÉý¤È¹â¤µ
plane_mask    : ²èÁü¥Ç¡¼¥¿¤ò¼èÆÀ¤·¤¿¤¤¥×¥ì¡¼¥ó¤ò»ØÄê
format        : XYBitmap / XYPixmap / ZPixmap ¤Î¤¤¤º¤ì¤«

plane_mask ¤Ë¤Ï²èÁü¥Ç¡¼¥¿¤ò¼èÆÀ¤·¤¿¤¤¥×¥ì¡¼¥ó¤ò¥Þ¥¹¥¯»ØÄꤷ¤Þ¤¹¡£Xlib.h ¤Ë AllPlanes ¤È¤¤¤¦Äê¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Æ¡¢¤³¤ì¤ò»ØÄꤹ¤ë¤ÈÁ´¤Æ¤Î¥×¥ì¡¼¥ó¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

¡û¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤òÁàºî¤¹¤ë

XImage ·¿ÊÑ¿ô¤ËÂФ·¤Æ¥Ô¥¯¥»¥ë¥Ç¡¼¥¿¤ÎÁàºî¤ò¤¹¤ë´Ø¿ô¤ò°Ê²¼¤Ë¤Þ¤È¤á¤Æ¾Ò²ð¤·¤Þ¤¹¡£

unsigned long XGetPixel( XImage* ximage, int x, int y );
XPutPixel( XImage* ximage, int x, int y, unsigned long pixel );
XAddPixel( XImage* ximage, long value );

XGetPixel() ¤Ï¡¢x¡¢y ¤Ç»ØÄꤷ¤¿°ÌÃ֤Υԥ¯¥»¥ë¥Ç¡¼¥¿¤Î¥Ô¥¯¥»¥ëÃͤò¼èÆÀ¤·¤Þ¤¹¡£XPutPixel() ¤Ï¡¢»ØÄꤷ¤¿°ÌÃ֤Υԥ¯¥»¥ë¥Ç¡¼¥¿¤Ë»ØÄꤷ¤¿¥Ô¥¯¥»¥ëÃͤòÀßÄꤷ¤Þ¤¹¡£XAddPixel() ¤Ï¡¢Á´¤Æ¤Î¥Ô¥¯¥»¥ëÃͤ˻ØÄꤷ¤¿Ãͤò²Ã»»¤·¤Þ¤¹¡£