Changeset 29368 for lang/c/SDL_image_save/trunk/IMGS_jpg.c
- Timestamp:
- 02/01/09 03:41:52 (4 years ago)
- Files:
-
- 1 modified
-
lang/c/SDL_image_save/trunk/IMGS_jpg.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/SDL_image_save/trunk/IMGS_jpg.c
r29324 r29368 26 26 27 27 #include <setjmp.h> 28 #include " libjpeg/jpeglib.h"28 #include "jpeglib.h" 29 29 30 30 /* This code assumes that sizeof(JSAMPLE) is 8 bit */ … … 80 80 { 81 81 struct imgs_destination_mgr *dest = (struct imgs_destination_mgr *) cinfo->dest; 82 int size = OUTPUT_BUFFER_SIZE - dest->pub.free_in_buffer;82 size_t size = OUTPUT_BUFFER_SIZE - dest->pub.free_in_buffer; 83 83 84 84 /* Output data to data stream */ 85 SDL_RWwrite(dest->ops, dest->buffer, 1, size);85 SDL_RWwrite(dest->ops, dest->buffer, 1, (int)size); 86 86 } 87 87 … … 102 102 static void jpg_output_no_message(j_common_ptr cinfo) 103 103 { 104 (void)cinfo; 104 105 /* do nothing */ 105 106 } … … 133 134 /* Add 0.5 to round off */ 134 135 int c = (int) (val + 0.5f); 135 if ( c > 255 ) c = 255;136 colormap[i] = c;136 if ( c > MAXJSAMPLE ) c = MAXJSAMPLE; 137 colormap[i] = (JSAMPLE)c; 137 138 } 138 139 } … … 151 152 const Uint32 Gmask = fmt->Gmask; 152 153 const Uint32 Bmask = fmt->Bmask; 153 const Uint32 Amask = fmt->Amask;154 154 const Uint32 Rshift = fmt->Rshift; 155 155 const Uint32 Gshift = fmt->Gshift; 156 156 const Uint32 Bshift = fmt->Bshift; 157 const Uint32 Ashift = fmt->Ashift;158 157 159 158 JSAMPROW row_pointer = NULL; … … 296 295 for ( x = 0; x < row_bytes; x += 3 ) { 297 296 Uint32 c = (pixels[x + 2] << 16) | (pixels[x + 1] << 8) | (pixels[x + 0] << 0); 298 row_pointer[x + 0] = ( c & Rmask) >> Rshift;299 row_pointer[x + 1] = ( c & Gmask) >> Gshift;300 row_pointer[x + 2] = ( c & Bmask) >> Bshift;297 row_pointer[x + 0] = (JSAMPLE)((c & Rmask) >> Rshift); 298 row_pointer[x + 1] = (JSAMPLE)((c & Gmask) >> Gshift); 299 row_pointer[x + 2] = (JSAMPLE)((c & Bmask) >> Bshift); 301 300 } 302 301 pixels += surface_pitch; … … 316 315 for ( x = 0; x < width; ++x ) { 317 316 Uint32 c = *(Uint32 *) &pixels[x * 4]; 318 row_pointer[x * 3 + 0] = ( c & Rmask) >> Rshift;319 row_pointer[x * 3 + 1] = ( c & Gmask) >> Gshift;320 row_pointer[x * 3 + 2] = ( c & Bmask) >> Bshift;317 row_pointer[x * 3 + 0] = (JSAMPLE)((c & Rmask) >> Rshift); 318 row_pointer[x * 3 + 1] = (JSAMPLE)((c & Gmask) >> Gshift); 319 row_pointer[x * 3 + 2] = (JSAMPLE)((c & Bmask) >> Bshift); 321 320 } 322 321 pixels += surface_pitch;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)