X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/655719367ac5e131d9642e5783f3ecf64d1a3385..cc4d5638c66a409e421420ed7110917755a66788:/src/common/quantize.cpp diff --git a/src/common/quantize.cpp b/src/common/quantize.cpp index 7d85887189..618f4e26b6 100644 --- a/src/common/quantize.cpp +++ b/src/common/quantize.cpp @@ -1,10 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: quantize.cpp +// Name: src/common/quantize.cpp // Purpose: wxQuantize implementation // Author: Julian Smart // Modified by: // Created: 22/6/2000 -// RCS-ID: $Id$ // Copyright: (c) Thomas G. Lane, Vaclav Slavik, Julian Smart // Licence: wxWindows licence + JPEG library licence ///////////////////////////////////////////////////////////////////////////// @@ -30,10 +29,6 @@ /* modified by Vaclav Slavik for use as jpeglib-independent module */ -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "quantize.h" -#endif - // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" @@ -41,17 +36,17 @@ #pragma hdrstop #endif -#ifndef WX_PRECOMP - #include "wx/palette.h" -#endif - #if wxUSE_IMAGE -#include "wx/image.h" #include "wx/quantize.h" +#ifndef WX_PRECOMP + #include "wx/palette.h" + #include "wx/image.h" +#endif + #ifdef __WXMSW__ -#include "wx/msw/private.h" + #include "wx/msw/private.h" #endif #include @@ -77,7 +72,9 @@ typedef unsigned short UINT16; typedef signed short INT16; +#if !(defined(__WATCOMC__) && (defined(__WXMSW__) || defined(__WXMOTIF__))) typedef signed int INT32; +#endif typedef unsigned char JSAMPLE; typedef JSAMPLE *JSAMPROW; @@ -1116,13 +1113,13 @@ pass2_fs_dither (j_decompress_ptr cinfo, dir = -1; dir3 = -3; errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */ - cquantize->on_odd_row = FALSE; /* flip for next time */ + cquantize->on_odd_row = false; /* flip for next time */ } else { /* work left to right in this row */ dir = 1; dir3 = 3; errorptr = cquantize->fserrors; /* => entry before first real column */ - cquantize->on_odd_row = TRUE; /* flip for next time */ + cquantize->on_odd_row = true; /* flip for next time */ } /* Preset error values: no error propagated to first pixel from left */ cur0 = cur1 = cur2 = 0; @@ -1282,7 +1279,7 @@ finish_pass1 (j_decompress_ptr cinfo) cinfo->colormap = cquantize->sv_colormap; select_colors(cinfo, cquantize->desired); /* Force next pass to zero the color index table */ - cquantize->needs_zeroed = TRUE; + cquantize->needs_zeroed = true; } @@ -1307,7 +1304,7 @@ start_pass_2_quant (j_decompress_ptr cinfo, bool is_pre_scan) /* Set up method pointers */ cquantize->pub.color_quantize = prescan_quantize; cquantize->pub.finish_pass = finish_pass1; - cquantize->needs_zeroed = TRUE; /* Always zero histogram */ + cquantize->needs_zeroed = true; /* Always zero histogram */ } else { /* Set up method pointers */ cquantize->pub.color_quantize = pass2_fs_dither; @@ -1324,7 +1321,7 @@ start_pass_2_quant (j_decompress_ptr cinfo, bool is_pre_scan) /* Make the error-limit table if we didn't already. */ if (cquantize->error_limiter == NULL) init_error_limit(cinfo); - cquantize->on_odd_row = FALSE; + cquantize->on_odd_row = false; } } @@ -1334,7 +1331,7 @@ start_pass_2_quant (j_decompress_ptr cinfo, bool is_pre_scan) memset((void *) histogram[i], 0, HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell)); } - cquantize->needs_zeroed = FALSE; + cquantize->needs_zeroed = false; } } @@ -1349,7 +1346,7 @@ new_color_map_2_quant (j_decompress_ptr cinfo) my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; /* Reset the inverse color map */ - cquantize->needs_zeroed = TRUE; + cquantize->needs_zeroed = true; } @@ -1376,7 +1373,7 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo) for (i = 0; i < HIST_C0_ELEMS; i++) { cquantize->histogram[i] = (hist2d) malloc(HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell)); } - cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ + cquantize->needs_zeroed = true; /* histogram is garbage now */ /* Allocate storage for the completed colormap, if required. * We do this now since it is storage and may affect @@ -1465,11 +1462,11 @@ void wxQuantize::DoQuantize(unsigned w, unsigned h, unsigned char **in_rows, uns cquantize = (my_cquantize_ptr) dec.cquantize; - cquantize->pub.start_pass(&dec, TRUE); + cquantize->pub.start_pass(&dec, true); cquantize->pub.color_quantize(&dec, in_rows, out_rows, h); cquantize->pub.finish_pass(&dec); - cquantize->pub.start_pass(&dec, FALSE); + cquantize->pub.start_pass(&dec, false); cquantize->pub.color_quantize(&dec, in_rows, out_rows, h); cquantize->pub.finish_pass(&dec); @@ -1548,7 +1545,7 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, if (flags & wxQUANTIZE_FILL_DESTINATION_IMAGE) { - if (!dest.Ok()) + if (!dest.IsOk()) dest.Create(w, h); imgdt = dest.GetData(); @@ -1569,7 +1566,7 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, // We need to shift the palette entries up // to make room for the Windows system colours. for (i = 0; i < w * h; i++) - data8bit[i] = data8bit[i] + paletteShift; + data8bit[i] = (unsigned char)(data8bit[i] + paletteShift); } #endif *eightBitData = data8bit; @@ -1623,9 +1620,11 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest, delete[] g; delete[] b; } -#endif // wxUSE_PALETTE +#else // !wxUSE_PALETTE + wxUnusedVar(pPalette); +#endif // wxUSE_PALETTE/!wxUSE_PALETTE - return TRUE; + return true; } // This version sets a palette in the destination image so you don't @@ -1639,7 +1638,7 @@ bool wxQuantize::Quantize(const wxImage& src, { wxPalette* palette = NULL; if ( !Quantize(src, dest, & palette, desiredNoColours, eightBitData, flags) ) - return FALSE; + return false; #if wxUSE_PALETTE if (palette) @@ -1649,9 +1648,8 @@ bool wxQuantize::Quantize(const wxImage& src, } #endif // wxUSE_PALETTE - return TRUE; + return true; } #endif // wxUSE_IMAGE -