aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/ImUtil.c
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2016-07-29 00:44:38 +0200
committerUlrich Sibiller <uli42@gmx.de>2016-10-10 22:52:29 +0200
commit687d44b6eaa3c64a12af9bbd557b401419b208eb (patch)
tree55c30ba6b0ae6a2618395fae92922ea4402d52f6 /nx-X11/lib/X11/ImUtil.c
parentea24f0b0eb7b82ad879810c8e84292d6bf810bea (diff)
downloadnx-libs-687d44b6eaa3c64a12af9bbd557b401419b208eb.tar.gz
nx-libs-687d44b6eaa3c64a12af9bbd557b401419b208eb.tar.bz2
nx-libs-687d44b6eaa3c64a12af9bbd557b401419b208eb.zip
update src files *[ch] to libX11 1.3.4
Diffstat (limited to 'nx-X11/lib/X11/ImUtil.c')
-rw-r--r--nx-X11/lib/X11/ImUtil.c222
1 files changed, 109 insertions, 113 deletions
diff --git a/nx-X11/lib/X11/ImUtil.c b/nx-X11/lib/X11/ImUtil.c
index dabe3d5b6..00b6f7db8 100644
--- a/nx-X11/lib/X11/ImUtil.c
+++ b/nx-X11/lib/X11/ImUtil.c
@@ -49,8 +49,8 @@ static int _XAddPixel(XImage *, long);
static unsigned char const _lomask[0x09] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
static unsigned char const _himask[0x09] = { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00 };
-/* These two convenience routines return the scanline_pad and bits_per_pixel
- associated with a specific depth of ZPixmap format image for a
+/* These two convenience routines return the scanline_pad and bits_per_pixel
+ associated with a specific depth of ZPixmap format image for a
display. */
int
@@ -60,14 +60,14 @@ _XGetScanlinePad(
{
register ScreenFormat *fmt = dpy->pixmap_format;
register int i;
-
+
for (i = dpy->nformats + 1; --i; ++fmt)
if (fmt->depth == depth)
return(fmt->scanline_pad);
-
+
return(dpy->bitmap_pad);
}
-
+
int
_XGetBitsPerPixel(
Display *dpy,
@@ -75,7 +75,7 @@ _XGetBitsPerPixel(
{
register ScreenFormat *fmt = dpy->pixmap_format;
register int i;
-
+
for (i = dpy->nformats + 1; --i; ++fmt)
if (fmt->depth == depth)
return(fmt->bits_per_pixel);
@@ -87,7 +87,7 @@ _XGetBitsPerPixel(
return 16;
return 32;
}
-
+
/*
* This module provides rudimentary manipulation routines for image data
@@ -111,7 +111,7 @@ _XGetBitsPerPixel(
*
* The logic contained in these routines makes several assumptions about
* the image data structures, and at least for current implementations
- * these assumptions are believed to be true. They are:
+ * these assumptions are believed to be true. They are:
*
* For all formats, bits_per_pixel is less than or equal to 32.
* For XY formats, bitmap_unit is always less than or equal to bitmap_pad.
@@ -211,31 +211,31 @@ static void _putbits(
break;
}
numbits = numbits - dstoffset;
- }
+ }
}
/*
* Macros
- *
+ *
* The ROUNDUP macro rounds up a quantity to the specified boundary,
* then truncates to bytes.
*
- * The XYNORMALIZE macro determines whether XY format data requires
+ * The XYNORMALIZE macro determines whether XY format data requires
* normalization and calls a routine to do so if needed. The logic in
- * this module is designed for LSBFirst byte and bit order, so
+ * this module is designed for LSBFirst byte and bit order, so
* normalization is done as required to present the data in this order.
*
- * The ZNORMALIZE macro performs byte and nibble order normalization if
+ * The ZNORMALIZE macro performs byte and nibble order normalization if
* required for Z format data.
*
* The XYINDEX macro computes the index to the starting byte (char) boundary
* for a bitmap_unit containing a pixel with coordinates x and y for image
* data in XY format.
- *
- * The ZINDEX macro computes the index to the starting byte (char) boundary
+ *
+ * The ZINDEX macro computes the index to the starting byte (char) boundary
* for a pixel with coordinates x and y for image data in ZPixmap format.
- *
+ *
*/
#if defined(Lynx) && defined(ROUNDUP)
@@ -299,26 +299,25 @@ void _XInitImageFuncPtrs (
/*
* CreateImage
- *
- * Allocates the memory necessary for an XImage data structure.
- * Initializes the structure with "default" values and returns XImage.
- *
+ *
+ * Allocates the memory necessary for an XImage data structure.
+ * Initializes the structure with "default" values and returns XImage.
+ *
*/
-XImage *XCreateImage (dpy, visual, depth, format, offset, data, width, height,
- xpad, image_bytes_per_line)
- register Display *dpy;
- register Visual *visual;
- unsigned int depth;
- int format;
- int offset; /*How many pixels from the start of the data does the
+XImage *XCreateImage (
+ register Display *dpy,
+ register Visual *visual,
+ unsigned int depth,
+ int format,
+ int offset, /*How many pixels from the start of the data does the
picture to be transmitted start?*/
- char *data;
- unsigned int width;
- unsigned int height;
- int xpad;
- int image_bytes_per_line;
+ char *data,
+ unsigned int width,
+ unsigned int height,
+ int xpad,
+ int image_bytes_per_line)
/*How many bytes between a pixel on one line and the pixel with
the same X coordinate on the next line? 0 means
XCreateImage can calculate it.*/
@@ -350,7 +349,7 @@ XImage *XCreateImage (dpy, visual, depth, format, offset, data, width, height,
else {
image->red_mask = image->green_mask = image->blue_mask = 0;
}
- if (format == ZPixmap)
+ if (format == ZPixmap)
{
bits_per_pixel = _XGetBitsPerPixel(dpy, (int) depth);
}
@@ -364,7 +363,7 @@ XImage *XCreateImage (dpy, visual, depth, format, offset, data, width, height,
*/
{
if (format == ZPixmap)
- min_bytes_per_line =
+ min_bytes_per_line =
ROUNDUP((bits_per_pixel * width), image->bitmap_pad);
else
min_bytes_per_line =
@@ -373,7 +372,7 @@ XImage *XCreateImage (dpy, visual, depth, format, offset, data, width, height,
if (image_bytes_per_line == 0) {
image->bytes_per_line = min_bytes_per_line;
} else if (image_bytes_per_line < min_bytes_per_line) {
- return 0;
+ return NULL;
} else {
image->bytes_per_line = image_bytes_per_line;
}
@@ -385,8 +384,7 @@ XImage *XCreateImage (dpy, visual, depth, format, offset, data, width, height,
return image;
}
-Status XInitImage (image)
- XImage *image;
+Status XInitImage (XImage *image)
{
int min_bytes_per_line;
@@ -407,7 +405,7 @@ Status XInitImage (image)
* compute per line accelerator.
*/
if (image->format == ZPixmap)
- min_bytes_per_line =
+ min_bytes_per_line =
ROUNDUP((image->bits_per_pixel * image->width),
image->bitmap_pad);
else
@@ -427,15 +425,13 @@ Status XInitImage (image)
/*
* _DestroyImage
- *
- * Deallocates the memory associated with the ximage data structure.
+ *
+ * Deallocates the memory associated with the ximage data structure.
* this version handles the case of the image data being malloc'd
* entirely by the library.
*/
-static int _XDestroyImage (ximage)
- XImage *ximage;
-
+static int _XDestroyImage (XImage *ximage)
{
if (ximage->data != NULL) Xfree((char *)ximage->data);
if (ximage->obdata != NULL) Xfree((char *)ximage->obdata);
@@ -446,8 +442,8 @@ static int _XDestroyImage (ximage)
/*
* GetPixel
- *
- * Returns the specified pixel. The X and Y coordinates are relative to
+ *
+ * Returns the specified pixel. The X and Y coordinates are relative to
* the origin (upper left [0,0]) of the image. The pixel value is returned
* in normalized format, i.e. the LSB of the long is the LSB of the pixel.
* The algorithm used is:
@@ -470,10 +466,10 @@ static unsigned long const low_bits_table[] = {
0xffffffff
};
-static unsigned long _XGetPixel (ximage, x, y)
- register XImage *ximage;
- int x;
- int y;
+static unsigned long _XGetPixel (
+ register XImage *ximage,
+ int x,
+ int y)
{
unsigned long pixel, px;
@@ -482,7 +478,7 @@ static unsigned long _XGetPixel (ximage, x, y)
register int i, j;
int bits, nbytes;
long plane;
-
+
if ((ximage->bits_per_pixel | ximage->depth) == 1) {
src = &ximage->data[XYINDEX(x, y, ximage)];
dst = (char *)&pixel;
@@ -511,7 +507,7 @@ static unsigned long _XGetPixel (ximage, x, y)
dst = (char *)&px;
px = 0;
for (i = (ximage->bits_per_pixel + 7) >> 3; --i >= 0; )
- *dst++ = *src++;
+ *dst++ = *src++;
ZNORMALIZE(&px, ximage);
pixel = 0;
for (i=sizeof(unsigned long); --i >= 0; )
@@ -533,10 +529,10 @@ static unsigned long _XGetPixel (ximage, x, y)
static CARD32 const byteorderpixel = MSBFirst << 24;
-static unsigned long _XGetPixel32 (ximage, x, y)
- register XImage *ximage;
- int x;
- int y;
+static unsigned long _XGetPixel32 (
+ register XImage *ximage,
+ int x,
+ int y)
{
register unsigned char *addr;
unsigned long pixel;
@@ -566,10 +562,10 @@ static unsigned long _XGetPixel32 (ximage, x, y)
}
}
-static unsigned long _XGetPixel16 (ximage, x, y)
- register XImage *ximage;
- int x;
- int y;
+static unsigned long _XGetPixel16 (
+ register XImage *ximage,
+ int x,
+ int y)
{
register unsigned char *addr;
unsigned long pixel;
@@ -590,10 +586,10 @@ static unsigned long _XGetPixel16 (ximage, x, y)
}
}
-static unsigned long _XGetPixel8 (ximage, x, y)
- register XImage *ximage;
- int x;
- int y;
+static unsigned long _XGetPixel8 (
+ register XImage *ximage,
+ int x,
+ int y)
{
unsigned char pixel;
@@ -609,10 +605,10 @@ static unsigned long _XGetPixel8 (ximage, x, y)
}
}
-static unsigned long _XGetPixel1 (ximage, x, y)
- register XImage *ximage;
- int x;
- int y;
+static unsigned long _XGetPixel1 (
+ register XImage *ximage,
+ int x,
+ int y)
{
unsigned char bit;
int xoff, yoff;
@@ -632,11 +628,11 @@ static unsigned long _XGetPixel1 (ximage, x, y)
return XGetPixel(ximage, x, y);
}
}
-
+
/*
* PutPixel
- *
- * Overwrites the specified pixel. The X and Y coordinates are relative to
+ *
+ * Overwrites the specified pixel. The X and Y coordinates are relative to
* the origin (upper left [0,0]) of the image. The input pixel value must be
* in normalized format, i.e. the LSB of the long is the LSB of the pixel.
* The algorithm used is:
@@ -649,11 +645,11 @@ static unsigned long _XGetPixel1 (ximage, x, y)
*
*/
-static int _XPutPixel (ximage, x, y, pixel)
- register XImage *ximage;
- int x;
- int y;
- unsigned long pixel;
+static int _XPutPixel (
+ register XImage *ximage,
+ int x,
+ int y,
+ unsigned long pixel)
{
unsigned long px, npixel;
@@ -709,8 +705,8 @@ static int _XPutPixel (ximage, x, y, pixel)
nbytes = (ximage->bits_per_pixel + 7) >> 3;
for (i = nbytes; --i >= 0; ) *dst++ = *src++;
ZNORMALIZE(&px, ximage);
- _putbits ((char *)&pixel,
- (x * ximage->bits_per_pixel) & 7,
+ _putbits ((char *)&pixel,
+ (x * ximage->bits_per_pixel) & 7,
ximage->bits_per_pixel, (char *)&px);
ZNORMALIZE(&px, ximage);
src = (char *)&px;
@@ -722,11 +718,11 @@ static int _XPutPixel (ximage, x, y, pixel)
return 1;
}
-static int _XPutPixel32 (ximage, x, y, pixel)
- register XImage *ximage;
- int x;
- int y;
- unsigned long pixel;
+static int _XPutPixel32 (
+ register XImage *ximage,
+ int x,
+ int y,
+ unsigned long pixel)
{
unsigned char *addr;
@@ -754,11 +750,11 @@ static int _XPutPixel32 (ximage, x, y, pixel)
}
}
-static int _XPutPixel16 (ximage, x, y, pixel)
- register XImage *ximage;
- int x;
- int y;
- unsigned long pixel;
+static int _XPutPixel16 (
+ register XImage *ximage,
+ int x,
+ int y,
+ unsigned long pixel)
{
unsigned char *addr;
@@ -779,11 +775,11 @@ static int _XPutPixel16 (ximage, x, y, pixel)
}
}
-static int _XPutPixel8 (ximage, x, y, pixel)
- register XImage *ximage;
- int x;
- int y;
- unsigned long pixel;
+static int _XPutPixel8 (
+ register XImage *ximage,
+ int x,
+ int y,
+ unsigned long pixel)
{
if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 8)) {
ximage->data[y * ximage->bytes_per_line + x] = pixel;
@@ -794,11 +790,11 @@ static int _XPutPixel8 (ximage, x, y, pixel)
}
}
-static int _XPutPixel1 (ximage, x, y, pixel)
- register XImage *ximage;
- int x;
- int y;
- unsigned long pixel;
+static int _XPutPixel1 (
+ register XImage *ximage,
+ int x,
+ int y,
+ unsigned long pixel)
{
unsigned char bit;
int xoff, yoff;
@@ -825,20 +821,20 @@ static int _XPutPixel1 (ximage, x, y, pixel)
/*
* SubImage
- *
+ *
* Creates a new image that is a subsection of an existing one.
- * Allocates the memory necessary for the new XImage data structure.
+ * Allocates the memory necessary for the new XImage data structure.
* Pointer to new image is returned. The algorithm used is repetitive
* calls to get and put pixel.
*
*/
-static XImage *_XSubImage (ximage, x, y, width, height)
- XImage *ximage;
- register int x; /* starting x coordinate in existing image */
- register int y; /* starting y coordinate in existing image */
- unsigned int width; /* width in pixels of new subimage */
- unsigned int height;/* height in pixels of new subimage */
+static XImage *_XSubImage (
+ XImage *ximage,
+ register int x, /* starting x coordinate in existing image */
+ register int y, /* starting y coordinate in existing image */
+ unsigned int width, /* width in pixels of new subimage */
+ unsigned int height)/* height in pixels of new subimage */
{
register XImage *subimage;
@@ -862,8 +858,8 @@ static XImage *_XSubImage (ximage, x, y, width, height)
/*
* compute per line accelerator.
*/
- if (subimage->format == ZPixmap)
- subimage->bytes_per_line =
+ if (subimage->format == ZPixmap)
+ subimage->bytes_per_line =
ROUNDUP(subimage->bits_per_pixel * width,
subimage->bitmap_pad);
else
@@ -900,7 +896,7 @@ static XImage *_XSubImage (ximage, x, y, width, height)
/*
* SetImage
- *
+ *
* Overwrites a section of one image with all of the data from another.
* If the two images are not of the same format (i.e. XYPixmap and ZPixmap),
* the image data is converted to the destination format. The following
@@ -915,7 +911,7 @@ static XImage *_XSubImage (ximage, x, y, width, height)
* 3. If the width of the source image is too large to fit between
* the specified x starting point and the end of the scanline,
* then pixels are truncated on the right.
- *
+ *
* The images need not have the same bitmap_bit_order, byte_order,
* bitmap_unit, bits_per_pixel, bitmap_pad, or xoffset.
*
@@ -959,15 +955,15 @@ int _XSetImage(
/*
* AddPixel
- *
+ *
* Adds a constant value to every pixel in a pixmap.
*
*/
static int
-_XAddPixel (ximage, value)
- register XImage *ximage;
- register long value;
+_XAddPixel (
+ register XImage *ximage,
+ register long value)
{
register int x;
register int y;