📄 floodf1.c
字号:
/************************************************************************* * 2D Graphics Library * * ALL RIGHTS RESERVED, COPYRIGHT (C) FUJITSU LIMITED 1993-2002 * * LICENSED MATERIAL - PROGRAM PROPERTY OF FUJITSU LIMITED * *************************************************************************//*=======================================================================* Sample program for painting with mask pattern (GL_floodfill) *=======================================================================*/#include "gl.h"/*------------------------------------------------------------------------ * Definition of parameter * * Defines parameter of GL. */#define PAGES 1 /* Number of pages */#define STYLES 2 /* Number of line styles */#define TILES 2 /* Number of tiles */#define IMAGES 2 /* Number of images */#define WIDTH 320 /* Number of horizontal pixels */#define HEIGHT 240 /* Number of vertical pixels */#define TMPAREASIZE 16384 /* Size of temporary buffer */#define VRAMTYPE GL_VRAM16M /* Type of VRAM */#define PLANES 1 /* Number of Planes */#define HOOKTABLE _GL_defhook16m /* Hook table for implement */ /* modules *//*------------------------------------------------------------------------ * VRAM area * * Defines VRAM area. * In this sample, VRAM area is defined in other source file. * * If VRAM area is fixed in hardware, specify address directory. * [Example] * #define Vram (void *)0x00400000 *//*-- Begin : Hardware dependence ----------------*/unsigned char *Vram;/*-- End : Hardware dependence ----------------*//*------------------------------------------------------------------------ * Configuration table * * In configuration table, type of VRAM to be used, maximum number of * each definitions, etc. are described. */const GL_CONFIG video_config = { VRAMTYPE, /*VRAMmode ; VRAM type */ /* GL_VRAM1 (0) 1bit *1plane */ /* GL_VRAM16P (1) 1bit * 4planes */ /* GL_VRAM16 (2) 4bits* 1plane */ /* GL_VRAM256 (3) 8bits* 1plane */ /* GL_VRAM256G (4) 8bits* 1plane */ /* GL_VRAM64K (5) 16bits* 1plane */ /* GL_VRAM16MP (6) 8bits* 3planes */ /* GL_VRAM16MH (7) 16bits* 3planes */ /* GL_VRAM16M (8) 24bits* 1plane */ 0, /*VRAMbpl ; bytes per line of VRAM */ /* 0:automatic */ (void *)0, /* VRAMtbl ; pointer of VRAM address table */ &HOOKTABLE, /* *hook ; pointer of a hook table */ PAGES, /* pages ; VRAM pages */ WIDTH, /* width ; VRAM width */ HEIGHT, /* lines ; VRAM height */ STYLES, /* styles ; maximum of line styles */ TILES, /* tiles ; maximum of tile patterns */ IMAGES, /* images ; maximum of images */ 1, /* linesize ; standard line size */ 0 /* ciradj ; adjustment of circle (n:256) */} ;/*------------------------------------------------------------------------ * Work area * * This is work area for Graphics Library. Accurate size of a temporary * buffer in this area (defined as TMPAREASIZE here) depends on type of * VRAM, the number of definition of tiles, etc. For detailed information, * refer to specification. * * Work area must be stored at 64 bit address boundary. Entry point of * work area is corrected in sample program (UserMain()). */char glwork[GL_WORKSIZE(PAGES,STYLES,TILES,IMAGES,TMPAREASIZE)+8] ;/*------------------------------------------------------------------------ * Definition of mask pattern * * Defines a mask pattern. * GL treats a mask pattern as stored in 32x32 bits area. If the pattern * doesn't begin at 4 bytes boundary address or size of the mask pattern * is not 32x32 pixels, GL may not work correctly. */const unsigned long maskdata[] = { 0xf0f0f0f0, 0x78787878, 0x3c3c3c3c, 0x1e1e1e1e, 0x0f0f0f0f, 0x87878787, 0xc3c3c3c3, 0xe1e1e1e1, 0xf0f0f0f0, 0x78787878, 0x3c3c3c3c, 0x1e1e1e1e, 0x0f0f0f0f, 0x87878787, 0xc3c3c3c3, 0xe1e1e1e1, 0xf0f0f0f0, 0x78787878, 0x3c3c3c3c, 0x1e1e1e1e, 0x0f0f0f0f, 0x87878787, 0xc3c3c3c3, 0xe1e1e1e1, 0xf0f0f0f0, 0x78787878, 0x3c3c3c3c, 0x1e1e1e1e, 0x0f0f0f0f, 0x87878787, 0xc3c3c3c3, 0xe1e1e1e1,} ;const GL_IDSC mask_dsc = { (void *)maskdata, 32, 32, GL_MONO, GL_D1, 0, 0} ;#define WHITE 0xffffff#define YELLOW 0xffff00/*--------------------------------------------------------------------------- * Main program * * This is a sample program of painting with mask pattern. * UserMain function is called from main function in main.c. * Initializes GL, and draws a circle, and paints in it with mask pattern. * */int main(){ GL_WP *gp ; int err ; long n, workmax ; /*-- Begin : Hardware dependence -----------------------*/ /* */ Vram =(unsigned char*) vdc_init(); /* */ /*-- End : Hardware dependence -----------------------*/ n = -(long)glwork & 7 ; gp = (GL_WP *)((long)glwork+n) ; workmax = sizeof(glwork)-n ; GL_setup(gp, workmax, Vram, (GL_CONFIG *)&video_config) ; GL_init(gp,0) ; GL_color(gp, GL_DRAWC, WHITE) ; GL_circle(gp, 128, 120, 60) ; GL_filltype(gp, GL_FRAME | GL_MASK) ; GL_color(gp, GL_FILLC, YELLOW) ; GL_setimage(gp, 1, (GL_IDSC *)&mask_dsc) ; GL_mask(gp, 1) ; GL_floodfill(gp, WHITE, 128, 120) ; /*-- Begin : Hardware dependence -------------------*/ /* */ /* Add routine for displaying image in pseudo VRAM */ /* */ /*-- End : Hardware dependence -------------------*/ return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -