-/* File: maid-x11.c */
+/* File: maid-x11.c */
/*
* Copyright (c) 1997 Ben Harrison, and others
#ifdef USE_X11
-#include "main/x11-gamma-builder.h"
+#include "main-unix/x11-gamma-builder.h"
#include <math.h>
/*
XColor xcolour;
if (!gamma_table_ready) {
concptr str = getenv("ANGBAND_X11_GAMMA");
- if (str != nullptr)
+ if (str != nullptr) {
gamma_val = atoi(str);
+ }
gamma_table_ready = true;
/* Only need to build the table if gamma exists */
- if (gamma_val)
+ if (gamma_val) {
build_gamma_table(gamma_val);
+ }
}
/* Hack -- Gamma Correction */
/* Determine total bytes needed for image */
i = 1;
j = (depth - 1) >> 2;
- while (j >>= 1)
+ while (j >>= 1) {
i <<= 1;
+ }
total = infoheader.biWidth * infoheader.biHeight * i;
/* Allocate image memory */
- Data = (char*)malloc(total);
+ Data = (char *)malloc(total);
Res = XCreateImage(dpy, visual, depth, ZPixmap, 0 /*offset*/, Data, infoheader.biWidth, infoheader.biHeight, 8 /*bitmap_pad*/, 0 /*bytes_per_line*/);
int ch = getc(f);
/* Verify not at end of file XXX XXX */
- if (feof(f))
+ if (feof(f)) {
quit_fmt("Unexpected end of file in %s", Name);
+ }
if (infoheader.biBitCount == 24) {
int c2 = getc(f);
int c3 = getc(f);
/* Verify not at end of file XXX XXX */
- if (feof(f))
+ if (feof(f)) {
quit_fmt("Unexpected end of file in %s", Name);
+ }
XPutPixel(Res, x, y2, create_pixel(dpy, ch, c2, c3));
} else if (infoheader.biBitCount == 8) {
unsigned long pix;
unsigned long adj = div / 2;
for (xi = 0; xi < w; xi++) {
- pix = (((((redScan[xi] + adj) / div) & redMask) << redShift) + ((((greenScan[xi] + adj) / div) & greenMask) << greenShift)
- + ((((blueScan[xi] + adj) / div) & blueMask) << blueShift));
+ pix = (((((redScan[xi] + adj) / div) & redMask) << redShift) + ((((greenScan[xi] + adj) / div) & greenMask) << greenShift) + ((((blueScan[xi] + adj) / div) & blueMask) << blueShift));
XPutPixel(Im, x + xi, y, pix);
}
}
bool getNextRow;
/* get divider value for the horizontal scaling: */
- if (ix == ox)
+ if (ix == ox) {
div = 1;
- else if (ix < ox)
+ } else if (ix < ox) {
div = ox - 1;
- else
+ } else {
div = ix;
+ }
if (iy == oy) {
/* no scaling needed vertically: */
Visual *visual = DefaultVisual(dpy, DefaultScreen(dpy));
int width1, height1, width2, height2;
- volatile int x1, x2, y1, y2, Tx, Ty;
- volatile int *px1, *px2, *dx1, *dx2;
- volatile int *py1, *py2, *dy1, *dy2;
+ int x1, x2, y1, y2, Tx, Ty;
+ int dx1, dx2, dy1, dy2;
XImage *Tmp;
Tmp = XCreateImage(dpy, visual, Im->depth, ZPixmap, 0, Data, width2, height2, 32, 0);
if (ix > ox) {
- px1 = &x1;
- px2 = &x2;
- dx1 = &ix;
- dx2 = &ox;
+ dx1 = ix;
+ dx2 = ox;
} else {
- px1 = &x2;
- px2 = &x1;
- dx1 = &ox;
- dx2 = &ix;
+ dx1 = ox;
+ dx2 = ix;
}
if (iy > oy) {
- py1 = &y1;
- py2 = &y2;
- dy1 = &iy;
- dy2 = &oy;
+ dy1 = iy;
+ dy2 = oy;
} else {
- py1 = &y2;
- py2 = &y1;
- dy1 = &oy;
- dy2 = &iy;
+ dy1 = oy;
+ dy2 = iy;
}
- Ty = *dy1 / 2;
+ Ty = dy1 / 2;
for (y1 = 0, y2 = 0; (y1 < height1) && (y2 < height2);) {
- Tx = *dx1 / 2;
+ Tx = dx1 / 2;
for (x1 = 0, x2 = 0; (x1 < width1) && (x2 < width2);) {
XPutPixel(Tmp, x2, y2, XGetPixel(Im, x1, y1));
- (*px1)++;
+ if (ix > ox) {
+ ++x1;
+ } else {
+ ++x2;
+ }
- Tx -= *dx2;
+ Tx -= dx2;
if (Tx < 0) {
- Tx += *dx1;
- (*px2)++;
+ Tx += dx1;
+ if (ix > ox) {
+ ++x2;
+ } else {
+ ++x1;
+ }
}
}
- (*py1)++;
+ if (iy > oy) {
+ ++y1;
+ } else {
+ ++y2;
+ }
- Ty -= *dy2;
+ Ty -= dy2;
if (Ty < 0) {
- Ty += *dy1;
- (*py2)++;
+ Ty += dy1;
+ if (iy > oy) {
+ ++y2;
+ } else {
+ ++y1;
+ }
}
}