1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-04 21:04:18 +01:00

changed indentation to use spaces only

This commit is contained in:
dan
2004-10-12 21:28:27 +00:00
parent 5912898b06
commit 6830b05716
240 changed files with 35951 additions and 35773 deletions

View File

@@ -1,5 +1,5 @@
/* xpixmap.c - Make RImage from Pixmap or XImage
*
*
* Raster graphics library
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -37,20 +37,20 @@ static int
get_shifts(unsigned long mask)
{
int i=0;
while (mask) {
mask>>=1;
i++;
mask>>=1;
i++;
}
return i;
}
#define NORMALIZE_RED(pixel) ((rshift>0) ? ((pixel) & rmask) >> rshift \
: ((pixel) & rmask) << -rshift)
: ((pixel) & rmask) << -rshift)
#define NORMALIZE_GREEN(pixel) ((gshift>0) ? ((pixel) & gmask) >> gshift \
: ((pixel) & gmask) << -gshift)
: ((pixel) & gmask) << -gshift)
#define NORMALIZE_BLUE(pixel) ((bshift>0) ? ((pixel) & bmask) >> bshift \
: ((pixel) & bmask) << -bshift)
: ((pixel) & bmask) << -bshift)
RImage*
RCreateImageFromXImage(RContext *context, XImage *image, XImage *mask)
@@ -73,16 +73,16 @@ RCreateImageFromXImage(RContext *context, XImage *image, XImage *mask)
/* I don't know why, but XGetImage() for pixmaps don't set the
* {red,green,blue}_mask values correctly.
*/
* {red,green,blue}_mask values correctly.
*/
if (context->depth==image->depth) {
rmask = context->visual->red_mask;
gmask = context->visual->green_mask;
bmask = context->visual->blue_mask;
rmask = context->visual->red_mask;
gmask = context->visual->green_mask;
bmask = context->visual->blue_mask;
} else {
rmask = image->red_mask;
gmask = image->green_mask;
bmask = image->blue_mask;
rmask = image->red_mask;
gmask = image->green_mask;
bmask = image->blue_mask;
}
/* how many bits to shift to normalize the color into 8bpp */
@@ -94,29 +94,29 @@ RCreateImageFromXImage(RContext *context, XImage *image, XImage *mask)
if (image->depth==1) {
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++) {
pixel = XGetPixel(image, x, y);
if (pixel) {
*data++ = 0;
*data++ = 0;
*data++ = 0;
} else {
*data++ = 0xff;
*data++ = 0xff;
*data++ = 0xff;
for (x = 0; x < image->width; x++) {
pixel = XGetPixel(image, x, y);
if (pixel) {
*data++ = 0;
*data++ = 0;
*data++ = 0;
} else {
*data++ = 0xff;
*data++ = 0xff;
*data++ = 0xff;
}
if (mask) data++;
}
if (mask) data++;
}
}
} else {
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++) {
pixel = XGetPixel(image, x, y);
*(data++) = NORMALIZE_RED(pixel);
*(data++) = NORMALIZE_GREEN(pixel);
*(data++) = NORMALIZE_BLUE(pixel);
if (mask) data++;
}
for (x = 0; x < image->width; x++) {
pixel = XGetPixel(image, x, y);
*(data++) = NORMALIZE_RED(pixel);
*(data++) = NORMALIZE_GREEN(pixel);
*(data++) = NORMALIZE_BLUE(pixel);
if (mask) data++;
}
}
}
@@ -160,33 +160,34 @@ RCreateImageFromDrawable(RContext *context, Drawable drawable, Pixmap mask)
assert(drawable!=None);
if (!XGetGeometry(context->dpy, drawable, &baz, &foo, &foo,
&w, &h, &bar, &bar)) {
printf("wrlib: invalid window or pixmap passed to RCreateImageFromPixmap\n");
return NULL;
if (!XGetGeometry(context->dpy, drawable, &baz, &foo, &foo,
&w, &h, &bar, &bar)) {
printf("wrlib: invalid window or pixmap passed to RCreateImageFromPixmap\n");
return NULL;
}
pimg = XGetImage(context->dpy, drawable, 0, 0, w, h, AllPlanes,
ZPixmap);
pimg = XGetImage(context->dpy, drawable, 0, 0, w, h, AllPlanes,
ZPixmap);
if (!pimg) {
RErrorCode = RERR_XERROR;
return NULL;
RErrorCode = RERR_XERROR;
return NULL;
}
mimg = NULL;
if (mask) {
if (XGetGeometry(context->dpy, mask, &baz, &foo, &foo,
&w, &h, &bar, &bar)) {
mimg = XGetImage(context->dpy, mask, 0, 0, w, h, AllPlanes,
ZPixmap);
}
if (XGetGeometry(context->dpy, mask, &baz, &foo, &foo,
&w, &h, &bar, &bar)) {
mimg = XGetImage(context->dpy, mask, 0, 0, w, h, AllPlanes,
ZPixmap);
}
}
image = RCreateImageFromXImage(context, pimg, mimg);
XDestroyImage(pimg);
if (mimg)
XDestroyImage(mimg);
XDestroyImage(mimg);
return image;
}