/[dtapublic]/projs/dtats/trunk/shared_source/c_tk_base_7_5_w_mods/ximage.c
ViewVC logotype

Diff of /projs/dtats/trunk/shared_source/c_tk_base_7_5_w_mods/ximage.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

projs/trunk/shared_source/tk_base/ximage.c revision 42 by dashley, Fri Oct 14 01:50:00 2016 UTC projs/trunk/shared_source/c_tk_base_7_5_w_mods/ximage.c revision 71 by dashley, Sat Nov 5 11:07:06 2016 UTC
# Line 1  Line 1 
 /* $Header: /cvsroot/esrg/sfesrg/esrgpcpj/shared/tk_base/ximage.c,v 1.1.1.1 2001/06/13 05:15:44 dtashley Exp $ */  
   
 /*  
  * ximage.c --  
  *  
  *      X bitmap and image routines.  
  *  
  * Copyright (c) 1995 Sun Microsystems, Inc.  
  *  
  * See the file "license.terms" for information on usage and redistribution  
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.  
  *  
  * RCS: @(#) $Id: ximage.c,v 1.1.1.1 2001/06/13 05:15:44 dtashley Exp $  
  */  
   
 #include "tkInt.h"  
   
   
 /*  
  *----------------------------------------------------------------------  
  *  
  * XCreateBitmapFromData --  
  *  
  *      Construct a single plane pixmap from bitmap data.  
  *  
  *      NOTE: This procedure has the correct behavior on Windows and  
  *      the Macintosh, but not on UNIX.  This is probably because the  
  *      emulation for XPutImage on those platforms compensates for whatever  
  *      is wrong here :-)  
  *  
  * Results:  
  *      Returns a new Pixmap.  
  *  
  * Side effects:  
  *      Allocates a new bitmap and drawable.  
  *  
  *----------------------------------------------------------------------  
  */  
   
 Pixmap  
 XCreateBitmapFromData(display, d, data, width, height)  
     Display* display;  
     Drawable d;  
     _Xconst char* data;  
     unsigned int width;  
     unsigned int height;  
 {  
     XImage ximage;  
     GC gc;  
     Pixmap pix;  
   
     pix = Tk_GetPixmap(display, d, width, height, 1);  
     gc = XCreateGC(display, pix, 0, NULL);  
     if (gc == NULL) {  
         return None;  
     }  
     ximage.height = height;  
     ximage.width = width;  
     ximage.depth = 1;  
     ximage.bits_per_pixel = 1;  
     ximage.xoffset = 0;  
     ximage.format = XYBitmap;  
     ximage.data = (char *)data;  
     ximage.byte_order = LSBFirst;  
     ximage.bitmap_unit = 8;  
     ximage.bitmap_bit_order = LSBFirst;  
     ximage.bitmap_pad = 8;  
     ximage.bytes_per_line = (width+7)/8;  
   
     TkPutImage(NULL, 0, display, pix, gc, &ximage, 0, 0, 0, 0, width, height);  
     XFreeGC(display, gc);  
     return pix;  
 }  
   
   
 /* $History: ximage.c $  
  *  
  * *****************  Version 1  *****************  
  * User: Dtashley     Date: 1/02/01    Time: 3:21a  
  * Created in $/IjuScripter, IjuConsole/Source/Tk Base  
  * Initial check-in.  
  */  
   
 /* End of XIMAGE.C */  
1    /* $Header$ */
2    
3    /*
4     * ximage.c --
5     *
6     *      X bitmap and image routines.
7     *
8     * Copyright (c) 1995 Sun Microsystems, Inc.
9     *
10     * See the file "license.terms" for information on usage and redistribution
11     * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12     *
13     * RCS: @(#) $Id: ximage.c,v 1.1.1.1 2001/06/13 05:15:44 dtashley Exp $
14     */
15    
16    #include "tkInt.h"
17    
18    
19    /*
20     *----------------------------------------------------------------------
21     *
22     * XCreateBitmapFromData --
23     *
24     *      Construct a single plane pixmap from bitmap data.
25     *
26     *      NOTE: This procedure has the correct behavior on Windows and
27     *      the Macintosh, but not on UNIX.  This is probably because the
28     *      emulation for XPutImage on those platforms compensates for whatever
29     *      is wrong here :-)
30     *
31     * Results:
32     *      Returns a new Pixmap.
33     *
34     * Side effects:
35     *      Allocates a new bitmap and drawable.
36     *
37     *----------------------------------------------------------------------
38     */
39    
40    Pixmap
41    XCreateBitmapFromData(display, d, data, width, height)
42        Display* display;
43        Drawable d;
44        _Xconst char* data;
45        unsigned int width;
46        unsigned int height;
47    {
48        XImage ximage;
49        GC gc;
50        Pixmap pix;
51    
52        pix = Tk_GetPixmap(display, d, width, height, 1);
53        gc = XCreateGC(display, pix, 0, NULL);
54        if (gc == NULL) {
55            return None;
56        }
57        ximage.height = height;
58        ximage.width = width;
59        ximage.depth = 1;
60        ximage.bits_per_pixel = 1;
61        ximage.xoffset = 0;
62        ximage.format = XYBitmap;
63        ximage.data = (char *)data;
64        ximage.byte_order = LSBFirst;
65        ximage.bitmap_unit = 8;
66        ximage.bitmap_bit_order = LSBFirst;
67        ximage.bitmap_pad = 8;
68        ximage.bytes_per_line = (width+7)/8;
69    
70        TkPutImage(NULL, 0, display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
71        XFreeGC(display, gc);
72        return pix;
73    }
74    
75    /* End of ximage.c */

Legend:
Removed from v.42  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25