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