Changeset 7040
- Timestamp:
- May 2, 2006, 9:19:22 AM (20 years ago)
- Location:
- trunk/Ohana/src/kapa
- Files:
-
- 54 deleted
- 3 edited
-
Makefile (modified) (1 diff)
-
graph/PNGit.c (modified) (6 diffs)
-
graph/PNGit2.c (deleted)
-
graph/PPMit.c (modified) (3 diffs)
-
graph/PPMit2.c (deleted)
-
graph/bDrawFuncs.c (deleted)
-
graph/bDrawRotFont.c (deleted)
-
include/bDraw.h (deleted)
-
rotfont/ReadMe (deleted)
-
rotfont/alphabet.h (deleted)
-
rotfont/blank.h (deleted)
-
rotfont/courier12.bdf (deleted)
-
rotfont/courier12.h (deleted)
-
rotfont/courier14.bdf (deleted)
-
rotfont/courier14.h (deleted)
-
rotfont/courier18.bdf (deleted)
-
rotfont/courier18.h (deleted)
-
rotfont/courier24.bdf (deleted)
-
rotfont/courier24.h (deleted)
-
rotfont/courier8.bdf (deleted)
-
rotfont/courier8.h (deleted)
-
rotfont/fixed.h (deleted)
-
rotfont/fixfont (deleted)
-
rotfont/fixfont.c (deleted)
-
rotfont/helvetica12.bdf (deleted)
-
rotfont/helvetica12.h (deleted)
-
rotfont/helvetica14.bdf (deleted)
-
rotfont/helvetica14.h (deleted)
-
rotfont/helvetica18.bdf (deleted)
-
rotfont/helvetica18.h (deleted)
-
rotfont/helvetica24.bdf (deleted)
-
rotfont/helvetica24.h (deleted)
-
rotfont/helvetica8.bdf (deleted)
-
rotfont/helvetica8.h (deleted)
-
rotfont/symbol12.bdf (deleted)
-
rotfont/symbol12.h (deleted)
-
rotfont/symbol14.bdf (deleted)
-
rotfont/symbol14.h (deleted)
-
rotfont/symbol18.bdf (deleted)
-
rotfont/symbol18.h (deleted)
-
rotfont/symbol24.bdf (deleted)
-
rotfont/symbol24.h (deleted)
-
rotfont/symbol8.bdf (deleted)
-
rotfont/symbol8.h (deleted)
-
rotfont/test.fn (deleted)
-
rotfont/test.h (deleted)
-
rotfont/times12.bdf (deleted)
-
rotfont/times12.h (deleted)
-
rotfont/times14.bdf (deleted)
-
rotfont/times14.h (deleted)
-
rotfont/times18.bdf (deleted)
-
rotfont/times18.h (deleted)
-
rotfont/times24.bdf (deleted)
-
rotfont/times24.h (deleted)
-
rotfont/times8.bdf (deleted)
-
rotfont/times8.h (deleted)
-
setup/MakeColormap.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa/Makefile
r6000 r7040 51 51 $(GDIR)/LoadPtext.$(ARCH).o $(GDIR)/DrawPtext.$(ARCH).o \ 52 52 $(GDIR)/PSLabels.$(ARCH).o $(GDIR)/PSPtext.$(ARCH).o \ 53 $(GDIR)/PPMit 2.$(ARCH).o \53 $(GDIR)/PPMit.$(ARCH).o \ 54 54 55 55 BDRAW = \ 56 $(GDIR)/bDrawIt.$(ARCH).o \ 57 $(GDIR)/bDrawFrame.$(ARCH).o $(GDIR)/bDrawLabels.$(ARCH).o \ 58 $(GDIR)/bDrawObjects.$(ARCH).o \ 59 $(GDIR)/PNGit2.$(ARCH).o \ 60 61 $(BDRAW): $(INC)/bDraw.h 56 $(GDIR)/bDrawIt.$(ARCH).o $(GDIR)/bDrawFrame.$(ARCH).o \ 57 $(GDIR)/bDrawLabels.$(ARCH).o $(GDIR)/bDrawObjects.$(ARCH).o \ 58 $(GDIR)/PNGit.$(ARCH).o \ 62 59 63 60 SOBJ = \ -
trunk/Ohana/src/kapa/graph/PNGit.c
r5610 r7040 1 1 # include "Ximage.h" 2 # include <png.h>3 2 4 int PNGit _old() {3 int PNGit () { 5 4 6 5 FILE *f; … … 8 7 png_infop info_ptr; 9 8 png_color *palette; 10 int *pchoice;11 XColor color;12 png_byte **rows;13 int dx, dy;14 int i, j, k, found;15 9 int Npalette; 16 XImage *tmpimage;17 unsigned long pixel;18 10 char filename[1024]; 19 11 int Nbytes, status; 20 12 21 Npalette = GetColormapSize (); 22 ALLOCATE (pchoice, int, Npalette); 23 ALLOCATE (palette, png_color, Npalette); 13 bDrawBuffer *buffer; 24 14 25 dx = graphic.dx;26 dy = graphic.dy;27 28 15 /* expect a line telling the number of bytes and a filename */ 29 16 status = read (sock, filename, 16); … … 33 20 filename[status] = 0; /* make the string easy to parse */ 34 21 35 ALLOCATE (rows, png_byte *, dy);36 for (i = 0; i < dy; i++) {37 ALLOCATE (rows[i], png_byte, dx);38 }39 40 /* define the palette */41 for (i = 0; i < Npalette; i++) {42 color.pixel = graphic.color[i];43 XQueryColor (graphic.display, graphic.colormap, &color);44 palette[i].red = (0x100 * color.red / 0x10000);45 palette[i].green = (0x100 * color.green / 0x10000);46 palette[i].blue = (0x100 * color.blue / 0x10000);47 pchoice[i] = color.pixel;48 }49 50 22 f = fopen (filename, "w"); 51 23 if (f == (FILE *) NULL) { 52 24 fprintf (stderr, "can't open output file %s\n", "Xgraph.png"); 53 free (pchoice);54 free (palette);55 25 return (TRUE); /* true because otherwise it quits kapa! */ 56 26 } … … 58 28 png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, (png_voidp) NULL, (png_voidp) NULL, (png_voidp) NULL); 59 29 if (!png_ptr) { 30 fprintf (stderr, "can't get png structure\n"); 60 31 fclose (f); 61 fprintf (stderr, "can't get png structure\n");62 free (pchoice);63 free (palette);64 32 return (TRUE); 65 33 } … … 67 35 info_ptr = png_create_info_struct (png_ptr); 68 36 if (!info_ptr) { 37 fprintf (stderr, "can't get png info structure\n"); 69 38 png_destroy_write_struct (&png_ptr, (png_infopp) NULL); 70 39 fclose (f); 71 fprintf (stderr, "can't get png info structure\n");72 free (pchoice);73 free (palette);74 40 return (TRUE); 75 41 } 76 42 77 43 if (setjmp (png_ptr[0].jmpbuf)) { 44 fprintf (stderr, "can't get png return\n"); 78 45 png_destroy_write_struct (&png_ptr, &info_ptr); 79 46 fclose (f); 80 fprintf (stderr, "can't get png return\n");81 free (pchoice);82 free (palette);83 47 return (TRUE); 84 48 } … … 88 52 /* see docs for write-row-callback to provide progress info */ 89 53 90 png_set_IHDR (png_ptr, info_ptr, dx,dy, 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);54 png_set_IHDR (png_ptr, info_ptr, graphic.dx, graphic.dy, 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 91 55 92 /* png_set_IHDR (png_ptr, info_ptr, dx,dy, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); */56 /* png_set_IHDR (png_ptr, info_ptr, graphic.dx, graphic.dy, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); */ 93 57 58 palette = KapaPNGPalette (&Npalette); 94 59 png_set_PLTE (png_ptr, info_ptr, palette, Npalette); 95 60 96 61 png_write_info (png_ptr, info_ptr); 97 62 98 /* a new attempt... */63 buffer = bDrawIt (); 99 64 100 { 101 XWindowAttributes WindowAttributes; 102 Pixmap tmp_pixmap; 103 Window tmp_window; 104 105 XGetWindowAttributes (graphic.display, graphic.window, &WindowAttributes); 106 107 tmp_pixmap = XCreatePixmap (graphic.display, graphic.window, dx, dy, WindowAttributes.depth); 108 109 tmp_window = graphic.window; 110 graphic.window = tmp_pixmap; 111 112 Refresh (1); 113 114 tmpimage = XGetImage (graphic.display, graphic.window, 0, 0, dx, dy, 0xffffffff, ZPixmap); 115 for (j = 0; j < dy; j++) { 116 for (i = 0; i < dx; i++) { 117 pixel = XGetPixel (tmpimage, i, j); 118 for (found = k = 0; (k < Npalette) && !found; k++) { 119 if (pixel == pchoice[k]) { 120 found = TRUE; 121 rows[j][i] = k; 122 } 123 } 124 } 125 } 126 graphic.window = tmp_window; 127 XFreePixmap (graphic.display, tmp_pixmap); 128 } 129 130 png_write_image (png_ptr, rows); 65 png_write_image (png_ptr, buffer[0].pixels); 131 66 png_write_end (png_ptr, info_ptr); 132 67 png_destroy_write_struct (&png_ptr, &info_ptr); 133 134 for (i = 0; i < dy; i++) { 135 free (rows[i]); 136 } 137 free (rows); 138 139 XDestroyImage (tmpimage); 140 68 69 bDrawBufferFree (buffer); 70 free (palette); 141 71 fclose (f); 142 free (pchoice);143 free (palette);144 72 return (TRUE); 145 73 -
trunk/Ohana/src/kapa/graph/PPMit.c
r2473 r7040 1 1 # include "Ximage.h" 2 # define NPALETTE 93 2 4 3 int PPMit () { 5 4 6 5 FILE *f; 7 int pixval[NPALETTE], red[NPALETTE], blue[NPALETTE], green[NPALETTE]; 8 XColor color; 9 int dx, dy; 10 int i, j, k, m, found; 11 XImage *tmpimage; 12 unsigned long pixel; 13 char filename[1024]; 14 int Nbytes, status; 15 char *buffer; 6 char *line, filename[1024]; 7 int Nbytes, status, dx, dy, i, j, Npalette, color; 8 png_color *palette; 16 9 17 XWindowAttributes WindowAttributes; 18 Pixmap tmp_pixmap; 19 Window tmp_window; 20 21 dx = graphic.dx; 22 dy = graphic.dy; 23 10 bDrawBuffer *buffer; 11 24 12 /* expect a line telling the number of bytes and a filename */ 25 13 status = read (sock, filename, 16); … … 29 17 filename[status] = 0; /* make the string easy to parse */ 30 18 31 ALLOCATE (buffer, char, 3*dx*dy);32 33 /* define the palette */34 for (i = 0; i < NPALETTE; i++) {35 color.pixel = graphic.color[i];36 XQueryColor (graphic.display, graphic.colormap, &color);37 red[i] = (color.red >> 8);38 green[i] = (color.green >> 8);39 blue[i] = (color.blue >> 8);40 pixval[i] = color.pixel;41 }42 43 19 f = fopen (filename, "w"); 44 20 if (f == (FILE *) NULL) { … … 47 23 } 48 24 25 palette = KapaPNGPalette (&Npalette); 26 27 dx = graphic.dx; 28 dy = graphic.dy; 29 49 30 fprintf (f, "P6\n"); 50 31 fprintf (f, "%d %d\n", dx, dy); 51 32 fprintf (f, "255\n"); 52 33 53 XGetWindowAttributes (graphic.display, graphic.window, &WindowAttributes); 34 buffer = bDrawIt (); 35 36 ALLOCATE (line, char, 3*dx); 37 38 for (i = 0; i < dy; i++) { 39 for (j = 0; j < dx; j++) { 40 color = buffer[0].pixels[i][j]; 41 line[3*j + 0] = palette[color].red; 42 line[3*j + 1] = palette[color].green; 43 line[3*j + 2] = palette[color].blue; 44 } 45 fwrite (line, 3, dx, f); 46 } 47 fclose (f); 54 48 55 tmp_pixmap = XCreatePixmap (graphic.display, graphic.window, dx, dy, WindowAttributes.depth); 56 57 tmp_window = graphic.window; 58 graphic.window = tmp_pixmap; 59 60 Refresh (1); 61 62 tmpimage = XGetImage (graphic.display, graphic.window, 0, 0, dx, dy, 0xffffffff, ZPixmap); 63 for (m = j = 0; j < dy; j++) { 64 for (i = 0; i < dx; i++, m+=3) { 65 pixel = XGetPixel (tmpimage, i, j); 66 for (found = k = 0; (k < NPALETTE) && !found; k++) { 67 if (pixel == pixval[k]) { 68 found = TRUE; 69 buffer[m+0] = red[k]; 70 buffer[m+1] = green[k]; 71 buffer[m+2] = blue[k]; 72 } 73 } 74 } 75 } 76 graphic.window = tmp_window; 77 XFreePixmap (graphic.display, tmp_pixmap); 78 79 fwrite (buffer, 3, dx*dy, f); 80 81 XDestroyImage (tmpimage); 82 83 fclose (f); 49 bDrawBufferFree (buffer); 84 50 return (TRUE); 85 51
Note:
See TracChangeset
for help on using the changeset viewer.
