diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-12-30 19:48:11 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-12-30 19:48:11 (GMT) |
| commit | b4b4a90f006c4c84d11a7017c2c454c1692c7b24 (patch) | |
| tree | e6761383beb59ca1728138632979c29ab34be7c6 /src/graphics.c | |
| parent | 9c3139354753f01c8cce68bad958c17ab6054b46 (diff) | |
| download | powder-b4b4a90f006c4c84d11a7017c2c454c1692c7b24.zip powder-b4b4a90f006c4c84d11a7017c2c454c1692c7b24.tar.gz | |
Almost finished new save format, just signs and thumbnail rendering needed
Diffstat (limited to 'src/graphics.c')
| -rw-r--r-- | src/graphics.c | 192 |
1 files changed, 0 insertions, 192 deletions
diff --git a/src/graphics.c b/src/graphics.c index 3a2c85c..aa72139 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3485,198 +3485,6 @@ void render_zoom(pixel *img) //draws the zoom box #endif } -//gets the thumbnail preview for stamps -pixel *prerender_save(void *save, int size, int *width, int *height) -{ - unsigned char *d,*c=save; - int i,j,k,x,y,rx,ry,p=0; - int bw,bh,w,h,new_format = 0; - pixel *fb; - - if (size<16) - return NULL; - if (!(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) && !(c[2]==0x76 && c[1]==0x53 && c[0]==0x50)) - return NULL; - if (c[2]==0x43 && c[1]==0x75 && c[0]==0x66) { - new_format = 1; - } - if (c[4]>SAVE_VERSION) - return NULL; - - bw = c[6]; - bh = c[7]; - w = bw*CELL; - h = bh*CELL; - - if (c[5]!=CELL) - return NULL; - - i = (unsigned)c[8]; - i |= ((unsigned)c[9])<<8; - i |= ((unsigned)c[10])<<16; - i |= ((unsigned)c[11])<<24; - d = malloc(i); - if (!d) - return NULL; - fb = calloc(w*h, PIXELSIZE); - if (!fb) - { - free(d); - return NULL; - } - - if (BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+12), size-12, 0, 0)) - goto corrupt; - size = i; - - if (size < bw*bh) - goto corrupt; - - k = 0; - for (y=0; y<bh; y++) - for (x=0; x<bw; x++) - { - rx = x*CELL; - ry = y*CELL; - switch (d[p]) - { - case 1: - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080); - break; - case 2: - for (j=0; j<CELL; j+=2) - for (i=(j>>1)&1; i<CELL; i+=2) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080); - break; - case 3: - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - if (!(j%2) && !(i%2)) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0xC0C0C0); - break; - case 4: - for (j=0; j<CELL; j+=2) - for (i=(j>>1)&1; i<CELL; i+=2) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0x8080FF); - k++; - break; - case 6: - for (j=0; j<CELL; j+=2) - for (i=(j>>1)&1; i<CELL; i+=2) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0xFF8080); - break; - case 7: - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - if (!(i&j&1)) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080); - break; - case 8: - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - if (!(j%2) && !(i%2)) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0xC0C0C0); - else - fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080); - break; - case WL_WALL: - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080); - break; - case WL_DESTROYALL: - for (j=0; j<CELL; j+=2) - for (i=(j>>1)&1; i<CELL; i+=2) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080); - break; - case WL_ALLOWLIQUID: - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - if (!(j%2) && !(i%2)) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0xC0C0C0); - break; - case WL_FAN: - for (j=0; j<CELL; j+=2) - for (i=(j>>1)&1; i<CELL; i+=2) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0x8080FF); - k++; - break; - case WL_DETECT: - for (j=0; j<CELL; j+=2) - for (i=(j>>1)&1; i<CELL; i+=2) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0xFF8080); - break; - case WL_EWALL: - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - if (!(i&j&1)) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080); - break; - case WL_WALLELEC: - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - if (!(j%2) && !(i%2)) - fb[(ry+j)*w+(rx+i)] = PIXPACK(0xC0C0C0); - else - fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080); - break; - } - p++; - } - p += 2*k; - if (p>=size) - goto corrupt; - - for (y=0; y<h; y++) - for (x=0; x<w; x++) - { - if (p >= size) - goto corrupt; - j=d[p++]; - if (j<PT_NUM && j>0) - { - if (j==PT_STKM || j==PT_STKM2 || j==PT_FIGH) - { - pixel lc, hc=PIXRGB(255, 224, 178); - if (j==PT_STKM || j==PT_FIGH) lc = PIXRGB(255, 255, 255); - else lc = PIXRGB(100, 100, 255); - //only need to check upper bound of y coord - lower bounds and x<w are checked in draw_line - draw_line(fb , x-2, y-2, x+2, y-2, PIXR(hc), PIXG(hc), PIXB(hc), w); - if (y+2<h) - { - draw_line(fb , x-2, y+2, x+2, y+2, PIXR(hc), PIXG(hc), PIXB(hc), w); - draw_line(fb , x-2, y-2, x-2, y+2, PIXR(hc), PIXG(hc), PIXB(hc), w); - draw_line(fb , x+2, y-2, x+2, y+2, PIXR(hc), PIXG(hc), PIXB(hc), w); - } - if (y+6<h) - { - draw_line(fb , x, y+3, x-1, y+6, PIXR(lc), PIXG(lc), PIXB(lc), w); - draw_line(fb , x, y+3, x+1, y+6, PIXR(lc), PIXG(lc), PIXB(lc), w); - } - if (y+12<h) - { - draw_line(fb , x-1, y+6, x-3, y+12, PIXR(lc), PIXG(lc), PIXB(lc), w); - draw_line(fb , x+1, y+6, x+3, y+12, PIXR(lc), PIXG(lc), PIXB(lc), w); - } - } - else - fb[y*w+x] = ptypes[j].pcolors; - } - } - - free(d); - *width = w; - *height = h; - return fb; - -corrupt: - free(d); - free(fb); - return NULL; -} - int render_thumb(void *thumb, int size, int bzip2, pixel *vid_buf, int px, int py, int scl) { unsigned char *d,*c=thumb; |
