0

tabs -> spaces and removed windows newline

This commit is contained in:
Aaron Griffith
2012-07-03 21:07:40 -04:00
parent 2b421d6d25
commit 3286b9c576

View File

@@ -22,8 +22,7 @@
* PIL paste if this extension is not found.
*/
#include "overviewer.h"
#include <stdio.h>
#include "overviewer.h"
typedef struct {
PyObject_HEAD
@@ -502,123 +501,123 @@ resize_half(PyObject *dest, PyObject *src) {
/* iteration variables */
unsigned int x, y;
/* temp color variables */
unsigned int r, g, b, a;
unsigned int r, g, b, a;
/* size values for source and destination */
int src_width, src_height, dest_width, dest_height;
int src_width, src_height, dest_width, dest_height;
imDest = imaging_python_to_c(dest);
imSrc = imaging_python_to_c(src);
if (!imDest || !imSrc)
return NULL;
/* check the various image modes, make sure they make sense */
if (strcmp(imDest->mode, "RGBA") != 0) {
PyErr_SetString(PyExc_ValueError,
"given destination image does not have mode \"RGBA\"");
return NULL;
}
if (strcmp(imSrc->mode, "RGBA") != 0 && strcmp(imSrc->mode, "RGB") != 0) {
PyErr_SetString(PyExc_ValueError,
"given source image does not have mode \"RGBA\" or \"RGB\"");
return NULL;
}
src_width = imSrc->xsize;
src_height = imSrc->ysize;
dest_width = imDest->xsize;
dest_height = imDest->ysize;
src_width = imSrc->xsize;
src_height = imSrc->ysize;
dest_width = imDest->xsize;
dest_height = imDest->ysize;
/* make sure destination size is 1/2 src size */
if (src_width / 2 != dest_width || src_height / 2 != dest_height) {
PyErr_SetString(PyExc_ValueError,
"destination image size is not one-half source image size");
return NULL;
}
/* set up flags for the src/mask type */
src_has_alpha = (imSrc->pixelsize == 4 ? 1 : 0);
dest_has_alpha = (imDest->pixelsize == 4 ? 1 : 0);
/* check that there remains anything to resize */
if (dest_width <= 0 || dest_height <= 0) {
/* nothing to do, return */
return dest;
}
/* set to fully opaque if source has no alpha channel */
if(!src_has_alpha)
a = 0xFF << 2;
if(!src_has_alpha)
a = 0xFF << 2;
for (y = 0; y < dest_height; y++) {
UINT8 *out = (UINT8 *)imDest->image[y];
UINT8 *in_row1 = (UINT8 *)imSrc->image[y * 2];
UINT8 *in_row2 = (UINT8 *)imSrc->image[y * 2 + 1];
for (x = 0; x < dest_width; x++) {
// read first column
r = *in_row1;
r += *in_row2;
in_row1++;
in_row2++;
g = *in_row1;
g += *in_row2;
in_row1++;
in_row2++;
b = *in_row1;
b += *in_row2;
in_row1++;
in_row2++;
// read first column
r = *in_row1;
r += *in_row2;
in_row1++;
in_row2++;
g = *in_row1;
g += *in_row2;
in_row1++;
in_row2++;
b = *in_row1;
b += *in_row2;
in_row1++;
in_row2++;
if (src_has_alpha)
{
a = *in_row1;
a += *in_row2;
in_row1++;
in_row2++;
}
// read second column
r += *in_row1;
r += *in_row2;
in_row1++;
in_row2++;
g += *in_row1;
g += *in_row2;
in_row1++;
in_row2++;
b += *in_row1;
b += *in_row2;
in_row1++;
in_row2++;
{
a = *in_row1;
a += *in_row2;
in_row1++;
in_row2++;
}
// read second column
r += *in_row1;
r += *in_row2;
in_row1++;
in_row2++;
g += *in_row1;
g += *in_row2;
in_row1++;
in_row2++;
b += *in_row1;
b += *in_row2;
in_row1++;
in_row2++;
if (src_has_alpha)
{
a += *in_row1;
a += *in_row2;
in_row1++;
in_row2++;
}
// write blended color
{
a += *in_row1;
a += *in_row2;
in_row1++;
in_row2++;
}
// write blended color
*out = (UINT8)(r >> 2);
out++;
*out = (UINT8)(g >> 2);
out++;
*out = (UINT8)(b >> 2);
out++;
if (dest_has_alpha)
{
*out = (UINT8)(a >> 2);
out++;
}
*out = (UINT8)(a >> 2);
out++;
}
}
}
return dest;
}
@@ -630,7 +629,7 @@ resize_half_wrap(PyObject *self, PyObject *args)
PyObject *dest, *src;
/* return value: dest image on success */
PyObject *ret;
if (!PyArg_ParseTuple(args, "OO", &dest, &src))
return NULL;
@@ -640,4 +639,4 @@ resize_half_wrap(PyObject *self, PyObject *args)
Py_INCREF(dest);
}
return ret;
}
}