Commit 97b9864e authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

Convert XCreate{Pix,Bit}map...Data to use C99 designated initializers

parent 7a8721b8
...@@ -53,30 +53,28 @@ Pixmap XCreateBitmapFromData( ...@@ -53,30 +53,28 @@ Pixmap XCreateBitmapFromData(
unsigned int width, unsigned int width,
unsigned int height) unsigned int height)
{ {
XImage ximage; Pixmap pix = XCreatePixmap(display, d, width, height, 1);
GC gc; GC gc = XCreateGC(display, pix, (unsigned long) 0, (XGCValues *) 0);
Pixmap pix;
pix = XCreatePixmap(display, d, width, height, 1);
gc = XCreateGC(display, pix, (unsigned long) 0, (XGCValues *) 0);
if (gc == NULL) { if (gc == NULL) {
XFreePixmap(display, pix); XFreePixmap(display, pix);
return (Pixmap) None; return (Pixmap) None;
} } else {
ximage.height = height; XImage ximage = {
ximage.width = width; .height = height,
ximage.depth = 1; .width = width,
ximage.bits_per_pixel = 1; .depth = 1,
ximage.xoffset = 0; .bits_per_pixel = 1,
ximage.format = XYPixmap; .xoffset = 0,
ximage.data = (char *)data; .format = XYPixmap,
ximage.byte_order = LSBFirst; .data = (char *) data,
ximage.bitmap_unit = 8; .byte_order = LSBFirst,
ximage.bitmap_bit_order = LSBFirst; .bitmap_unit = 8,
ximage.bitmap_pad = 8; .bitmap_bit_order = LSBFirst,
ximage.bytes_per_line = (width+7)/8; .bitmap_pad = 8,
.bytes_per_line = (width + 7) / 8,
};
XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height); XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
XFreeGC(display, gc); XFreeGC(display, gc);
return(pix); return(pix);
}
} }
...@@ -58,33 +58,32 @@ Pixmap XCreatePixmapFromBitmapData( ...@@ -58,33 +58,32 @@ Pixmap XCreatePixmapFromBitmapData(
unsigned long bg, unsigned long bg,
unsigned int depth) unsigned int depth)
{ {
XImage ximage; Pixmap pix = XCreatePixmap(display, d, width, height, depth);
GC gc; XGCValues gcv = {
XGCValues gcv; .foreground = fg,
Pixmap pix; .background = bg
};
pix = XCreatePixmap(display, d, width, height, depth); GC gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv);
gcv.foreground = fg;
gcv.background = bg;
gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv);
if (gc == NULL) { if (gc == NULL) {
XFreePixmap(display, pix); XFreePixmap(display, pix);
return (Pixmap) None; return (Pixmap) None;
} } else {
ximage.height = height; XImage ximage = {
ximage.width = width; .height = height,
ximage.depth = 1; .width = width,
ximage.bits_per_pixel = 1; .depth = 1,
ximage.xoffset = 0; .bits_per_pixel = 1,
ximage.format = XYBitmap; .xoffset = 0,
ximage.data = data; .format = XYBitmap,
ximage.byte_order = LSBFirst; .data = data,
ximage.bitmap_unit = 8; .byte_order = LSBFirst,
ximage.bitmap_bit_order = LSBFirst; .bitmap_unit = 8,
ximage.bitmap_pad = 8; .bitmap_bit_order = LSBFirst,
ximage.bytes_per_line = (width+7)/8; .bitmap_pad = 8,
.bytes_per_line = (width + 7) / 8
};
XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height); XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
XFreeGC(display, gc); XFreeGC(display, gc);
return(pix); return(pix);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment