1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-30 18:32:34 +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,19 +1,19 @@
/* jpeg.c - load JPEG image from file
*
*
* Raster graphics library
*
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
* This library is free software; you can redistribute it and/or
* 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.
@@ -68,9 +68,9 @@
*/
struct my_error_mgr {
struct jpeg_error_mgr pub; /* "public" fields */
struct jpeg_error_mgr pub; /* "public" fields */
jmp_buf setjmp_buffer; /* for return to caller */
jmp_buf setjmp_buffer; /* for return to caller */
};
typedef struct my_error_mgr * my_error_ptr;
@@ -82,15 +82,15 @@ typedef struct my_error_mgr * my_error_ptr;
static void
my_error_exit(j_common_ptr cinfo)
{
/* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
my_error_ptr myerr = (my_error_ptr) cinfo->err;
/* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
my_error_ptr myerr = (my_error_ptr) cinfo->err;
/* Always display the message. */
/* We could postpone this until after returning, if we chose. */
(*cinfo->err->output_message) (cinfo);
/* Always display the message. */
/* We could postpone this until after returning, if we chose. */
(*cinfo->err->output_message) (cinfo);
/* Return control to the setjmp point */
longjmp(myerr->setjmp_buffer, 1);
/* Return control to the setjmp point */
longjmp(myerr->setjmp_buffer, 1);
}
@@ -111,41 +111,41 @@ RLoadJPEG(RContext *context, char *file_name, int index)
file = fopen(file_name, "rb");
if (!file) {
RErrorCode = RERR_OPEN;
return NULL;
RErrorCode = RERR_OPEN;
return NULL;
}
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* Establish the setjmp return context for my_error_exit to use. */
if (setjmp(jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error.
* We need to clean up the JPEG object, close the input file, and return.
*/
jpeg_destroy_decompress(&cinfo);
fclose(file);
return NULL;
/* If we get here, the JPEG code has signaled an error.
* We need to clean up the JPEG object, close the input file, and return.
*/
jpeg_destroy_decompress(&cinfo);
fclose(file);
return NULL;
}
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, file);
jpeg_read_header(&cinfo, TRUE);
if (cinfo.image_width < 1 || cinfo.image_height < 1) {
RErrorCode = RERR_BADIMAGEFILE;
goto bye;
RErrorCode = RERR_BADIMAGEFILE;
goto bye;
}
bptr = buffer[0] = (JSAMPROW)malloc(cinfo.image_width*cinfo.num_components);
if (!buffer[0]) {
RErrorCode = RERR_NOMEMORY;
goto bye;
RErrorCode = RERR_NOMEMORY;
goto bye;
}
if(cinfo.jpeg_color_space==JCS_GRAYSCALE) {
cinfo.out_color_space=JCS_GRAYSCALE;
cinfo.out_color_space=JCS_GRAYSCALE;
} else
cinfo.out_color_space = JCS_RGB;
cinfo.quantize_colors = FALSE;
@@ -154,62 +154,63 @@ RLoadJPEG(RContext *context, char *file_name, int index)
jpeg_calc_output_dimensions(&cinfo);
if (context->flags.optimize_for_speed)
image = RCreateImage(cinfo.image_width, cinfo.image_height, True);
image = RCreateImage(cinfo.image_width, cinfo.image_height, True);
else
image = RCreateImage(cinfo.image_width, cinfo.image_height, False);
image = RCreateImage(cinfo.image_width, cinfo.image_height, False);
if (!image) {
RErrorCode = RERR_NOMEMORY;
goto bye;
RErrorCode = RERR_NOMEMORY;
goto bye;
}
jpeg_start_decompress(&cinfo);
ptr = image->data;
if (cinfo.out_color_space==JCS_RGB) {
if (context->flags.optimize_for_speed) {
while (cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, buffer,(JDIMENSION) 1);
bptr = buffer[0];
for (i=0; i<cinfo.image_width; i++) {
*ptr++ = *bptr++;
*ptr++ = *bptr++;
*ptr++ = *bptr++;
ptr++; /* skip alpha channel */
}
}
} else {
while (cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, buffer,(JDIMENSION) 1);
bptr = buffer[0];
memcpy(ptr, bptr, cinfo.image_width*3);
ptr += cinfo.image_width*3;
}
}
if (context->flags.optimize_for_speed) {
while (cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, buffer,(JDIMENSION) 1);
bptr = buffer[0];
for (i=0; i<cinfo.image_width; i++) {
*ptr++ = *bptr++;
*ptr++ = *bptr++;
*ptr++ = *bptr++;
ptr++; /* skip alpha channel */
}
}
} else {
while (cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, buffer,(JDIMENSION) 1);
bptr = buffer[0];
memcpy(ptr, bptr, cinfo.image_width*3);
ptr += cinfo.image_width*3;
}
}
} else {
while (cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, buffer,(JDIMENSION) 1);
bptr = buffer[0];
for (i=0; i<cinfo.image_width; i++) {
while (cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, buffer,(JDIMENSION) 1);
bptr = buffer[0];
for (i=0; i<cinfo.image_width; i++) {
*ptr++ = *bptr;
*ptr++ = *bptr;
*ptr++ = *bptr++;
}
}
}
}
}
jpeg_finish_decompress(&cinfo);
bye:
bye:
jpeg_destroy_decompress(&cinfo);
fclose(file);
if (buffer[0])
free(buffer[0]);
free(buffer[0]);
return image;
}
#endif /* USE_JPEG */