int main() { gdImagePtr im, tile; int tile_red, tile_blue; int error = 0; char path[1024]; im = gdImageCreate(200, 150); tile = gdImageCreateTrueColor(2, 2); tile_red = gdImageColorAllocate(tile, 255, 0, 0); tile_blue = gdImageColorAllocate(tile, 0, 0, 255); gdImageSetPixel(tile, 0, 0, tile_red); gdImageSetPixel(tile, 1, 1, tile_red); gdImageSetPixel(tile, 1, 0, tile_blue); gdImageSetPixel(tile, 0, 1, tile_blue); gdImageSetTile(im, tile); gdImageFill(im, 11, 12, gdTiled); sprintf(path, "%s/gdimagefill/bug00104_1_exp.png", GDTEST_TOP_DIR); if (!gdAssertImageEqualsToFile(path, im)) { error = 1; } gdImageDestroy(im); gdImageDestroy(tile); return error; }
int renderPolygonTiledGD(imageObj *img, shapeObj *p, imageObj *tile) { gdImagePtr ip, tp; if(!img || !p || !tile) return MS_FAILURE; if(!(ip = MS_IMAGE_GET_GDIMAGEPTR(img))) return MS_FAILURE; if(!(tp = MS_IMAGE_GET_GDIMAGEPTR(tile))) return MS_FAILURE; gdImageColorTransparent(tp,0); gdImageSetTile(ip, tp); imageFilledPolygon(ip, p, gdTiled); return MS_SUCCESS; }
int main() { gdImagePtr im, tile; int im_white, im_black, tile_white, tile_black; int x,y, error = 0; FILE *fp; char path[1024]; fputs("flag 0\n", stdout); im = gdImageCreate(150, 150); tile = gdImageCreateTrueColor(36, 36); tile_white = gdImageColorAllocate(tile,255,255,255); tile_black = gdImageColorAllocate(tile,55,0,0); im_white = gdImageColorAllocate(im,255,255,255); im_black = gdImageColorAllocate(im,0,0,0); gdImageFill(tile, 0,0, tile_white); gdImageColorTransparent(tile, tile_black); gdImageColorTransparent(im, im_black); /* create the dots pattern */ for (x=0; x<36; x+=2) { for (y=0; y<36; y+=2) { gdImageSetPixel(tile,x,y,tile_black); } } gdImageSetTile(im,tile); gdImageRectangle(im, 9,9,139,139, im_black); gdImageLine(im, 9,9,139,139, im_black); gdImageFill(im, 11,12, gdTiled); fputs("flag 1\n", stdout); gdImageFill(im, 0, 0, 0xffffff); fputs("flag 2\n", stdout); gdImageFill(im, 0, 0, 0xffffff); fputs("flag 3\n", stdout); sprintf(path, "%s/gdimagefill/bug00002_3_exp.png", GDTEST_TOP_DIR); if (!gdAssertImageEqualsToFile(path, im)) { error = 1; } /* Destroy it */ gdImageDestroy(im); return error; }
int main() { gdImagePtr im, tile; int im_black, tile_black; int x,y, error = 0; /* fputs("flag 0\n", stdout); */ im = gdImageCreate(150, 150); tile = gdImageCreate(36, 36); gdImageColorAllocate(tile,255,255,255); /* allocate white for background color */ tile_black = gdImageColorAllocate(tile,0,0,0); gdImageColorAllocate(im,255,255,255); /* allocate white for background color */ im_black = gdImageColorAllocate(im,0,0,0); /* create the dots pattern */ for (x=0; x<36; x+=2) { for (y=0; y<36; y+=2) { gdImageSetPixel(tile,x,y,tile_black); } } gdImageSetTile(im,tile); gdImageRectangle(im, 9,9,139,139, im_black); gdImageLine(im, 9,9,139,139, im_black); gdImageFill(im, 11,12, gdTiled); /* fputs("flag 1\n", stdout); */ gdImageFill(im, 0, 0, 0xffffff); /* fputs("flag 2\n", stdout); */ gdImageFill(im, 0, 0, 0xffffff); /* fputs("flag 2\n", stdout); */ if (!gdAssertImageEqualsToFile("gdimagefill/bug00002_2_exp.png", im)) { error = 1; } /* Destroy it */ gdImageDestroy(im); gdImageDestroy(tile); return error; }
int main() { gdImagePtr im, tile; char exp[] = "bug00032_exp.png"; FILE *fp; tile = gdImageCreateTrueColor(10, 10); gdImageFill(tile, 0, 0, 0xFFFFFF); gdImageLine(tile, 0,0, 9,9, 0xff0000); gdImageColorTransparent(tile, 0xFFFFFF); im = gdImageCreateTrueColor(50, 50); gdImageFilledRectangle(im, 0, 0, 25, 25, 0x00FF00); gdImageSetTile(im, tile); gdImageFilledRectangle(im, 10, 10, 49, 49, gdTiled); gdAssertImageEqualsToFile(exp_img, im); /* Destroy it */ gdImageDestroy(im); gdImageDestroy(tile); return 0; }
static int setbrushstyle (wmfAPI* API,wmfDC* dc) { wmf_gd_t* ddata = WMF_GD_GetData (API); gd_t* gd = (gd_t*) ddata->gd_data; wmfBrush* brush = 0; wmfBMP* bmp = 0; wmfRGB* rgb = 0; wmfRGB pixel; int i; int j; int fg; int bg; int brushstyle; int opacity; unsigned int x; unsigned int y; unsigned char* bits = 0; brush = WMF_DC_BRUSH (dc); rgb = WMF_BRUSH_COLOR (brush); brushstyle = gdImageColorResolve (gd->image,rgb->r,rgb->g,rgb->b); switch (WMF_BRUSH_STYLE (brush)) { case BS_NULL: WMF_ERROR (API,"Attempt to set null fill-style!"); API->err = wmf_E_Glitch; break; case BS_HATCHED: switch (WMF_BRUSH_HATCH (brush)) { case HS_HORIZONTAL: bits = HS_HORIZONTAL_bits; break; case HS_VERTICAL: bits = HS_VERTICAL_bits; break; case HS_FDIAGONAL: bits = HS_FDIAGONAL_bits; break; case HS_BDIAGONAL: bits = HS_BDIAGONAL_bits; break; case HS_CROSS: bits = HS_CROSS_bits; break; case HS_DIAGCROSS: bits = HS_DIAGCROSS_bits; break; default: if (API->flags & WMF_OPT_IGNORE_NONFATAL) { WMF_DEBUG (API,"Unsupported brush/hatch style!"); bits = HS_DIAGCROSS_bits; } else { WMF_ERROR (API,"Unsupported brush/hatch style!"); API->err = wmf_E_Glitch; bits = 0; } break; } if (bits == 0) break; if (gd->brush.hatch == 0) gd->brush.hatch = gdImageCreateTrueColor (8,8); if (gd->brush.hatch) { rgb = WMF_DC_BACKGROUND (dc); bg = gdImageColorResolve (gd->brush.hatch,rgb->r,rgb->g,rgb->b); if (!WMF_DC_OPAQUE (dc)) { gdImageColorTransparent (gd->brush.hatch,bg); } rgb = WMF_BRUSH_COLOR (brush); fg = gdImageColorResolve (gd->brush.hatch,rgb->r,rgb->g,rgb->b); for (j = 0; j < 8; j++) { for (i = 0; i < 8; i++) { if (bits[j] & (1<<(7-i))) { gdImageSetPixel (gd->brush.hatch,i,j,fg); } else { gdImageSetPixel (gd->brush.hatch,i,j,bg); } } } gdImageSetTile (gd->image,gd->brush.hatch); brushstyle = gdTiled; } break; case BS_DIBPATTERN: bmp = WMF_BRUSH_BITMAP (brush); if (bmp->data == 0) { if (API->flags & WMF_OPT_IGNORE_NONFATAL) { WMF_DEBUG (API,"Attempt to fill with non-existent pattern!"); break; } else { WMF_ERROR (API,"Attempt to fill with non-existent pattern!"); API->err = wmf_E_Glitch; break; } } if (gd->brush.image) { if ((gd->brush.width != (int) bmp->width ) || (gd->brush.height != (int) bmp->height)) { gdImageDestroy (gd->brush.image); gd->brush.image = 0; } } if (gd->brush.image == 0) { gd->brush.width = (int) bmp->width; gd->brush.height = (int) bmp->height; gd->brush.image = gdImageCreateTrueColor (gd->brush.width,gd->brush.height); } if (gd->brush.image) { for (y = 0; y < (unsigned int) gd->brush.height; y++) { for (x = 0; x < (unsigned int) gd->brush.width; x++) { opacity = wmf_ipa_bmp_color (API,bmp,&pixel,x,y); fg = gdImageColorResolve (gd->brush.image,pixel.r,pixel.g,pixel.b); gdImageSetPixel (gd->brush.image,(int) x,(int) y,fg); } } gdImageSetTile (gd->image,gd->brush.image); brushstyle = gdTiled; } break; default: if (API->flags & WMF_OPT_IGNORE_NONFATAL) { WMF_DEBUG (API,"Unsupported brush style!"); /* no break here */ } else { WMF_ERROR (API,"Unsupported brush style!"); API->err = wmf_E_Glitch; break; } case BS_SOLID: break; } return (brushstyle); }