~cosme/ubuntu/precise/freeimage/freeimage-3.15.1

« back to all changes in this revision

Viewing changes to Source/FreeImage/Conversion4.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-07-20 13:42:15 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100720134215-xt1454zaedv3b604
Tags: 3.13.1-0ubuntu1
* New upstream release. Closes: (LP: #607800)
 - Updated debian/freeimage-get-orig-source script.
 - Removing no longer necessary debian/patches/* and
   the patch system in debian/rules.
 - Updated debian/rules to work with the new Makefiles.
 - Drop from -O3 to -O2 and use lzma compression saves
   ~10 MB of free space. 
* lintian stuff
 - fixed debhelper-but-no-misc-depends
 - fixed ldconfig-symlink-missing-for-shlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
FreeImage_ConvertTo4Bits(FIBITMAP *dib) {
143
143
        if(!dib) return NULL;
144
144
 
145
 
        int bpp = FreeImage_GetBPP(dib);
 
145
        const int bpp = FreeImage_GetBPP(dib);
146
146
 
147
147
        if(bpp != 4) {
148
 
                int width  = FreeImage_GetWidth(dib);
149
 
                int height = FreeImage_GetHeight(dib);
 
148
                const int width  = FreeImage_GetWidth(dib);
 
149
                const int height = FreeImage_GetHeight(dib);
150
150
                FIBITMAP *new_dib = FreeImage_Allocate(width, height, 4);
151
151
 
152
152
                if(new_dib == NULL) {
153
153
                        return NULL;
154
154
                }
155
155
 
 
156
                // copy metadata from src to dst
 
157
                FreeImage_CloneMetadata(new_dib, dib);
 
158
 
156
159
                // Build a greyscale palette (*always* needed for image processing)
157
160
 
158
161
                RGBQUAD *new_pal = FreeImage_GetPalette(new_dib);
186
189
 
187
190
                                // Expand and copy the bitmap data
188
191
 
189
 
                                for (int rows = 0; rows < height; rows++)
 
192
                                for (int rows = 0; rows < height; rows++) {
190
193
                                        FreeImage_ConvertLine1To4(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width);
191
 
                                        
 
194
                                }
192
195
                                return new_dib;
193
196
                        }
194
197
 
196
199
                        {
197
200
                                // Expand and copy the bitmap data
198
201
 
199
 
                                for (int rows = 0; rows < height; rows++)
 
202
                                for (int rows = 0; rows < height; rows++) {
200
203
                                        FreeImage_ConvertLine8To4(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib));
201
 
 
 
204
                                }
202
205
                                return new_dib;
203
206
                        }
204
207
 
221
224
                        {
222
225
                                // Expand and copy the bitmap data
223
226
 
224
 
                                for (int rows = 0; rows < height; rows++)
 
227
                                for (int rows = 0; rows < height; rows++) {
225
228
                                        FreeImage_ConvertLine24To4(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width);                                      
226
 
 
 
229
                                }
227
230
                                return new_dib;
228
231
                        }
229
232
 
231
234
                        {
232
235
                                // Expand and copy the bitmap data
233
236
 
234
 
                                for (int rows = 0; rows < height; rows++)
 
237
                                for (int rows = 0; rows < height; rows++) {
235
238
                                        FreeImage_ConvertLine32To4(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width);
236
 
                                
 
239
                                }
237
240
                                return new_dib;
238
241
                        }
239
242
                }