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; }
//axis aligned circle for setting up brushes for thick lines void rs_gdImageCircleForBrush(gdImagePtr im, int x, int y, int rad, RS_Color& color) { int gdc = ConvertColor(im, color); float rad2 = (float)rad*rad; for (int j = -rad, k = y+j; j <= rad; j++, k++) { float j_offset = j + 0.5f; float hlen = sqrt(rad2 - j_offset*j_offset); int solidwid = (int)hlen; if (solidwid) gdImageLine(im, x-solidwid, k, x+solidwid-1, k, gdc); float aalpha = hlen - solidwid; RS_Color ac = color; ac.alpha() = (int)(ac.alpha() * aalpha); int gdc2 = ConvertColor(im, ac); gdImageSetPixel(im, x-solidwid-1, k, gdc2); gdImageSetPixel(im, x+solidwid, k, gdc2); } }
gdImage *fx_rotate(gdImage *src, char *options) { int x, y; gdImage *im; int angle = atoi(options); /* Restrict angle to 0-360 range. */ if((angle %= 360) < 0) angle += 360; /* Round to nearest right angle. */ x = (angle + 45) % 360; angle = x - (x % 90); /* Not rotating 0 degrees. */ if(angle == 0) { MSG("Not rotating 0 degrees."); return(src); } /* 180 can be done with two flips. */ if(angle == 180) { fx_flip(src, "h,v"); return(src); } MSG("Rotating image %i degrees. %ix%i -> %ix%i.", angle, gdImageSX(src), gdImageSY(src), gdImageSY(src), gdImageSX(src)); /* Create rotated image. */ im = gdImageCreateTrueColor(gdImageSY(src), gdImageSX(src)); if(!im) { WARN("Out of memory."); return(src); } for(y = 0; y < gdImageSY(src); y++) for(x = 0; x < gdImageSX(src); x++) { int c = gdImageGetPixel(src, x, y); if(angle == 90) { gdImageSetPixel(im, gdImageSX(im) - y - 1, x, c); } else { gdImageSetPixel(im, y, gdImageSY(im) - x - 1, c); } } gdImageDestroy(src); return(im); }
static void imageScanline(gdImagePtr im, int x1, int x2, int y, int c) { int x; /* TO DO: This fix (adding if/then) was to address circumstances in the polygon fill code */ /* where x2 < x1. There may be something wrong in that code, but at any rate this is safer. */ if(x1 < x2) for(x=x1; x<=x2; x++) gdImageSetPixel(im, x, y, c); else for(x=x2; x<=x1; x++) gdImageSetPixel(im, x, y, c); }
void gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c) { int x=0,mx1=0,mx2=0,my1=0,my2=0; long aq,bq,dx,dy,r,rx,ry,a,b; int i; int old_y2; a=w>>1; b=h>>1; for (x = mx-a; x <= mx+a; x++) { gdImageSetPixel(im, x, my, c); } mx1 = mx-a;my1 = my; mx2 = mx+a;my2 = my; aq = a * a; bq = b * b; dx = aq << 1; dy = bq << 1; r = a * bq; rx = r << 1; ry = 0; x = a; old_y2=-2; while (x > 0) { if (r > 0) { my1++;my2--; ry +=dx; r -=ry; } if (r <= 0) { x--; mx1++;mx2--; rx -=dy; r +=rx; } if(old_y2!=my2) { for(i=mx1;i<=mx2;i++) { gdImageSetPixel(im,i,my1,c); } } if(old_y2!=my2) { for(i=mx1;i<=mx2;i++) { gdImageSetPixel(im,i,my2,c); } } old_y2 = my2; } }
int renderEllipseSymbolGD(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *style) { /* check for trivial cases - 1x1 and 2x2, GD does not do these well */ gdImagePtr ip; int w,h,fc,oc; if(!(ip = MS_IMAGE_GET_GDIMAGEPTR(img))) return MS_FAILURE; SETPEN(ip, style->color); SETPEN(ip, style->outlinecolor); fc = style->color ? style->color->pen : -1; oc = style->outlinecolor ? style->outlinecolor->pen : -1; if(oc==-1 && fc ==-1) { return MS_SUCCESS; } w = symbol->sizex * style->scale; h = symbol->sizey * style->scale; if(w==1 && h==1) { if(fc >= 0) gdImageSetPixel(ip, x, y, fc); else gdImageSetPixel(ip, x, y, oc); return MS_SUCCESS; } if(w==2 && h==2) { if(oc >= 0) { gdImageSetPixel(ip, x, y, oc); gdImageSetPixel(ip, x, y+1, oc); gdImageSetPixel(ip, x+1, y, oc); gdImageSetPixel(ip, x+1, y+1, oc); } else { gdImageSetPixel(ip, x, y, fc); gdImageSetPixel(ip, x, y+1, fc); gdImageSetPixel(ip, x+1, y, fc); gdImageSetPixel(ip, x+1, y+1, fc); } return MS_SUCCESS; } if(symbol->filled) { if(fc >= 0) gdImageFilledEllipse(ip, x, y, w, h, fc); if(oc >= 0) gdImageArc(ip, x, y, w, h, 0, 360, oc); } else { if(fc < 0) fc = oc; /* try the outline color */ gdImageArc(ip, x, y, w, h, 0, 360, fc); } return MS_SUCCESS; }
void plD_pixel_gd (PLStream *pls, short x, short y) { png_Dev *dev=(png_Dev *)pls->dev; gdImageSetPixel(dev->im_out, x, y,dev->colour); }
gdImagePtr imagefilter_difference(gdImagePtr img1, gdImagePtr img2) { int x, y, c1, c2, r, g, b, np; int sx = img1->sx < img2->sx ? img1->sx : img2->sx; int sy = img1->sy < img2->sy ? img1->sy : img2->sy; gdImagePtr img = gdImageCreateTrueColor(sx, sy); for (y = 0; y < sy; y++) for (x = 0; x < sx; x++) { c1 = gdImageGetPixel(img1, x, y); c2 = gdImageGetPixel(img2, x, y); r = gdImageRed(img1, c1) - gdImageRed(img2, c2); g = gdImageGreen(img1, c1) - gdImageGreen(img2, c2); b = gdImageBlue(img1, c1) - gdImageBlue(img2, c2); np = gdImageColorAllocate(img, r < 0 ? -r : r, g < 0 ? -g : g, b < 0 ? -b : b ); gdImageSetPixel(img, x, y, np); } return img; }
gdImagePtr ca_make_gif(CA *ca_ptr, int generations, int br, int bg, int bb, int wr, int wg, int wb ) { gdImagePtr img; int black, white; int gen; int cell; img = gdImageCreate(ca_ptr->width, generations); if (!img) { fprintf(stderr,"Can't allocate image!\n"); exit(1); } black = gdImageColorAllocate(img, br, bg, bb); white = gdImageColorAllocate(img, wr, wg, wb); for(gen=0; gen < generations; gen++) { for(cell=0; cell < ca_ptr->width; cell++) { gdImageSetPixel(img, cell, gen, *(ca_ptr->c_row + cell) ? white : black); } ca_gen_next_row(ca_ptr); } return img; }
PngSurface::~PngSurface() { gdImagePtr im; FILE* out; im = gdImageCreateTrueColor(width(), height()); if (!(out = fopen(m_fname.c_str(), "wb"))) { std::cerr << "Unable to open/create file " << m_fname << std::endl; return; } for (int h = 0; h < m_height; ++h) { for (int w = 0; w < m_width; ++w) { gdImageSetPixel(im, w, h, data[h][w]); } } gdImagePng(im, out); fclose(out); gdImageDestroy(im); for (int i = 0; i < m_height; ++i) { delete[] data[i]; data[i] = NULL; } delete[] data; data = NULL; }
/** * void mrc_to_gd(MRC *mrc, int ** tpixels, int pmin, int pmax) { */ void mrc_to_gd(MRC *mrc, gdImagePtr im, int pmin, int pmax) { float *data_array; float fmin=mrc->header.amin, fmax=mrc->header.amax, scale = fmax - fmin, nmin, nmax, nscale, f_val; int w=mrc->header.nx, h=mrc->header.ny, i,j; int densitymax = DENSITY_MAX; long n=w*h, ij; data_array = (float *)mrc->pbyData; nmin = fmin + pmin * scale / densitymax; nmax = fmin + pmax * scale / densitymax; nscale = nmax - nmin; if (nscale != 0) for (j = 0; j < h; ++j) { for (i = 0; i < w; ++i) { ij = i + j*w; f_val = data_array[ij]; f_val = (f_val-nmin)*densitymax/nscale; gdImageSetPixel (im, i, j, setDensity(f_val)); } } }
static void gdImageBrushApply(gdImagePtr im, int x, int y) { int lx, ly; int hy; int hx; int x1, y1, x2, y2; int srcx, srcy; if (!im->brush) { return; } hy = gdImageSY(im->brush)/2; y1 = y - hy; y2 = y1 + gdImageSY(im->brush); hx = gdImageSX(im->brush)/2; x1 = x - hx; x2 = x1 + gdImageSX(im->brush); srcy = 0; for (ly = y1; (ly < y2); ly++) { srcx = 0; for (lx = x1; (lx < x2); lx++) { int p; p = gdImageGetPixel(im->brush, srcx, srcy); /* Allow for non-square brushes! */ if (p != gdImageGetTransparent(im->brush)) { gdImageSetPixel(im, lx, ly, im->brushColorMap[p]); } srcx++; } srcy++; } }
int output_gd_png(void *_array, int width, int height, int depth, const char *filename, color colors[], int numColors) { int x, y; int (*array)[height][width] = _array; int color=0; // Draw to buffer gdImagePtr im; im = gdImageCreateTrueColor(width, height); for (y=0; y<height; y++) for (x=0; x<width; x++) { if ((*array)[y][x] == -1) color=0; else color=colors[(*array)[y][x]].hex; //return_color(colors, numColors, depth, (*array)[y][x]); gdImageSetPixel(im, x, y, color); } // Write to file save_png(im, filename); gdImageDestroy(im); return 0; }
int main() { gdImagePtr im; int x, y, c; FILE *out; char path[1024]; int r=0; im = gdImageCreateTrueColor(256, 256); gdImageAlphaBlending( im, gdEffectReplace ); for (x=0; x<256; x++) { for (y=0; y<256; y++) { c = (y/2 << 24) + (x << 16) + (x << 8) + x; gdImageSetPixel(im, x, y, c ); } } gdImageAlphaBlending( im, gdEffectOverlay ); gdImageFilledRectangle(im, 0, 0, 255, 255, 0xff7f00); if (gdTrueColorGetGreen(gdImageGetPixel(im, 0, 128)) != 0x00) { r = 1; } if (gdTrueColorGetGreen(gdImageGetPixel(im, 128, 128)) != 0x80) { r = 1; } if (gdTrueColorGetGreen(gdImageGetPixel(im, 255, 128)) != 0xff) { r = 1; } gdImageDestroy(im); return r; }
void after_nodes() { gdImagePtr im = gdImageCreate(m_xsize, m_ysize); for (int i=0; i <= 255; ++i) { gdImageColorAllocate(im, i, i, i); } int n=0; for (int y=0; y < m_ysize; ++y) { for (int x=0; x < m_xsize; ++x) { int val = in_range(m_min, m_node_count[n], m_max); ++n; gdImageSetPixel(im, x, y, static_cast<uint8_t>((val - m_min) * 255 / m_diff)); } } FILE* out = fopen("node_density.png", "wb"); if (!out) { std::cerr << "Can't open file 'node_density.png': " << strerror(errno) << std::endl; } gdImagePng(im, out); fclose(out); gdImageDestroy(im); }
/* * This is a very simple and experimental deinterlacer, * there is a lot of room for improvement here. * * (For example: Making it work) * */ gdImage *fx_deinterlace(gdImage *src, char *options) { int x, y; MSG("Deinterlacing image."); for(y = 1; y < gdImageSY(src) - 1; y += 2) { for(x = 0; x < gdImageSX(src); x++) { int c, cu, cd, d; c = gdImageGetPixel(src, x, y); cu = gdImageGetPixel(src, x, y - 1); cd = gdImageGetPixel(src, x, y + 1); /* Calculate the difference of the pixel (x,y) from * the average of it's neighbours above and below. */ d = 0xFF - abs(GREY(cu) - GREY(cd)); d = (abs(GREY(cu) - (0xFF - GREY(c)) - GREY(cd)) * d) / 0xFF; c = RGBMIX(c, RGBMIX(cu, cd, 128), d); gdImageSetPixel(src, x, y, c); } } return(src); }
static void writePng(char *filename, wlImage pic) { gdImagePtr output; int x, y, i; int palette[16]; FILE *file; output = gdImageCreate(pic->width, pic->height); for (i = 0; i < 16; i++) { palette[i] = gdImageColorAllocate(output, wlPalette[i].red, wlPalette[i].green, wlPalette[i].blue); } for (y = 0; y < pic->height; y++) { for (x = 0; x < pic->width; x++) { gdImageSetPixel(output, x, y, palette[pic->pixels[y * pic->width + x]]); } } file = fopen(filename, "wb"); if (!file) { die("Unable to write PNG to %s: %s\n", filename, strerror(errno)); } gdImagePng(output, file); gdImageDestroy(output); fclose(file); }
/* saves the data stored in the image_data array of given width and height into an output .png file returns: 0 on success 1 otherwise */ int save_image_data(char *file_name, color_t *imageData, int width, int height) { gdImagePtr img = gdImageCreateTrueColor(width, height); unsigned x, y; for(y = 0; y < height; ++y) { for(x = 0; x < width; ++x) { int index = y*width + x; int gd_color = gdImageColorAllocate(img, imageData[index].r, imageData[index].g, imageData[index].b); gdImageSetPixel(img, x, y, gd_color); } } FILE *img_file = fopen(file_name, "w+"); if (img_file == NULL) { gdImageDestroy(img); perror("error opening file"); return 1; } gdImagePng(img, img_file); gdImageDestroy(img); if (fclose(img_file)) { perror("error closing file"); return 1; } return 0; }
int main(int argc, char *argv[]){ FILE *fp; gdImagePtr im1, im2, imOut; int i,x,y,xsize,ysize,c; int c1,c2; if(argc != 4){ fprintf(stderr, "[%s] compiled [%s/%s %s]\n", argv[0], __DATE__, __TIME__, DIRE); fprintf(stderr, "Usage : %s in-gif1 in-gif2 out-gif\n", argv[0]); exit(1); } im1 = fromGif(argv[1]); im2 = fromGif(argv[2]); outfile = argv[3]; xsize = gdImageSX(im1); ysize = gdImageSY(im2); imOut = gdImageCreate(xsize, ysize); for(i=0; i<gdImageColorsTotal(im1); i++){ int r,g,b; r = gdImageRed( im1, i); g = gdImageGreen(im1, i); b = gdImageBlue( im1, i); } for(y=0; y<ysize; y++){ int r,g,b; for(x=0; x<xsize; x++){ c1 = gdImageGetPixel(im1, x, y); c2 = gdImageGetPixel(im2, x, y); r = gdImageRed( im1, c1) - gdImageRed( im2, c2); g = gdImageGreen(im1, c1) - gdImageGreen(im2, c2); b = gdImageBlue( im1, c1) - gdImageBlue( im2, c2); r = (r + 256) % 256; g = (g + 256) % 256; b = (b + 256) % 256; c = allocOrExact(imOut, r, g, b); gdImageSetPixel(imOut, x, y, c); } } gdImageDestroy(im1); gdImageDestroy(im2); fp = fopen(outfile, "wb"); if(!fp){ fprintf(stderr, "Can't open [%s]\n", outfile); exit(1); } gdImageGif(imOut, fp); fclose(fp); gdImageDestroy(imOut); return 0; }
void doPixel(FILE *stream) { float x, y; int c; x = getFloat(stream); y = getFloat(stream); c = getColor(getNumber(stream)); gdImageSetPixel(image, viewx(x), viewy(y), c); }
result_t Image::setPixel(int32_t x, int32_t y, int32_t color) { if (!m_image) return CHECK_ERROR(CALL_E_INVALID_CALL); gdImageSetPixel(m_image, x, y, color); return 0; }
BGD_DECLARE(int) gdImageScatterEx(gdImagePtr im, gdScatterPtr scatter) { register int x, y; int dest_x, dest_y; int pxl, new_pxl; unsigned int n; int sub = scatter->sub, plus = scatter->plus; PIXEL_FUNCTION_DECLARE(f); if (plus == 0 && sub == 0) { return 1; } else if (sub >= plus) { return 0; } f = GET_PIXEL_FUNCTION(im); (void)srand(scatter->seed); if (scatter->num_colors) { for (y = 0; y < im->sy; y++) { for (x = 0; x < im->sx; x++) { GD_SCATTER_MAIN(); for (n = 0; n < scatter->num_colors; n++) { if (pxl == scatter->colors[n]) { gdImageSetPixel(im, dest_x, dest_y, pxl); gdImageSetPixel(im, x, y, new_pxl); } } } } } else { for (y = 0; y < im->sy; y++) { for (x = 0; x < im->sx; x++) { GD_SCATTER_MAIN(); gdImageSetPixel(im, dest_x, dest_y, pxl); gdImageSetPixel(im, x, y, new_pxl); } } } return 1; }
void hqx_scale(gdImagePtr srcIm, int factor, gdImagePtr* result) { gdImagePtr dstIm; uint32_t *srcBuffer, *dstBuffer; size_t srcSize, dstSize; uint32_t w, h; uint32_t x, y; w = gdImageSX(srcIm); h = gdImageSY(srcIm); srcSize = sizeof(uint32_t) * w * h; dstSize = sizeof(uint32_t) * factor * w * factor * h; // Unfortunately it doesn't work to simply pass the gd buffer from the // gdImage struct to hqx, and the gd documentation explicitly says // not to access member fields directly. Thus we allocate two buffers // and copy the data back and forth as a workaround. srcBuffer = (uint32_t*)emalloc(srcSize); for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { srcBuffer[w*y + x] = gdImageGetPixel(srcIm, x, y); } } dstBuffer = (uint32_t*)emalloc(dstSize); if (factor == 4) { hq4x_32_rb(srcBuffer, sizeof(uint32_t)*w, dstBuffer, sizeof(uint32_t)*factor*w, w, h); } else if (factor == 3) { hq3x_32_rb(srcBuffer, sizeof(uint32_t)*w, dstBuffer, sizeof(uint32_t)*factor*w, w, h); } else if (factor == 2) { hq2x_32_rb(srcBuffer, sizeof(uint32_t)*w, dstBuffer, sizeof(uint32_t)*factor*w, w, h); } dstIm = gdImageCreateTrueColor(factor*w, factor*h); gdImageAlphaBlending(dstIm, 0); gdImageSaveAlpha(dstIm, 1); for (y = 0; y < factor*h; y++) { for (x = 0; x < factor*w; x++) { gdImageSetPixel(dstIm, x, y, dstBuffer[factor*w*y + x]); } } efree(srcBuffer); efree(dstBuffer); *result = dstIm; }
/* gdImageCreateFromWBMPCtx ** ------------------------ ** Create a gdImage from a WBMP file input from an gdIOCtx */ BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPCtx (gdIOCtx * infile) { /* FILE *wbmp_file; */ Wbmp *wbmp; gdImagePtr im = NULL; int black, white; int col, row, pos; if (readwbmp (&gd_getin, infile, &wbmp)) return (NULL); if (!(im = gdImageCreate (wbmp->width, wbmp->height))) { freewbmp (wbmp); return (NULL); } /* create the background color */ white = gdImageColorAllocate (im, 255, 255, 255); /* create foreground color */ black = gdImageColorAllocate (im, 0, 0, 0); /* fill in image (in a wbmp 1 = white/ 0 = black) */ pos = 0; for (row = 0; row < wbmp->height; row++) { for (col = 0; col < wbmp->width; col++) { if (wbmp->bitmap[pos++] == WBMP_WHITE) { gdImageSetPixel (im, col, row, white); } else { gdImageSetPixel (im, col, row, black); } } } freewbmp (wbmp); return (im); }
result_t Image::rotate(int32_t dir) { if (dir != gd_base::_LEFT && dir != gd_base::_RIGHT) return CHECK_ERROR(CALL_E_INVALIDARG); int32_t sx = gdImageSX(m_image); int32_t sy = gdImageSY(m_image); int32_t i, j; gdImagePtr newImage; if (gdImageTrueColor(m_image)) newImage = gdImageCreateTrueColor(sy, sx); else { newImage = gdImageCreate(sy, sx); gdImagePaletteCopy(newImage, m_image); } gdImageColorTransparent(newImage, gdImageGetTransparent(m_image)); if (dir == gd_base::_LEFT) { for (i = 0; i < sx; i++) for (j = 0; j < sy; j++) gdImageSetPixel(newImage, j, sx - i - 1, gdImageGetPixel(m_image, i, j)); } else { for (i = 0; i < sx; i++) for (j = 0; j < sy; j++) gdImageSetPixel(newImage, sy - j - 1, i, gdImageGetPixel(m_image, i, j)); } setExtMemory(-1); gdImageDestroy(m_image); m_image = newImage; setExtMemory(); return 0; }
/* * Save float luminance image to JPEG via gd * return -1 on error, 0 otherwise */ uint32_t y_float_save( float *data, uint32_t w, uint32_t h, char *name ) { FILE *f; gdImage *image; uint32_t i, j, g, color; float *dat, d, max; if(!name) return(-1); f = fopen(name, "wb"); if(!f) { ERROR("Error opening file for output: %s", name); ERROR("fopen: %s", strerror(errno)); return(-1); } image = gdImageCreateTrueColor(w,h); if(!image) { ERROR("Cannot create image"); fclose(f); return(-1); } max=0; dat=data; for(j=0;j<h;j++) for(i=0;i<w;i++) { d = *(dat++); if(d>max) max=d; } dat = data; for(j=0; j<h; j++){ for(i=0; i<w; i++) { d = *(dat++); g = 0xff * d/max; color = g + (g<<8) + (g<<16); color &= 0xffffff; gdImageSetPixel(image,i,j,color); } } gdImageJpeg(image, f, 255); gdImageDestroy(image); return(0); }
JBoolean PadColormap ( gdImagePtr image ) { JSize colorCount = gdImageColorsTotal(image); if (colorCount >= kMinColorCount) { return kJFalse; } const JSize extraColorCount = kMinColorCount - colorCount; int x = gdImageSX(image) - extraColorCount; if (x < 0) { cerr << "image is too small to fit extra colors on single raster line" << endl; exit(1); } int y = gdImageSY(image) - 1; int c = gdImageGetPixel(image, x,y); int r = gdImageRed (image, c); int g = gdImageGreen(image, c); int b = gdImageBlue (image, c); int delta = -1; if (r < 127 || g < 127 || b < 127) { delta = +1; } for (JIndex i=1; i<=extraColorCount; i++) { assert( x < gdImageSX(image) ); while ((c = gdImageColorExact(image, r,g,b)) != -1) { r = JMax(0, JMin(r + delta, 255)); g = JMax(0, JMin(g + delta, 255)); b = JMax(0, JMin(b + delta, 255)); } c = gdImageColorAllocate(image, r,g,b); assert( c != -1 ); gdImageSetPixel(image, x,y, c); x++; } return kJTrue; }
void doManyPixels(FILE *stream) { float x, y; int npix, c, i; npix = getNumber(stream); c = getColor(getNumber(stream)); for (i = 0; i < npix; i++) { x = getFloat(stream); y = getFloat(stream); gdImageSetPixel(image, viewx(x), viewy(y), c); } }
void gdImageSetPixel(gdImagePtr im, int x, int y, int color) { int p; switch(color) { case gdStyled: if (!im->style) { /* Refuse to draw if no style is set. */ return; } else { p = im->style[im->stylePos++]; } if (p != (gdTransparent)) { gdImageSetPixel(im, x, y, p); } im->stylePos = im->stylePos % im->styleLength; break; case gdStyledBrushed: if (!im->style) { /* Refuse to draw if no style is set. */ return; } p = im->style[im->stylePos++]; if ((p != gdTransparent) && (p != 0)) { gdImageSetPixel(im, x, y, gdBrushed); } im->stylePos = im->stylePos % im->styleLength; break; case gdBrushed: gdImageBrushApply(im, x, y); break; case gdTiled: gdImageTileApply(im, x, y); break; default: if (gdImageBoundsSafe(im, x, y)) { /* NOW ROW-MAJOR IN GD 1.3 */ im->pixels[y][x] = color; } break; } }
static void write_row(gdImagePtr im, int row, const char *data, unsigned len) { unsigned i, j; int col = 0; for(i = 0; i < len; i++) for(j = 0; j < 8; j++){ if(data[i] & (1 << j)) gdImageSetPixel(im, col, row, 0x000FF00); col++; } }