Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: core/fxge/dib/fx_dib_convert.cpp

Issue 2075383002: Remove some fx_dib functions with unused parameters. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Fix build, fix skia Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxge/agg/fx_agg_driver.cpp ('k') | core/fxge/dib/fx_dib_main.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fxcodec/include/fx_codec.h" 7 #include "core/fxcodec/include/fx_codec.h"
8 #include "core/fxge/include/fx_dib.h" 8 #include "core/fxge/include/fx_dib.h"
9 #include "core/fxge/include/fx_ge.h" 9 #include "core/fxge/include/fx_ge.h"
10 10
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 FXSYS_memcpy(dest_scan, src_scan, width); 167 FXSYS_memcpy(dest_scan, src_scan, width);
168 } 168 }
169 return TRUE; 169 return TRUE;
170 } 170 }
171 FX_BOOL ConvertBuffer_1bppPlt2Gray(uint8_t* dest_buf, 171 FX_BOOL ConvertBuffer_1bppPlt2Gray(uint8_t* dest_buf,
172 int dest_pitch, 172 int dest_pitch,
173 int width, 173 int width,
174 int height, 174 int height,
175 const CFX_DIBSource* pSrcBitmap, 175 const CFX_DIBSource* pSrcBitmap,
176 int src_left, 176 int src_left,
177 int src_top, 177 int src_top) {
178 void* pIccTransform) {
179 uint32_t* src_plt = pSrcBitmap->GetPalette(); 178 uint32_t* src_plt = pSrcBitmap->GetPalette();
180 uint8_t gray[2]; 179 uint8_t gray[2];
181 if (pIccTransform) { 180 uint8_t reset_r;
182 uint32_t plt[2]; 181 uint8_t reset_g;
183 if (pSrcBitmap->IsCmykImage()) { 182 uint8_t reset_b;
184 plt[0] = FXCMYK_TODIB(src_plt[0]); 183 uint8_t set_r;
185 plt[1] = FXCMYK_TODIB(src_plt[1]); 184 uint8_t set_g;
186 } else { 185 uint8_t set_b;
187 uint8_t* bgr_ptr = (uint8_t*)plt; 186 if (pSrcBitmap->IsCmykImage()) {
188 bgr_ptr[0] = FXARGB_B(src_plt[0]); 187 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_plt[0]),
189 bgr_ptr[1] = FXARGB_G(src_plt[0]); 188 FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]),
190 bgr_ptr[2] = FXARGB_R(src_plt[0]); 189 reset_r, reset_g, reset_b);
191 bgr_ptr[3] = FXARGB_B(src_plt[1]); 190 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_plt[1]),
192 bgr_ptr[4] = FXARGB_G(src_plt[1]); 191 FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]),
193 bgr_ptr[5] = FXARGB_R(src_plt[1]); 192 set_r, set_g, set_b);
194 }
195 CCodec_IccModule* pIccModule =
196 CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
197 pIccModule->TranslateScanline(pIccTransform, gray, (const uint8_t*)plt, 2);
198 } else { 193 } else {
199 uint8_t reset_r, reset_g, reset_b, set_r, set_g, set_b; 194 reset_r = FXARGB_R(src_plt[0]);
200 if (pSrcBitmap->IsCmykImage()) { 195 reset_g = FXARGB_G(src_plt[0]);
201 AdobeCMYK_to_sRGB1( 196 reset_b = FXARGB_B(src_plt[0]);
202 FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_plt[0]), 197 set_r = FXARGB_R(src_plt[1]);
203 FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]), reset_r, 198 set_g = FXARGB_G(src_plt[1]);
204 reset_g, reset_b); 199 set_b = FXARGB_B(src_plt[1]);
205 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[1]),
206 FXSYS_GetMValue(src_plt[1]),
207 FXSYS_GetYValue(src_plt[1]),
208 FXSYS_GetKValue(src_plt[1]), set_r, set_g, set_b);
209 } else {
210 reset_r = FXARGB_R(src_plt[0]);
211 reset_g = FXARGB_G(src_plt[0]);
212 reset_b = FXARGB_B(src_plt[0]);
213 set_r = FXARGB_R(src_plt[1]);
214 set_g = FXARGB_G(src_plt[1]);
215 set_b = FXARGB_B(src_plt[1]);
216 }
217 gray[0] = FXRGB2GRAY(reset_r, reset_g, reset_b);
218 gray[1] = FXRGB2GRAY(set_r, set_g, set_b);
219 } 200 }
201 gray[0] = FXRGB2GRAY(reset_r, reset_g, reset_b);
202 gray[1] = FXRGB2GRAY(set_r, set_g, set_b);
203
220 for (int row = 0; row < height; row++) { 204 for (int row = 0; row < height; row++) {
221 uint8_t* dest_scan = dest_buf + row * dest_pitch; 205 uint8_t* dest_scan = dest_buf + row * dest_pitch;
222 FXSYS_memset(dest_scan, gray[0], width); 206 FXSYS_memset(dest_scan, gray[0], width);
223 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); 207 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row);
224 for (int col = src_left; col < src_left + width; col++) { 208 for (int col = src_left; col < src_left + width; col++) {
225 if (src_scan[col / 8] & (1 << (7 - col % 8))) { 209 if (src_scan[col / 8] & (1 << (7 - col % 8))) {
226 *dest_scan = gray[1]; 210 *dest_scan = gray[1];
227 } 211 }
228 dest_scan++; 212 dest_scan++;
229 } 213 }
230 } 214 }
231 return TRUE; 215 return TRUE;
232 } 216 }
217
233 FX_BOOL ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf, 218 FX_BOOL ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf,
234 int dest_pitch, 219 int dest_pitch,
235 int width, 220 int width,
236 int height, 221 int height,
237 const CFX_DIBSource* pSrcBitmap, 222 const CFX_DIBSource* pSrcBitmap,
238 int src_left, 223 int src_left,
239 int src_top, 224 int src_top) {
240 void* pIccTransform) {
241 uint32_t* src_plt = pSrcBitmap->GetPalette(); 225 uint32_t* src_plt = pSrcBitmap->GetPalette();
242 uint8_t gray[256]; 226 uint8_t gray[256];
243 if (pIccTransform) { 227 if (pSrcBitmap->IsCmykImage()) {
244 uint32_t plt[256]; 228 uint8_t r;
245 if (pSrcBitmap->IsCmykImage()) { 229 uint8_t g;
246 for (int i = 0; i < 256; i++) { 230 uint8_t b;
247 plt[i] = FXCMYK_TODIB(src_plt[i]); 231 for (size_t i = 0; i < FX_ArraySize(gray); i++) {
248 } 232 AdobeCMYK_to_sRGB1(
249 } else { 233 FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]),
250 uint8_t* bgr_ptr = (uint8_t*)plt; 234 FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), r, g, b);
251 for (int i = 0; i < 256; i++) { 235 gray[i] = FXRGB2GRAY(r, g, b);
252 *bgr_ptr++ = FXARGB_B(src_plt[i]);
253 *bgr_ptr++ = FXARGB_G(src_plt[i]);
254 *bgr_ptr++ = FXARGB_R(src_plt[i]);
255 }
256 } 236 }
257 CCodec_IccModule* pIccModule =
258 CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
259 pIccModule->TranslateScanline(pIccTransform, gray, (const uint8_t*)plt,
260 256);
261 } else { 237 } else {
262 if (pSrcBitmap->IsCmykImage()) { 238 for (size_t i = 0; i < FX_ArraySize(gray); i++) {
263 uint8_t r, g, b; 239 gray[i] = FXRGB2GRAY(FXARGB_R(src_plt[i]), FXARGB_G(src_plt[i]),
264 for (int i = 0; i < 256; i++) { 240 FXARGB_B(src_plt[i]));
265 AdobeCMYK_to_sRGB1(
266 FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]),
267 FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), r, g, b);
268 gray[i] = FXRGB2GRAY(r, g, b);
269 }
270 } else {
271 for (int i = 0; i < 256; i++) {
272 gray[i] = FXRGB2GRAY(FXARGB_R(src_plt[i]), FXARGB_G(src_plt[i]),
273 FXARGB_B(src_plt[i]));
274 }
275 } 241 }
276 } 242 }
243
277 for (int row = 0; row < height; row++) { 244 for (int row = 0; row < height; row++) {
278 uint8_t* dest_scan = dest_buf + row * dest_pitch; 245 uint8_t* dest_scan = dest_buf + row * dest_pitch;
279 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left; 246 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left;
280 for (int col = 0; col < width; col++) { 247 for (int col = 0; col < width; col++) {
281 *dest_scan++ = gray[*src_scan++]; 248 *dest_scan++ = gray[*src_scan++];
282 } 249 }
283 } 250 }
284 return TRUE; 251 return TRUE;
285 } 252 }
253
286 FX_BOOL ConvertBuffer_RgbOrCmyk2Gray(uint8_t* dest_buf, 254 FX_BOOL ConvertBuffer_RgbOrCmyk2Gray(uint8_t* dest_buf,
287 int dest_pitch, 255 int dest_pitch,
288 int width, 256 int width,
289 int height, 257 int height,
290 const CFX_DIBSource* pSrcBitmap, 258 const CFX_DIBSource* pSrcBitmap,
291 int src_left, 259 int src_left,
292 int src_top, 260 int src_top) {
293 void* pIccTransform) {
294 int Bpp = pSrcBitmap->GetBPP() / 8; 261 int Bpp = pSrcBitmap->GetBPP() / 8;
295 if (pIccTransform) { 262 if (pSrcBitmap->IsCmykImage()) {
296 CCodec_IccModule* pIccModule = 263 for (int row = 0; row < height; row++) {
297 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); 264 uint8_t* dest_scan = dest_buf + row * dest_pitch;
298 if (Bpp == 3 || pSrcBitmap->IsCmykImage()) { 265 const uint8_t* src_scan =
299 for (int row = 0; row < height; row++) { 266 pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
300 uint8_t* dest_scan = dest_buf + row * dest_pitch; 267 for (int col = 0; col < width; col++) {
301 const uint8_t* src_scan = 268 uint8_t r, g, b;
302 pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp; 269 AdobeCMYK_to_sRGB1(FXSYS_GetCValue((uint32_t)src_scan[0]),
303 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, 270 FXSYS_GetMValue((uint32_t)src_scan[1]),
304 width); 271 FXSYS_GetYValue((uint32_t)src_scan[2]),
305 } 272 FXSYS_GetKValue((uint32_t)src_scan[3]), r, g, b);
306 } else { 273 *dest_scan++ = FXRGB2GRAY(r, g, b);
307 for (int row = 0; row < height; row++) { 274 src_scan += 4;
308 uint8_t* dest_scan = dest_buf + row * dest_pitch;
309 const uint8_t* src_scan =
310 pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
311 for (int col = 0; col < width; col++) {
312 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, 1);
313 dest_scan++;
314 src_scan += 4;
315 }
316 } 275 }
317 } 276 }
318 } else { 277 } else {
319 if (pSrcBitmap->IsCmykImage()) { 278 for (int row = 0; row < height; row++) {
320 for (int row = 0; row < height; row++) { 279 uint8_t* dest_scan = dest_buf + row * dest_pitch;
321 uint8_t* dest_scan = dest_buf + row * dest_pitch; 280 const uint8_t* src_scan =
322 const uint8_t* src_scan = 281 pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
323 pSrcBitmap->GetScanline(src_top + row) + src_left * 4; 282 for (int col = 0; col < width; col++) {
324 for (int col = 0; col < width; col++) { 283 *dest_scan++ = FXRGB2GRAY(src_scan[2], src_scan[1], src_scan[0]);
325 uint8_t r, g, b; 284 src_scan += Bpp;
326 AdobeCMYK_to_sRGB1(FXSYS_GetCValue((uint32_t)src_scan[0]),
327 FXSYS_GetMValue((uint32_t)src_scan[1]),
328 FXSYS_GetYValue((uint32_t)src_scan[2]),
329 FXSYS_GetKValue((uint32_t)src_scan[3]), r, g, b);
330 *dest_scan++ = FXRGB2GRAY(r, g, b);
331 src_scan += 4;
332 }
333 }
334 } else {
335 for (int row = 0; row < height; row++) {
336 uint8_t* dest_scan = dest_buf + row * dest_pitch;
337 const uint8_t* src_scan =
338 pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
339 for (int col = 0; col < width; col++) {
340 *dest_scan++ = FXRGB2GRAY(src_scan[2], src_scan[1], src_scan[0]);
341 src_scan += Bpp;
342 }
343 } 285 }
344 } 286 }
345 } 287 }
346 return TRUE; 288 return TRUE;
347 } 289 }
348 inline void ConvertBuffer_IndexCopy(uint8_t* dest_buf, 290
349 int dest_pitch, 291 void ConvertBuffer_IndexCopy(uint8_t* dest_buf,
350 int width, 292 int dest_pitch,
351 int height, 293 int width,
352 const CFX_DIBSource* pSrcBitmap, 294 int height,
353 int src_left, 295 const CFX_DIBSource* pSrcBitmap,
354 int src_top) { 296 int src_left,
297 int src_top) {
355 if (pSrcBitmap->GetBPP() == 1) { 298 if (pSrcBitmap->GetBPP() == 1) {
356 for (int row = 0; row < height; row++) { 299 for (int row = 0; row < height; row++) {
357 uint8_t* dest_scan = dest_buf + row * dest_pitch; 300 uint8_t* dest_scan = dest_buf + row * dest_pitch;
358 FXSYS_memset(dest_scan, 0, width); 301 FXSYS_memset(dest_scan, 0, width);
359 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); 302 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row);
360 for (int col = src_left; col < src_left + width; col++) { 303 for (int col = src_left; col < src_left + width; col++) {
361 if (src_scan[col / 8] & (1 << (7 - col % 8))) { 304 if (src_scan[col / 8] & (1 << (7 - col % 8))) {
362 *dest_scan = 1; 305 *dest_scan = 1;
363 } 306 }
364 dest_scan++; 307 dest_scan++;
365 } 308 }
366 } 309 }
367 } else { 310 } else {
368 for (int row = 0; row < height; row++) { 311 for (int row = 0; row < height; row++) {
369 uint8_t* dest_scan = dest_buf + row * dest_pitch; 312 uint8_t* dest_scan = dest_buf + row * dest_pitch;
370 const uint8_t* src_scan = 313 const uint8_t* src_scan =
371 pSrcBitmap->GetScanline(src_top + row) + src_left; 314 pSrcBitmap->GetScanline(src_top + row) + src_left;
372 FXSYS_memcpy(dest_scan, src_scan, width); 315 FXSYS_memcpy(dest_scan, src_scan, width);
373 } 316 }
374 } 317 }
375 } 318 }
319
376 FX_BOOL ConvertBuffer_Plt2PltRgb8(uint8_t* dest_buf, 320 FX_BOOL ConvertBuffer_Plt2PltRgb8(uint8_t* dest_buf,
377 int dest_pitch, 321 int dest_pitch,
378 int width, 322 int width,
379 int height, 323 int height,
380 const CFX_DIBSource* pSrcBitmap, 324 const CFX_DIBSource* pSrcBitmap,
381 int src_left, 325 int src_left,
382 int src_top, 326 int src_top,
383 uint32_t* dst_plt, 327 uint32_t* dst_plt) {
384 void* pIccTransform) {
385 ConvertBuffer_IndexCopy(dest_buf, dest_pitch, width, height, pSrcBitmap, 328 ConvertBuffer_IndexCopy(dest_buf, dest_pitch, width, height, pSrcBitmap,
386 src_left, src_top); 329 src_left, src_top);
387 uint32_t* src_plt = pSrcBitmap->GetPalette(); 330 uint32_t* src_plt = pSrcBitmap->GetPalette();
388 int plt_size = pSrcBitmap->GetPaletteSize(); 331 int plt_size = pSrcBitmap->GetPaletteSize();
389 if (pIccTransform) { 332 if (pSrcBitmap->IsCmykImage()) {
390 uint32_t plt[256];
391 uint8_t* bgr_ptr = (uint8_t*)plt;
392 if (pSrcBitmap->IsCmykImage()) {
393 for (int i = 0; i < plt_size; i++) {
394 plt[i] = FXCMYK_TODIB(src_plt[i]);
395 }
396 } else {
397 for (int i = 0; i < plt_size; i++) {
398 *bgr_ptr++ = FXARGB_B(src_plt[i]);
399 *bgr_ptr++ = FXARGB_G(src_plt[i]);
400 *bgr_ptr++ = FXARGB_R(src_plt[i]);
401 }
402 bgr_ptr = (uint8_t*)plt;
403 }
404 CCodec_IccModule* pIccModule =
405 CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
406 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt,
407 (const uint8_t*)plt, plt_size);
408 for (int i = 0; i < plt_size; i++) { 333 for (int i = 0; i < plt_size; i++) {
409 dst_plt[i] = FXARGB_MAKE(0xff, bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]); 334 uint8_t r;
410 bgr_ptr += 3; 335 uint8_t g;
336 uint8_t b;
337 AdobeCMYK_to_sRGB1(
338 FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]),
339 FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), r, g, b);
340 dst_plt[i] = FXARGB_MAKE(0xff, r, g, b);
411 } 341 }
412 } else { 342 } else {
413 if (pSrcBitmap->IsCmykImage()) { 343 FXSYS_memcpy(dst_plt, src_plt, plt_size * 4);
414 for (int i = 0; i < plt_size; i++) {
415 uint8_t r, g, b;
416 AdobeCMYK_to_sRGB1(
417 FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]),
418 FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), r, g, b);
419 dst_plt[i] = FXARGB_MAKE(0xff, r, g, b);
420 }
421 } else {
422 FXSYS_memcpy(dst_plt, src_plt, plt_size * 4);
423 }
424 } 344 }
425 return TRUE; 345 return TRUE;
426 } 346 }
427 FX_BOOL ConvertBuffer_Rgb2PltRgb8_NoTransform(uint8_t* dest_buf, 347
428 int dest_pitch, 348 FX_BOOL ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf,
429 int width, 349 int dest_pitch,
430 int height, 350 int width,
431 const CFX_DIBSource* pSrcBitmap, 351 int height,
432 int src_left, 352 const CFX_DIBSource* pSrcBitmap,
433 int src_top, 353 int src_left,
434 uint32_t* dst_plt) { 354 int src_top,
355 uint32_t* dst_plt) {
435 int bpp = pSrcBitmap->GetBPP() / 8; 356 int bpp = pSrcBitmap->GetBPP() / 8;
436 CFX_Palette palette; 357 CFX_Palette palette;
437 palette.BuildPalette(pSrcBitmap); 358 palette.BuildPalette(pSrcBitmap);
438 uint32_t* cLut = palette.GetColorLut(); 359 uint32_t* cLut = palette.GetColorLut();
439 uint32_t* aLut = palette.GetAmountLut(); 360 uint32_t* aLut = palette.GetAmountLut();
440 if (!cLut || !aLut) { 361 if (!cLut || !aLut) {
441 return FALSE; 362 return FALSE;
442 } 363 }
443 int lut = palette.Getlut(); 364 int lut = palette.Getlut();
444 uint32_t* pPalette = palette.GetPalette(); 365 uint32_t* pPalette = palette.GetPalette();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 for (int i = lut_1; i >= 0; i--) 399 for (int i = lut_1; i >= 0; i--)
479 if (clrindex == cLut[i]) { 400 if (clrindex == cLut[i]) {
480 *(dest_scan + col) = (uint8_t)(aLut[i]); 401 *(dest_scan + col) = (uint8_t)(aLut[i]);
481 break; 402 break;
482 } 403 }
483 } 404 }
484 } 405 }
485 FXSYS_memcpy(dst_plt, pPalette, sizeof(uint32_t) * 256); 406 FXSYS_memcpy(dst_plt, pPalette, sizeof(uint32_t) * 256);
486 return TRUE; 407 return TRUE;
487 } 408 }
488 FX_BOOL ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf, 409
489 int dest_pitch,
490 int width,
491 int height,
492 const CFX_DIBSource* pSrcBitmap,
493 int src_left,
494 int src_top,
495 uint32_t* dst_plt,
496 void* pIccTransform) {
497 FX_BOOL ret = ConvertBuffer_Rgb2PltRgb8_NoTransform(
498 dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top,
499 dst_plt);
500 if (ret && pIccTransform) {
501 CCodec_IccModule* pIccModule =
502 CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
503 for (int i = 0; i < 256; i++) {
504 FX_ARGB* plt = dst_plt + i;
505 FX_ARGB plt_entry = FXARGB_TODIB(*plt);
506 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&plt_entry,
507 (const uint8_t*)&plt_entry, 1);
508 *plt = FXARGB_TODIB(plt_entry);
509 }
510 }
511 return ret;
512 }
513 FX_BOOL ConvertBuffer_1bppMask2Rgb(FXDIB_Format dst_format, 410 FX_BOOL ConvertBuffer_1bppMask2Rgb(FXDIB_Format dst_format,
514 uint8_t* dest_buf, 411 uint8_t* dest_buf,
515 int dest_pitch, 412 int dest_pitch,
516 int width, 413 int width,
517 int height, 414 int height,
518 const CFX_DIBSource* pSrcBitmap, 415 const CFX_DIBSource* pSrcBitmap,
519 int src_left, 416 int src_left,
520 int src_top) { 417 int src_top) {
521 int comps = (dst_format & 0xff) / 8; 418 int comps = (dst_format & 0xff) / 8;
522 uint8_t set_gray, reset_gray; 419 uint8_t set_gray, reset_gray;
(...skipping 10 matching lines...) Expand all
533 } else { 430 } else {
534 dest_scan[0] = reset_gray; 431 dest_scan[0] = reset_gray;
535 dest_scan[1] = reset_gray; 432 dest_scan[1] = reset_gray;
536 dest_scan[2] = reset_gray; 433 dest_scan[2] = reset_gray;
537 } 434 }
538 dest_scan += comps; 435 dest_scan += comps;
539 } 436 }
540 } 437 }
541 return TRUE; 438 return TRUE;
542 } 439 }
440
543 FX_BOOL ConvertBuffer_8bppMask2Rgb(FXDIB_Format dst_format, 441 FX_BOOL ConvertBuffer_8bppMask2Rgb(FXDIB_Format dst_format,
544 uint8_t* dest_buf, 442 uint8_t* dest_buf,
545 int dest_pitch, 443 int dest_pitch,
546 int width, 444 int width,
547 int height, 445 int height,
548 const CFX_DIBSource* pSrcBitmap, 446 const CFX_DIBSource* pSrcBitmap,
549 int src_left, 447 int src_left,
550 int src_top) { 448 int src_top) {
551 int comps = (dst_format & 0xff) / 8; 449 int comps = (dst_format & 0xff) / 8;
552 for (int row = 0; row < height; row++) { 450 for (int row = 0; row < height; row++) {
553 uint8_t* dest_scan = dest_buf + row * dest_pitch; 451 uint8_t* dest_scan = dest_buf + row * dest_pitch;
554 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left; 452 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left;
555 uint8_t src_pixel; 453 uint8_t src_pixel;
556 for (int col = 0; col < width; col++) { 454 for (int col = 0; col < width; col++) {
557 src_pixel = *src_scan++; 455 src_pixel = *src_scan++;
558 *dest_scan++ = src_pixel; 456 *dest_scan++ = src_pixel;
559 *dest_scan++ = src_pixel; 457 *dest_scan++ = src_pixel;
560 *dest_scan = src_pixel; 458 *dest_scan = src_pixel;
561 dest_scan += comps - 2; 459 dest_scan += comps - 2;
562 } 460 }
563 } 461 }
564 return TRUE; 462 return TRUE;
565 } 463 }
464
566 FX_BOOL ConvertBuffer_1bppPlt2Rgb(FXDIB_Format dst_format, 465 FX_BOOL ConvertBuffer_1bppPlt2Rgb(FXDIB_Format dst_format,
567 uint8_t* dest_buf, 466 uint8_t* dest_buf,
568 int dest_pitch, 467 int dest_pitch,
569 int width, 468 int width,
570 int height, 469 int height,
571 const CFX_DIBSource* pSrcBitmap, 470 const CFX_DIBSource* pSrcBitmap,
572 int src_left, 471 int src_left,
573 int src_top, 472 int src_top) {
574 void* pIccTransform) {
575 int comps = (dst_format & 0xff) / 8; 473 int comps = (dst_format & 0xff) / 8;
576 uint32_t* src_plt = pSrcBitmap->GetPalette(); 474 uint32_t* src_plt = pSrcBitmap->GetPalette();
577 uint32_t plt[2]; 475 uint32_t plt[2];
578 uint8_t* bgr_ptr = (uint8_t*)plt; 476 uint8_t* bgr_ptr = (uint8_t*)plt;
579 if (pSrcBitmap->IsCmykImage()) { 477 if (pSrcBitmap->IsCmykImage()) {
580 plt[0] = FXCMYK_TODIB(src_plt[0]); 478 plt[0] = FXCMYK_TODIB(src_plt[0]);
581 plt[1] = FXCMYK_TODIB(src_plt[1]); 479 plt[1] = FXCMYK_TODIB(src_plt[1]);
582 } else { 480 } else {
583 bgr_ptr[0] = FXARGB_B(src_plt[0]); 481 bgr_ptr[0] = FXARGB_B(src_plt[0]);
584 bgr_ptr[1] = FXARGB_G(src_plt[0]); 482 bgr_ptr[1] = FXARGB_G(src_plt[0]);
585 bgr_ptr[2] = FXARGB_R(src_plt[0]); 483 bgr_ptr[2] = FXARGB_R(src_plt[0]);
586 bgr_ptr[3] = FXARGB_B(src_plt[1]); 484 bgr_ptr[3] = FXARGB_B(src_plt[1]);
587 bgr_ptr[4] = FXARGB_G(src_plt[1]); 485 bgr_ptr[4] = FXARGB_G(src_plt[1]);
588 bgr_ptr[5] = FXARGB_R(src_plt[1]); 486 bgr_ptr[5] = FXARGB_R(src_plt[1]);
589 } 487 }
590 if (pIccTransform) { 488
591 CCodec_IccModule* pIccModule = 489 if (pSrcBitmap->IsCmykImage()) {
592 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); 490 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_plt[0]),
593 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt, 491 FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]),
594 (const uint8_t*)plt, 2); 492 bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]);
595 } else { 493 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_plt[1]),
596 if (pSrcBitmap->IsCmykImage()) { 494 FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]),
597 AdobeCMYK_to_sRGB1( 495 bgr_ptr[5], bgr_ptr[4], bgr_ptr[3]);
598 FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_plt[0]),
599 FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]), bgr_ptr[2],
600 bgr_ptr[1], bgr_ptr[0]);
601 AdobeCMYK_to_sRGB1(
602 FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_plt[1]),
603 FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]), bgr_ptr[5],
604 bgr_ptr[4], bgr_ptr[3]);
605 }
606 } 496 }
497
607 for (int row = 0; row < height; row++) { 498 for (int row = 0; row < height; row++) {
608 uint8_t* dest_scan = dest_buf + row * dest_pitch; 499 uint8_t* dest_scan = dest_buf + row * dest_pitch;
609 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); 500 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row);
610 for (int col = src_left; col < src_left + width; col++) { 501 for (int col = src_left; col < src_left + width; col++) {
611 if (src_scan[col / 8] & (1 << (7 - col % 8))) { 502 if (src_scan[col / 8] & (1 << (7 - col % 8))) {
612 *dest_scan++ = bgr_ptr[3]; 503 *dest_scan++ = bgr_ptr[3];
613 *dest_scan++ = bgr_ptr[4]; 504 *dest_scan++ = bgr_ptr[4];
614 *dest_scan = bgr_ptr[5]; 505 *dest_scan = bgr_ptr[5];
615 } else { 506 } else {
616 *dest_scan++ = bgr_ptr[0]; 507 *dest_scan++ = bgr_ptr[0];
617 *dest_scan++ = bgr_ptr[1]; 508 *dest_scan++ = bgr_ptr[1];
618 *dest_scan = bgr_ptr[2]; 509 *dest_scan = bgr_ptr[2];
619 } 510 }
620 dest_scan += comps - 2; 511 dest_scan += comps - 2;
621 } 512 }
622 } 513 }
623 return TRUE; 514 return TRUE;
624 } 515 }
516
625 FX_BOOL ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format, 517 FX_BOOL ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format,
626 uint8_t* dest_buf, 518 uint8_t* dest_buf,
627 int dest_pitch, 519 int dest_pitch,
628 int width, 520 int width,
629 int height, 521 int height,
630 const CFX_DIBSource* pSrcBitmap, 522 const CFX_DIBSource* pSrcBitmap,
631 int src_left, 523 int src_left,
632 int src_top, 524 int src_top) {
633 void* pIccTransform) {
634 int comps = (dst_format & 0xff) / 8; 525 int comps = (dst_format & 0xff) / 8;
635 uint32_t* src_plt = pSrcBitmap->GetPalette(); 526 uint32_t* src_plt = pSrcBitmap->GetPalette();
636 uint32_t plt[256]; 527 uint32_t plt[256];
637 uint8_t* bgr_ptr = (uint8_t*)plt; 528 uint8_t* bgr_ptr = (uint8_t*)plt;
638 if (!pSrcBitmap->IsCmykImage()) { 529 if (!pSrcBitmap->IsCmykImage()) {
639 for (int i = 0; i < 256; i++) { 530 for (int i = 0; i < 256; i++) {
640 *bgr_ptr++ = FXARGB_B(src_plt[i]); 531 *bgr_ptr++ = FXARGB_B(src_plt[i]);
641 *bgr_ptr++ = FXARGB_G(src_plt[i]); 532 *bgr_ptr++ = FXARGB_G(src_plt[i]);
642 *bgr_ptr++ = FXARGB_R(src_plt[i]); 533 *bgr_ptr++ = FXARGB_R(src_plt[i]);
643 } 534 }
644 bgr_ptr = (uint8_t*)plt; 535 bgr_ptr = (uint8_t*)plt;
645 } 536 }
646 if (pIccTransform) { 537
647 if (pSrcBitmap->IsCmykImage()) { 538 if (pSrcBitmap->IsCmykImage()) {
648 for (int i = 0; i < 256; i++) { 539 for (int i = 0; i < 256; i++) {
649 plt[i] = FXCMYK_TODIB(src_plt[i]); 540 AdobeCMYK_to_sRGB1(
650 } 541 FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]),
542 FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), bgr_ptr[2],
543 bgr_ptr[1], bgr_ptr[0]);
544 bgr_ptr += 3;
651 } 545 }
652 CCodec_IccModule* pIccModule = 546 bgr_ptr = (uint8_t*)plt;
653 CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
654 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt,
655 (const uint8_t*)plt, 256);
656 } else {
657 if (pSrcBitmap->IsCmykImage()) {
658 for (int i = 0; i < 256; i++) {
659 AdobeCMYK_to_sRGB1(
660 FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]),
661 FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]),
662 bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]);
663 bgr_ptr += 3;
664 }
665 bgr_ptr = (uint8_t*)plt;
666 }
667 } 547 }
548
668 for (int row = 0; row < height; row++) { 549 for (int row = 0; row < height; row++) {
669 uint8_t* dest_scan = dest_buf + row * dest_pitch; 550 uint8_t* dest_scan = dest_buf + row * dest_pitch;
670 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left; 551 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left;
671 for (int col = 0; col < width; col++) { 552 for (int col = 0; col < width; col++) {
672 uint8_t* src_pixel = bgr_ptr + 3 * (*src_scan++); 553 uint8_t* src_pixel = bgr_ptr + 3 * (*src_scan++);
673 *dest_scan++ = *src_pixel++; 554 *dest_scan++ = *src_pixel++;
674 *dest_scan++ = *src_pixel++; 555 *dest_scan++ = *src_pixel++;
675 *dest_scan = *src_pixel++; 556 *dest_scan = *src_pixel++;
676 dest_scan += comps - 2; 557 dest_scan += comps - 2;
677 } 558 }
678 } 559 }
679 return TRUE; 560 return TRUE;
680 } 561 }
562
681 FX_BOOL ConvertBuffer_24bppRgb2Rgb24(uint8_t* dest_buf, 563 FX_BOOL ConvertBuffer_24bppRgb2Rgb24(uint8_t* dest_buf,
682 int dest_pitch, 564 int dest_pitch,
683 int width, 565 int width,
684 int height, 566 int height,
685 const CFX_DIBSource* pSrcBitmap, 567 const CFX_DIBSource* pSrcBitmap,
686 int src_left, 568 int src_left,
687 int src_top, 569 int src_top) {
688 void* pIccTransform) { 570 for (int row = 0; row < height; row++) {
689 if (pIccTransform) { 571 uint8_t* dest_scan = dest_buf + row * dest_pitch;
690 CCodec_IccModule* pIccModule = 572 const uint8_t* src_scan =
691 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); 573 pSrcBitmap->GetScanline(src_top + row) + src_left * 3;
692 for (int row = 0; row < height; row++) { 574 FXSYS_memcpy(dest_scan, src_scan, width * 3);
693 uint8_t* dest_scan = dest_buf + row * dest_pitch;
694 const uint8_t* src_scan =
695 pSrcBitmap->GetScanline(src_top + row) + src_left * 3;
696 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, width);
697 }
698 } else {
699 for (int row = 0; row < height; row++) {
700 uint8_t* dest_scan = dest_buf + row * dest_pitch;
701 const uint8_t* src_scan =
702 pSrcBitmap->GetScanline(src_top + row) + src_left * 3;
703 FXSYS_memcpy(dest_scan, src_scan, width * 3);
704 }
705 } 575 }
706 return TRUE; 576 return TRUE;
707 } 577 }
578
708 FX_BOOL ConvertBuffer_32bppRgb2Rgb24(uint8_t* dest_buf, 579 FX_BOOL ConvertBuffer_32bppRgb2Rgb24(uint8_t* dest_buf,
709 int dest_pitch, 580 int dest_pitch,
710 int width, 581 int width,
711 int height, 582 int height,
712 const CFX_DIBSource* pSrcBitmap, 583 const CFX_DIBSource* pSrcBitmap,
713 int src_left, 584 int src_left,
714 int src_top, 585 int src_top) {
715 void* pIccTransform) {
716 for (int row = 0; row < height; row++) { 586 for (int row = 0; row < height; row++) {
717 uint8_t* dest_scan = dest_buf + row * dest_pitch; 587 uint8_t* dest_scan = dest_buf + row * dest_pitch;
718 const uint8_t* src_scan = 588 const uint8_t* src_scan =
719 pSrcBitmap->GetScanline(src_top + row) + src_left * 4; 589 pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
720 for (int col = 0; col < width; col++) { 590 for (int col = 0; col < width; col++) {
721 *dest_scan++ = *src_scan++; 591 *dest_scan++ = *src_scan++;
722 *dest_scan++ = *src_scan++; 592 *dest_scan++ = *src_scan++;
723 *dest_scan++ = *src_scan++; 593 *dest_scan++ = *src_scan++;
724 src_scan++; 594 src_scan++;
725 } 595 }
726 } 596 }
727 if (pIccTransform) {
728 CCodec_IccModule* pIccModule =
729 CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
730 for (int row = 0; row < height; row++) {
731 uint8_t* dest_scan = dest_buf + row * dest_pitch;
732 pIccModule->TranslateScanline(pIccTransform, dest_scan, dest_scan, width);
733 }
734 }
735 return TRUE; 597 return TRUE;
736 } 598 }
599
737 FX_BOOL ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf, 600 FX_BOOL ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf,
738 int dest_pitch, 601 int dest_pitch,
739 int width, 602 int width,
740 int height, 603 int height,
741 const CFX_DIBSource* pSrcBitmap, 604 const CFX_DIBSource* pSrcBitmap,
742 int src_left, 605 int src_left,
743 int src_top, 606 int src_top) {
744 void* pIccTransform) {
745 int comps = pSrcBitmap->GetBPP() / 8; 607 int comps = pSrcBitmap->GetBPP() / 8;
746 if (pIccTransform) { 608 for (int row = 0; row < height; row++) {
747 CCodec_IccModule* pIccModule = 609 uint8_t* dest_scan = dest_buf + row * dest_pitch;
748 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); 610 const uint8_t* src_scan =
749 for (int row = 0; row < height; row++) { 611 pSrcBitmap->GetScanline(src_top + row) + src_left * comps;
750 uint8_t* dest_scan = dest_buf + row * dest_pitch; 612 for (int col = 0; col < width; col++) {
751 const uint8_t* src_scan = 613 *dest_scan++ = *src_scan++;
752 pSrcBitmap->GetScanline(src_top + row) + src_left * comps; 614 *dest_scan++ = *src_scan++;
753 for (int col = 0; col < width; col++) { 615 *dest_scan++ = *src_scan++;
754 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, 1); 616 dest_scan++;
755 dest_scan += 4; 617 src_scan += comps - 3;
756 src_scan += comps;
757 }
758 }
759 } else {
760 for (int row = 0; row < height; row++) {
761 uint8_t* dest_scan = dest_buf + row * dest_pitch;
762 const uint8_t* src_scan =
763 pSrcBitmap->GetScanline(src_top + row) + src_left * comps;
764 for (int col = 0; col < width; col++) {
765 *dest_scan++ = *src_scan++;
766 *dest_scan++ = *src_scan++;
767 *dest_scan++ = *src_scan++;
768 dest_scan++;
769 src_scan += comps - 3;
770 }
771 } 618 }
772 } 619 }
773 return TRUE; 620 return TRUE;
774 } 621 }
622
775 FX_BOOL ConvertBuffer_32bppCmyk2Rgb32(uint8_t* dest_buf, 623 FX_BOOL ConvertBuffer_32bppCmyk2Rgb32(uint8_t* dest_buf,
776 int dest_pitch, 624 int dest_pitch,
777 int width, 625 int width,
778 int height, 626 int height,
779 const CFX_DIBSource* pSrcBitmap, 627 const CFX_DIBSource* pSrcBitmap,
780 int src_left, 628 int src_left,
781 int src_top, 629 int src_top) {
782 void* pIccTransform) { 630 for (int row = 0; row < height; row++) {
783 if (pIccTransform) { 631 uint8_t* dest_scan = dest_buf + row * dest_pitch;
784 CCodec_IccModule* pIccModule = 632 const uint8_t* src_scan =
785 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); 633 pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
786 for (int row = 0; row < height; row++) { 634 for (int col = 0; col < width; col++) {
787 uint8_t* dest_scan = dest_buf + row * dest_pitch; 635 AdobeCMYK_to_sRGB1(src_scan[0], src_scan[1], src_scan[2], src_scan[3],
788 const uint8_t* src_scan = 636 dest_scan[2], dest_scan[1], dest_scan[0]);
789 pSrcBitmap->GetScanline(src_top + row) + src_left * 4; 637 dest_scan += 4;
790 for (int col = 0; col < width; col++) { 638 src_scan += 4;
791 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, 1);
792 dest_scan += 4;
793 src_scan += 4;
794 }
795 }
796 } else {
797 for (int row = 0; row < height; row++) {
798 uint8_t* dest_scan = dest_buf + row * dest_pitch;
799 const uint8_t* src_scan =
800 pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
801 for (int col = 0; col < width; col++) {
802 AdobeCMYK_to_sRGB1(src_scan[0], src_scan[1], src_scan[2], src_scan[3],
803 dest_scan[2], dest_scan[1], dest_scan[0]);
804 dest_scan += 4;
805 src_scan += 4;
806 }
807 } 639 }
808 } 640 }
809 return TRUE; 641 return TRUE;
810 } 642 }
643
811 FX_BOOL ConvertBuffer(FXDIB_Format dest_format, 644 FX_BOOL ConvertBuffer(FXDIB_Format dest_format,
812 uint8_t* dest_buf, 645 uint8_t* dest_buf,
813 int dest_pitch, 646 int dest_pitch,
814 int width, 647 int width,
815 int height, 648 int height,
816 const CFX_DIBSource* pSrcBitmap, 649 const CFX_DIBSource* pSrcBitmap,
817 int src_left, 650 int src_left,
818 int src_top, 651 int src_top,
819 uint32_t*& d_pal, 652 uint32_t*& d_pal) {
820 void* pIccTransform) {
821 FXDIB_Format src_format = pSrcBitmap->GetFormat(); 653 FXDIB_Format src_format = pSrcBitmap->GetFormat();
822 if (!CFX_GEModule::Get()->GetCodecModule() ||
823 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
824 pIccTransform = nullptr;
825 }
826 switch (dest_format) { 654 switch (dest_format) {
827 case FXDIB_Invalid: 655 case FXDIB_Invalid:
828 case FXDIB_1bppCmyk: 656 case FXDIB_1bppCmyk:
829 case FXDIB_1bppMask: 657 case FXDIB_1bppMask:
830 case FXDIB_1bppRgb: 658 case FXDIB_1bppRgb:
831 ASSERT(FALSE); 659 ASSERT(FALSE);
832 return FALSE; 660 return FALSE;
833 case FXDIB_8bppMask: { 661 case FXDIB_8bppMask: {
834 if ((src_format & 0xff) == 1) { 662 if ((src_format & 0xff) == 1) {
835 if (pSrcBitmap->GetPalette()) { 663 if (pSrcBitmap->GetPalette()) {
836 return ConvertBuffer_1bppPlt2Gray(dest_buf, dest_pitch, width, height, 664 return ConvertBuffer_1bppPlt2Gray(dest_buf, dest_pitch, width, height,
837 pSrcBitmap, src_left, src_top, 665 pSrcBitmap, src_left, src_top);
838 pIccTransform);
839 } 666 }
840 return ConvertBuffer_1bppMask2Gray(dest_buf, dest_pitch, width, height, 667 return ConvertBuffer_1bppMask2Gray(dest_buf, dest_pitch, width, height,
841 pSrcBitmap, src_left, src_top); 668 pSrcBitmap, src_left, src_top);
842 } 669 }
843 if ((src_format & 0xff) == 8) { 670 if ((src_format & 0xff) == 8) {
844 if (pSrcBitmap->GetPalette()) { 671 if (pSrcBitmap->GetPalette()) {
845 return ConvertBuffer_8bppPlt2Gray(dest_buf, dest_pitch, width, height, 672 return ConvertBuffer_8bppPlt2Gray(dest_buf, dest_pitch, width, height,
846 pSrcBitmap, src_left, src_top, 673 pSrcBitmap, src_left, src_top);
847 pIccTransform);
848 } 674 }
849 return ConvertBuffer_8bppMask2Gray(dest_buf, dest_pitch, width, height, 675 return ConvertBuffer_8bppMask2Gray(dest_buf, dest_pitch, width, height,
850 pSrcBitmap, src_left, src_top); 676 pSrcBitmap, src_left, src_top);
851 } 677 }
852 if ((src_format & 0xff) >= 24) { 678 if ((src_format & 0xff) >= 24) {
853 return ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, width, height, 679 return ConvertBuffer_RgbOrCmyk2Gray(dest_buf, dest_pitch, width, height,
854 pSrcBitmap, src_left, src_top, 680 pSrcBitmap, src_left, src_top);
855 pIccTransform);
856 } 681 }
857 return FALSE; 682 return FALSE;
858 } 683 }
859 case FXDIB_8bppRgb: 684 case FXDIB_8bppRgb:
860 case FXDIB_8bppRgba: { 685 case FXDIB_8bppRgba: {
861 if ((src_format & 0xff) == 8 && !pSrcBitmap->GetPalette()) { 686 if ((src_format & 0xff) == 8 && !pSrcBitmap->GetPalette()) {
862 return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, width, 687 return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, width,
863 height, pSrcBitmap, src_left, src_top, d_pal, 688 height, pSrcBitmap, src_left, src_top, d_pal);
864 pIccTransform);
865 } 689 }
866 d_pal = FX_Alloc(uint32_t, 256); 690 d_pal = FX_Alloc(uint32_t, 256);
867 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && 691 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) &&
868 pSrcBitmap->GetPalette()) { 692 pSrcBitmap->GetPalette()) {
869 return ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, width, height, 693 return ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, width, height,
870 pSrcBitmap, src_left, src_top, d_pal, 694 pSrcBitmap, src_left, src_top, d_pal);
871 pIccTransform);
872 } 695 }
873 if ((src_format & 0xff) >= 24) { 696 if ((src_format & 0xff) >= 24) {
874 return ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, width, height, 697 return ConvertBuffer_Rgb2PltRgb8(dest_buf, dest_pitch, width, height,
875 pSrcBitmap, src_left, src_top, d_pal, 698 pSrcBitmap, src_left, src_top, d_pal);
876 pIccTransform);
877 } 699 }
878 return FALSE; 700 return FALSE;
879 } 701 }
880 case FXDIB_Rgb: 702 case FXDIB_Rgb:
881 case FXDIB_Rgba: { 703 case FXDIB_Rgba: {
882 if ((src_format & 0xff) == 1) { 704 if ((src_format & 0xff) == 1) {
883 if (pSrcBitmap->GetPalette()) { 705 if (pSrcBitmap->GetPalette()) {
884 return ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch, 706 return ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch,
885 width, height, pSrcBitmap, src_left, 707 width, height, pSrcBitmap, src_left,
886 src_top, pIccTransform); 708 src_top);
887 } 709 }
888 return ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, dest_pitch, 710 return ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, dest_pitch,
889 width, height, pSrcBitmap, src_left, 711 width, height, pSrcBitmap, src_left,
890 src_top); 712 src_top);
891 } 713 }
892 if ((src_format & 0xff) == 8) { 714 if ((src_format & 0xff) == 8) {
893 if (pSrcBitmap->GetPalette()) { 715 if (pSrcBitmap->GetPalette()) {
894 return ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, 716 return ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch,
895 width, height, pSrcBitmap, src_left, 717 width, height, pSrcBitmap, src_left,
896 src_top, pIccTransform); 718 src_top);
897 } 719 }
898 return ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, dest_pitch, 720 return ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, dest_pitch,
899 width, height, pSrcBitmap, src_left, 721 width, height, pSrcBitmap, src_left,
900 src_top); 722 src_top);
901 } 723 }
902 if ((src_format & 0xff) == 24) { 724 if ((src_format & 0xff) == 24) {
903 return ConvertBuffer_24bppRgb2Rgb24(dest_buf, dest_pitch, width, height, 725 return ConvertBuffer_24bppRgb2Rgb24(dest_buf, dest_pitch, width, height,
904 pSrcBitmap, src_left, src_top, 726 pSrcBitmap, src_left, src_top);
905 pIccTransform);
906 } 727 }
907 if ((src_format & 0xff) == 32) { 728 if ((src_format & 0xff) == 32) {
908 return ConvertBuffer_32bppRgb2Rgb24(dest_buf, dest_pitch, width, height, 729 return ConvertBuffer_32bppRgb2Rgb24(dest_buf, dest_pitch, width, height,
909 pSrcBitmap, src_left, src_top, 730 pSrcBitmap, src_left, src_top);
910 pIccTransform);
911 } 731 }
912 return FALSE; 732 return FALSE;
913 } 733 }
914 case FXDIB_Argb: 734 case FXDIB_Argb:
915 case FXDIB_Rgb32: { 735 case FXDIB_Rgb32: {
916 if ((src_format & 0xff) == 1) { 736 if ((src_format & 0xff) == 1) {
917 if (pSrcBitmap->GetPalette()) { 737 if (pSrcBitmap->GetPalette()) {
918 return ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch, 738 return ConvertBuffer_1bppPlt2Rgb(dest_format, dest_buf, dest_pitch,
919 width, height, pSrcBitmap, src_left, 739 width, height, pSrcBitmap, src_left,
920 src_top, pIccTransform); 740 src_top);
921 } 741 }
922 return ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, dest_pitch, 742 return ConvertBuffer_1bppMask2Rgb(dest_format, dest_buf, dest_pitch,
923 width, height, pSrcBitmap, src_left, 743 width, height, pSrcBitmap, src_left,
924 src_top); 744 src_top);
925 } 745 }
926 if ((src_format & 0xff) == 8) { 746 if ((src_format & 0xff) == 8) {
927 if (pSrcBitmap->GetPalette()) { 747 if (pSrcBitmap->GetPalette()) {
928 return ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, 748 return ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch,
929 width, height, pSrcBitmap, src_left, 749 width, height, pSrcBitmap, src_left,
930 src_top, pIccTransform); 750 src_top);
931 } 751 }
932 return ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, dest_pitch, 752 return ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, dest_pitch,
933 width, height, pSrcBitmap, src_left, 753 width, height, pSrcBitmap, src_left,
934 src_top); 754 src_top);
935 } 755 }
936 if ((src_format & 0xff) >= 24) { 756 if ((src_format & 0xff) >= 24) {
937 if (src_format & 0x0400) { 757 if (src_format & 0x0400) {
938 return ConvertBuffer_32bppCmyk2Rgb32(dest_buf, dest_pitch, width, 758 return ConvertBuffer_32bppCmyk2Rgb32(dest_buf, dest_pitch, width,
939 height, pSrcBitmap, src_left, 759 height, pSrcBitmap, src_left,
940 src_top, pIccTransform); 760 src_top);
941 } 761 }
942 return ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width, height, 762 return ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width, height,
943 pSrcBitmap, src_left, src_top, 763 pSrcBitmap, src_left, src_top);
944 pIccTransform);
945 } 764 }
946 return FALSE; 765 return FALSE;
947 } 766 }
948 default: 767 default:
949 return FALSE; 768 return FALSE;
950 } 769 }
951 } 770 }
952 CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format, 771
953 const FX_RECT* pClip, 772 CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format) const {
954 void* pIccTransform) const { 773 if (dest_format == GetFormat())
955 if (dest_format == GetFormat() && !pIccTransform) { 774 return Clone(nullptr);
956 return Clone(pClip); 775
957 } 776 std::unique_ptr<CFX_DIBitmap> pClone(new CFX_DIBitmap);
958 if (pClip) { 777 if (!pClone->Create(m_Width, m_Height, dest_format))
959 CFX_DIBitmap* pClone = Clone(pClip);
960 if (!pClone) {
961 return nullptr;
962 }
963 if (!pClone->ConvertFormat(dest_format, pIccTransform)) {
964 delete pClone;
965 return nullptr;
966 }
967 return pClone;
968 }
969 CFX_DIBitmap* pClone = new CFX_DIBitmap;
970 if (!pClone->Create(m_Width, m_Height, dest_format)) {
971 delete pClone;
972 return nullptr; 778 return nullptr;
973 } 779
974 FX_BOOL ret = TRUE;
975 CFX_DIBitmap* pSrcAlpha = nullptr; 780 CFX_DIBitmap* pSrcAlpha = nullptr;
976 if (HasAlpha()) { 781 if (HasAlpha()) {
977 pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask; 782 pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask;
978 if (!pSrcAlpha) { 783 if (!pSrcAlpha)
979 delete pClone;
980 return nullptr; 784 return nullptr;
981 }
982 } 785 }
786
787 FX_BOOL ret = TRUE;
983 if (dest_format & 0x0200) { 788 if (dest_format & 0x0200) {
984 if (dest_format == FXDIB_Argb) { 789 if (dest_format == FXDIB_Argb) {
985 ret = pSrcAlpha ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha, FXDIB_Alpha) 790 ret = pSrcAlpha ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha, FXDIB_Alpha)
986 : pClone->LoadChannel(FXDIB_Alpha, 0xff); 791 : pClone->LoadChannel(FXDIB_Alpha, 0xff);
987 } else { 792 } else {
988 ret = pClone->CopyAlphaMask(pSrcAlpha); 793 ret = pClone->CopyAlphaMask(pSrcAlpha);
989 } 794 }
990 } 795 }
991 if (pSrcAlpha && pSrcAlpha != m_pAlphaMask) { 796 if (pSrcAlpha && pSrcAlpha != m_pAlphaMask) {
992 delete pSrcAlpha; 797 delete pSrcAlpha;
993 pSrcAlpha = nullptr; 798 pSrcAlpha = nullptr;
994 } 799 }
995 if (!ret) { 800 if (!ret)
996 delete pClone;
997 return nullptr; 801 return nullptr;
998 } 802
999 uint32_t* pal_8bpp = nullptr; 803 uint32_t* pal_8bpp = nullptr;
1000 ret = ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(), 804 if (!ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(),
1001 m_Width, m_Height, this, 0, 0, pal_8bpp, pIccTransform); 805 m_Width, m_Height, this, 0, 0, pal_8bpp)) {
1002 if (!ret) {
1003 FX_Free(pal_8bpp); 806 FX_Free(pal_8bpp);
1004 delete pClone;
1005 return nullptr; 807 return nullptr;
1006 } 808 }
1007 if (pal_8bpp) { 809 if (pal_8bpp) {
1008 pClone->CopyPalette(pal_8bpp); 810 pClone->CopyPalette(pal_8bpp);
1009 FX_Free(pal_8bpp); 811 FX_Free(pal_8bpp);
1010 pal_8bpp = nullptr;
1011 } 812 }
1012 return pClone; 813 return pClone.release();
1013 } 814 }
1014 FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format, 815
1015 void* pIccTransform) { 816 FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) {
1016 FXDIB_Format src_format = GetFormat(); 817 FXDIB_Format src_format = GetFormat();
1017 if (dest_format == src_format && !pIccTransform) { 818 if (dest_format == src_format)
1018 return TRUE; 819 return TRUE;
1019 } 820
1020 if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb && 821 if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb &&
1021 !m_pPalette) { 822 !m_pPalette) {
1022 m_AlphaFlag = 1; 823 m_AlphaFlag = 1;
1023 return TRUE; 824 return TRUE;
1024 } 825 }
1025 if (dest_format == FXDIB_Argb && src_format == FXDIB_Rgb32 && 826 if (dest_format == FXDIB_Argb && src_format == FXDIB_Rgb32) {
1026 !pIccTransform) {
1027 m_AlphaFlag = 2; 827 m_AlphaFlag = 2;
1028 for (int row = 0; row < m_Height; row++) { 828 for (int row = 0; row < m_Height; row++) {
1029 uint8_t* scanline = m_pBuffer + row * m_Pitch + 3; 829 uint8_t* scanline = m_pBuffer + row * m_Pitch + 3;
1030 for (int col = 0; col < m_Width; col++) { 830 for (int col = 0; col < m_Width; col++) {
1031 *scanline = 0xff; 831 *scanline = 0xff;
1032 scanline += 4; 832 scanline += 4;
1033 } 833 }
1034 } 834 }
1035 return TRUE; 835 return TRUE;
1036 } 836 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 pAlphaMask = m_pAlphaMask; 869 pAlphaMask = m_pAlphaMask;
1070 m_pAlphaMask = nullptr; 870 m_pAlphaMask = nullptr;
1071 } else { 871 } else {
1072 pAlphaMask = m_pAlphaMask; 872 pAlphaMask = m_pAlphaMask;
1073 } 873 }
1074 } 874 }
1075 } 875 }
1076 FX_BOOL ret = FALSE; 876 FX_BOOL ret = FALSE;
1077 uint32_t* pal_8bpp = nullptr; 877 uint32_t* pal_8bpp = nullptr;
1078 ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height, 878 ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height,
1079 this, 0, 0, pal_8bpp, pIccTransform); 879 this, 0, 0, pal_8bpp);
1080 if (!ret) { 880 if (!ret) {
1081 FX_Free(pal_8bpp); 881 FX_Free(pal_8bpp);
1082 if (pAlphaMask != m_pAlphaMask) { 882 if (pAlphaMask != m_pAlphaMask) {
1083 delete pAlphaMask; 883 delete pAlphaMask;
1084 } 884 }
1085 FX_Free(dest_buf); 885 FX_Free(dest_buf);
1086 return FALSE; 886 return FALSE;
1087 } 887 }
1088 if (m_pAlphaMask && pAlphaMask != m_pAlphaMask) { 888 if (m_pAlphaMask && pAlphaMask != m_pAlphaMask) {
1089 delete m_pAlphaMask; 889 delete m_pAlphaMask;
1090 } 890 }
1091 m_pAlphaMask = pAlphaMask; 891 m_pAlphaMask = pAlphaMask;
1092 FX_Free(m_pPalette); 892 FX_Free(m_pPalette);
1093 m_pPalette = pal_8bpp; 893 m_pPalette = pal_8bpp;
1094 if (!m_bExtBuf) { 894 if (!m_bExtBuf) {
1095 FX_Free(m_pBuffer); 895 FX_Free(m_pBuffer);
1096 } 896 }
1097 m_bExtBuf = FALSE; 897 m_bExtBuf = FALSE;
1098 m_pBuffer = dest_buf; 898 m_pBuffer = dest_buf;
1099 m_bpp = (uint8_t)dest_format; 899 m_bpp = (uint8_t)dest_format;
1100 m_AlphaFlag = (uint8_t)(dest_format >> 8); 900 m_AlphaFlag = (uint8_t)(dest_format >> 8);
1101 m_Pitch = dest_pitch; 901 m_Pitch = dest_pitch;
1102 return TRUE; 902 return TRUE;
1103 } 903 }
OLDNEW
« no previous file with comments | « core/fxge/agg/fx_agg_driver.cpp ('k') | core/fxge/dib/fx_dib_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698