diff options
| author | No author <no_author@ocaml.org> | 1995-06-15 16:08:54 +0000 |
|---|---|---|
| committer | No author <no_author@ocaml.org> | 1995-06-15 16:08:54 +0000 |
| commit | 77b1c8b89fd8940a63b17c41eb37161e5d159831 (patch) | |
| tree | 43dbfb3982d9166b717199cb8faa97bdce30add7 /otherlibs/graph/make_img.c | |
| parent | ba79d4bd1f01a70b892c69f6a5e6e86714a023d6 (diff) | |
| download | ocaml-unlabeled-1.2.2.tar.gz | |
This commit was manufactured by cvs2svn to create branchunlabeled-1.2.2
'unlabeled-1.2.2'.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/unlabeled-1.2.2@37 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/graph/make_img.c')
| -rw-r--r-- | otherlibs/graph/make_img.c | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/otherlibs/graph/make_img.c b/otherlibs/graph/make_img.c deleted file mode 100644 index 6c9570def7..0000000000 --- a/otherlibs/graph/make_img.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "libgraph.h" -#include "image.h" -#include <memory.h> - -value gr_make_image(m) - value m; -{ - int width, height; - value im; - Bool has_transp; - XImage * idata, * imask; - char * bdata, * bmask; - int i, j, rgb; - value line; - GC gc; - - gr_check_open(); - height = Wosize_val(m); - if (height == 0) return gr_new_image(0, 0); - width = Wosize_val(Field(m, 0)); - for (i = 1; i < height; i++) - if (Wosize_val(Field(m, i)) != width) - gr_fail("make_image: lines of different lengths", NULL); - - /* Build an XImage for the data part of the image */ - idata = - XCreateImage(grdisplay, DefaultVisual(grdisplay, grscreen), - XDefaultDepth(grdisplay, grscreen), - ZPixmap, 0, NULL, width, height, - BitmapPad(grdisplay), 0); - bdata = (char *) stat_alloc(height * idata->bytes_per_line); - idata->data = bdata; - has_transp = False; - - for (i = 0; i < height; i++) { - line = Field(m, i); - for (j = 0; j < width; j++) { - rgb = Int_val(Field(line, j)); - if (rgb == Transparent) { has_transp = True; rgb = 0; } - XPutPixel(idata, j, i, gr_pixel_rgb(rgb)); - } - } - - /* If the matrix contains transparent points, - build an XImage for the mask part of the image */ - if (has_transp) { - imask = - XCreateImage(grdisplay, DefaultVisual(grdisplay, grscreen), - 1, ZPixmap, 0, NULL, width, height, - BitmapPad(grdisplay), 0); - bmask = (char *) stat_alloc(height * imask->bytes_per_line); - imask->data = bmask; - - for (i = 0; i < height; i++) { - line = Field(m, i); - for (j = 0; j < width; j++) { - rgb = Int_val(Field(line, j)); - XPutPixel(imask, j, i, rgb != Transparent); - } - } - } - - /* Allocate the image and store the XImages into the Pixmaps */ - im = gr_new_image(width, height); - gc = XCreateGC(grdisplay, Data_im(im), 0, NULL); - XPutImage(grdisplay, Data_im(im), gc, idata, 0, 0, 0, 0, width, height); - XDestroyImage(idata); - XFreeGC(grdisplay, gc); - if (has_transp) { - Mask_im(im) = XCreatePixmap(grdisplay, grwindow.win, width, height, 1); - gc = XCreateGC(grdisplay, Mask_im(im), 0, NULL); - XPutImage(grdisplay, Mask_im(im), gc, imask, 0, 0, 0, 0, width, height); - XDestroyImage(imask); - XFreeGC(grdisplay, gc); - } - XFlush(grdisplay); - return im; -} - |
