home *** CD-ROM | disk | FTP | other *** search
/ Phoenix Heaven Sunny 2 / APPARE2.BIN / oh_towns / art2 / src.lzh / PIC.H < prev    next >
C/C++ Source or Header  |  1995-06-19  |  3KB  |  103 lines

  1. #ifndef HEADER_PIC
  2. #define HEADER_PIC
  3.  
  4. #include "screen.h"
  5. #include "pen.h"
  6. #include "area.h"
  7.  
  8.   /* 画像 */
  9.  
  10.     typedef struct {
  11.         int        wid,ht;
  12.         char    *buf;
  13.         FRAME    update;
  14.         int pixelsize;
  15.     } PIC;
  16.  
  17.   /* ピクセルの色 */
  18.  
  19.     typedef struct {
  20.         char r,g,b;
  21.     } PIXEL;
  22.  
  23. int        pic_init(void);
  24. void    pic_close(void);
  25. PIC        *pic_new(int pixelsize,int width,int height);
  26. PIC* pic_dup(PIC* pic);
  27. void    pic_destroy(PIC *pic);
  28. #define    pic_delete pic_destroy
  29.  
  30. void pic_setPixelXy(PIC *pic, int x, int y, PIXEL *pixel);
  31. void pic_getPixelXy(PIC *pic, int x, int y, PIXEL *pixel);
  32.  
  33. void pic_grayPset(PIC* pic,int x,int y,int gray,PIXEL *pixel);
  34. void pic_grayhline(PIC *pic,int x1,int x2,int y,int gray,PIXEL *pixel);
  35. void pic_psetpen(PIC *pic,int x,int y,Pen pen,PIXEL *pixel);
  36. void pic_putGrayBlock(PIC *pic,int x,int y,
  37.                       char *graypat,int wid,int ht, PIXEL *pixel);
  38. void pic_clear(PIC *pic, PIXEL *pixel);
  39. void pic_kosuriStart(PIC* pic,int x,int y,char* graypat,int wid,int ht);
  40. void pic_kosuriDrag(PIC* pic,int x,int y,int r);
  41.  
  42. void pic_beginUpDate(PIC *pic);
  43. void pic_endUpDate(PIC *pic, FRAME *frame);
  44.  
  45. void pic_copy(PIC* picSrc, FRAME* frSrc, PIC* picDest, POINT* ptDest);
  46.     // update 管理を忘れないこと!
  47. void pic_copyarea(PIC* picSrc, AREA areaSrc, PIC* picDest, POINT* ptDest);
  48. void pic_paint(PIC *pic, int x,int y, PIXEL* pix);
  49. void pic_blot(PIC *pic,int x,int y,int branch,int depth,PIXEL* pix);
  50. void pic_diffusePen(PIC* pic,int x,int y,Pen pen);
  51. void pic_sandPen(PIC* pic,int x,int y,Pen pen);
  52. void pic_polygon(PIC* pic,POINT* points,int nPoint,PIXEL* pix);
  53. void pic_fillarea(PIC* pic,AREA area,PIXEL* pix);
  54.  
  55. int pic_loadTIFF_(PIC *pic, char *fname);
  56. int pic_saveTIFF_(PIC *pic, char *fname);
  57. // void    pic_getRectImage( PIC *pic, char *buf, FRAME *fr );
  58.  
  59. void pic_getScrBitMap(PIC* pic, SCRBITMAP bm, int ofsx, int ofsy, FRAME *fr,
  60.                       int zoom);
  61.     // 画像内の fr(x,y,wid,ht) の領域を bm の ofsx, ofsy に転送する
  62. #define    pic_getScrBitmap    pic_getScrBitMap
  63.  
  64. void    pixel_setRgb(PIXEL *pixel, int r, int g, int b);
  65. void    pixel_getRgb(PIXEL *pixel, int *r, int *g, int *b);
  66.  
  67. #define    PICOFFSET(pic,x,y)        (((pic)->wid*(y)+(x))*(pic)->pixelsize /8)
  68.  
  69. #define PICADDR(pic,x,y)   ((pic)->buf + PICOFFSET(pic,x,y))
  70.  
  71. #define    CODE32K(pix)                    \
  72.     ((((unsigned int)(pix).r >> 3) << 5)  |        \
  73.      (((unsigned int)(pix).g >> 3) << 10) |        \
  74.      (((unsigned int)(pix).b >> 3)))
  75.  
  76. #define CODE16M(pix)    \
  77.     (((uint)(pix).g << 8) | ((uint)(pix).r) | ((uint)(pix).b << 16))
  78.  
  79. #define SETBYTE3(p,n)   \
  80.     (*(ushort*)(p)=(ushort)((uint)(n) & 0xffff),    \
  81.      *(((char*)(p))+2) = ((uint)(n)>>16)&0xff)
  82.  
  83. #define GETBYTE3(p)  (*(ushort*)(p)) | (((uint)*((char*)(p)+2)) << 16)
  84.  
  85. #define GET3BYTE(ptr,a,b,c)    ((a)=(ptr)[0],(b)=(ptr)[1],(c)=(ptr)[2])
  86.  
  87. #define COLCODE(pix)  (scrPixelSize==16 ? CODE32K(pix) : CODE16M(pix))
  88.  
  89. #define SETRGB32K(pix, col)                                    \
  90.     ((pix).r = ((((col) >> 5) & 31) * 255 + 15) / 31,        \
  91.      (pix).g = ((((col) >> 10) & 31) * 255 + 15) / 31,        \
  92.      (pix).b = ((((col)      ) & 31) * 255 + 15) / 31)
  93.  
  94. #define GETRGB31(code,r,g,b)        \
  95.     ((g) = ((uint)code >> 10) & 31,    \
  96.      (r) = ((uint)code >> 5) & 31,    \
  97.      (b) = ((uint)code) & 31)
  98.  
  99. #define    SETRGB31(code,r,g,b)    \
  100.     ((code) = ((uint)(g)<<10) | ((uint)(r)<<5) | ((uint)b))
  101.  
  102. #endif HEADER_PIC
  103.