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 <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include "../../../include/fxcrt/fx_coordinates.h" | 9 #include "../../../include/fxcrt/fx_coordinates.h" |
10 #include "../../../include/fxcrt/fx_safe_types.h" | 10 #include "../../../include/fxcrt/fx_safe_types.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 JBig2ComposeOp op, | 122 JBig2ComposeOp op, |
123 const FX_RECT* pSrcRect) { | 123 const FX_RECT* pSrcRect) { |
124 if (!m_pData) { | 124 if (!m_pData) { |
125 return FALSE; | 125 return FALSE; |
126 } | 126 } |
127 if (NULL == pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight)) { | 127 if (NULL == pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight)) { |
128 return composeTo_opt2(pDst, x, y, op); | 128 return composeTo_opt2(pDst, x, y, op); |
129 } | 129 } |
130 return composeTo_opt2(pDst, x, y, op, pSrcRect); | 130 return composeTo_opt2(pDst, x, y, op, pSrcRect); |
131 } | 131 } |
132 FX_BOOL CJBig2_Image::composeTo_unopt(CJBig2_Image* pDst, | |
133 int32_t x, | |
134 int32_t y, | |
135 JBig2ComposeOp op) { | |
136 int32_t w, h, dx, dy; | |
137 int32_t i, j; | |
138 w = m_nWidth; | |
139 h = m_nHeight; | |
140 dx = dy = 0; | |
141 if (x < 0) { | |
142 dx += -x; | |
143 w -= -x; | |
144 x = 0; | |
145 } | |
146 if (y < 0) { | |
147 dy += -y; | |
148 h -= -y; | |
149 y = 0; | |
150 } | |
151 if (x + w > pDst->m_nWidth) { | |
152 w = pDst->m_nWidth - x; | |
153 } | |
154 if (y + h > pDst->m_nHeight) { | |
155 h = pDst->m_nHeight - y; | |
156 } | |
157 switch (op) { | |
158 case JBIG2_COMPOSE_OR: | |
159 for (j = 0; j < h; j++) { | |
160 for (i = 0; i < w; i++) { | |
161 pDst->setPixel( | |
162 x + i, y + j, | |
163 (getPixel(i + dx, j + dy) | pDst->getPixel(x + i, y + j)) & 1); | |
164 } | |
165 } | |
166 break; | |
167 case JBIG2_COMPOSE_AND: | |
168 for (j = 0; j < h; j++) { | |
169 for (i = 0; i < w; i++) { | |
170 pDst->setPixel( | |
171 x + i, y + j, | |
172 (getPixel(i + dx, j + dy) & pDst->getPixel(x + i, y + j)) & 1); | |
173 } | |
174 } | |
175 break; | |
176 case JBIG2_COMPOSE_XOR: | |
177 for (j = 0; j < h; j++) { | |
178 for (i = 0; i < w; i++) { | |
179 pDst->setPixel( | |
180 x + i, y + j, | |
181 (getPixel(i + dx, j + dy) ^ pDst->getPixel(x + i, y + j)) & 1); | |
182 } | |
183 } | |
184 break; | |
185 case JBIG2_COMPOSE_XNOR: | |
186 for (j = 0; j < h; j++) { | |
187 for (i = 0; i < w; i++) { | |
188 pDst->setPixel( | |
189 x + i, y + j, | |
190 (~(getPixel(i + dx, j + dy) ^ pDst->getPixel(x + i, y + j))) & 1); | |
191 } | |
192 } | |
193 break; | |
194 case JBIG2_COMPOSE_REPLACE: | |
195 for (j = 0; j < h; j++) { | |
196 for (i = 0; i < w; i++) { | |
197 pDst->setPixel(x + i, y + j, getPixel(i + dx, j + dy)); | |
198 } | |
199 } | |
200 break; | |
201 } | |
202 return TRUE; | |
203 } | |
204 | 132 |
205 FX_BOOL CJBig2_Image::composeTo_opt(CJBig2_Image* pDst, | |
206 int32_t x, | |
207 int32_t y, | |
208 JBig2ComposeOp op) { | |
209 int32_t x0, x1, y0, y1, xx, yy; | |
210 uint8_t *pLineSrc, *pLineDst, *srcPtr, *destPtr; | |
211 FX_DWORD src0, src1, src, dest, s1, s2, m1, m2, m3; | |
212 FX_BOOL oneByte; | |
213 if (!m_pData) { | |
214 return FALSE; | |
215 } | |
216 if (y < 0) { | |
217 y0 = -y; | |
218 } else { | |
219 y0 = 0; | |
220 } | |
221 if (y + m_nHeight > pDst->m_nHeight) { | |
222 y1 = pDst->m_nHeight - y; | |
223 } else { | |
224 y1 = m_nHeight; | |
225 } | |
226 if (y0 >= y1) { | |
227 return FALSE; | |
228 } | |
229 if (x >= 0) { | |
230 x0 = x & ~7; | |
231 } else { | |
232 x0 = 0; | |
233 } | |
234 x1 = x + m_nWidth; | |
235 if (x1 > pDst->m_nWidth) { | |
236 x1 = pDst->m_nWidth; | |
237 } | |
238 if (x0 >= x1) { | |
239 return FALSE; | |
240 } | |
241 s1 = x & 7; | |
242 s2 = 8 - s1; | |
243 m1 = 0xff >> (x1 & 7); | |
244 m2 = 0xff << (((x1 & 7) == 0) ? 0 : 8 - (x1 & 7)); | |
245 m3 = (0xff >> s1) & m2; | |
246 oneByte = x0 == ((x1 - 1) & ~7); | |
247 pLineDst = pDst->m_pData + y * pDst->m_nStride; | |
248 pLineSrc = m_pData + y0 * m_nStride; | |
249 if (oneByte) { | |
250 if (x >= 0) { | |
251 switch (op) { | |
252 case JBIG2_COMPOSE_OR: { | |
253 for (yy = y0; yy < y1; ++yy) { | |
254 destPtr = pLineDst + (x >> 3); | |
255 srcPtr = pLineSrc; | |
256 dest = *destPtr; | |
257 dest |= (*srcPtr >> s1) & m2; | |
258 *destPtr = (uint8_t)dest; | |
259 pLineDst += pDst->m_nStride; | |
260 pLineSrc += m_nStride; | |
261 } | |
262 } break; | |
263 case JBIG2_COMPOSE_AND: { | |
264 for (yy = y0; yy < y1; ++yy) { | |
265 destPtr = pLineDst + (x >> 3); | |
266 srcPtr = pLineSrc; | |
267 dest = *destPtr; | |
268 dest &= ((0xff00 | *srcPtr) >> s1) | m1; | |
269 *destPtr = (uint8_t)dest; | |
270 pLineDst += pDst->m_nStride; | |
271 pLineSrc += m_nStride; | |
272 } | |
273 } break; | |
274 case JBIG2_COMPOSE_XOR: { | |
275 for (yy = y0; yy < y1; ++yy) { | |
276 destPtr = pLineDst + (x >> 3); | |
277 srcPtr = pLineSrc; | |
278 dest = *destPtr; | |
279 dest ^= (*srcPtr >> s1) & m2; | |
280 *destPtr = (uint8_t)dest; | |
281 pLineDst += pDst->m_nStride; | |
282 pLineSrc += m_nStride; | |
283 } | |
284 } break; | |
285 case JBIG2_COMPOSE_XNOR: { | |
286 for (yy = y0; yy < y1; ++yy) { | |
287 destPtr = pLineDst + (x >> 3); | |
288 srcPtr = pLineSrc; | |
289 dest = *destPtr; | |
290 dest ^= ((*srcPtr ^ 0xff) >> s1) & m2; | |
291 *destPtr = (uint8_t)dest; | |
292 pLineDst += pDst->m_nStride; | |
293 pLineSrc += m_nStride; | |
294 } | |
295 } break; | |
296 case JBIG2_COMPOSE_REPLACE: { | |
297 for (yy = y0; yy < y1; ++yy) { | |
298 destPtr = pLineDst + (x >> 3); | |
299 srcPtr = pLineSrc; | |
300 dest = *destPtr; | |
301 dest = (dest & ~m3) | ((*srcPtr >> s1) & m3); | |
302 *destPtr = (uint8_t)dest; | |
303 pLineDst += pDst->m_nStride; | |
304 pLineSrc += m_nStride; | |
305 } | |
306 } break; | |
307 } | |
308 } else { | |
309 switch (op) { | |
310 case JBIG2_COMPOSE_OR: { | |
311 for (yy = y0; yy < y1; ++yy) { | |
312 destPtr = pLineDst; | |
313 srcPtr = pLineSrc + (-x >> 3); | |
314 dest = *destPtr; | |
315 dest |= *srcPtr & m2; | |
316 *destPtr = (uint8_t)dest; | |
317 pLineDst += pDst->m_nStride; | |
318 pLineSrc += m_nStride; | |
319 } | |
320 } break; | |
321 case JBIG2_COMPOSE_AND: { | |
322 for (yy = y0; yy < y1; ++yy) { | |
323 destPtr = pLineDst; | |
324 srcPtr = pLineSrc + (-x >> 3); | |
325 dest = *destPtr; | |
326 dest &= *srcPtr | m1; | |
327 *destPtr = (uint8_t)dest; | |
328 pLineDst += pDst->m_nStride; | |
329 pLineSrc += m_nStride; | |
330 } | |
331 } break; | |
332 case JBIG2_COMPOSE_XOR: { | |
333 for (yy = y0; yy < y1; ++yy) { | |
334 destPtr = pLineDst; | |
335 srcPtr = pLineSrc + (-x >> 3); | |
336 dest = *destPtr; | |
337 dest ^= *srcPtr & m2; | |
338 *destPtr = (uint8_t)dest; | |
339 pLineDst += pDst->m_nStride; | |
340 pLineSrc += m_nStride; | |
341 } | |
342 } break; | |
343 case JBIG2_COMPOSE_XNOR: { | |
344 for (yy = y0; yy < y1; ++yy) { | |
345 destPtr = pLineDst; | |
346 srcPtr = pLineSrc + (-x >> 3); | |
347 dest = *destPtr; | |
348 dest ^= (*srcPtr ^ 0xff) & m2; | |
349 *destPtr = (uint8_t)dest; | |
350 pLineDst += pDst->m_nStride; | |
351 pLineSrc += m_nStride; | |
352 } | |
353 } break; | |
354 case JBIG2_COMPOSE_REPLACE: { | |
355 for (yy = y0; yy < y1; ++yy) { | |
356 destPtr = pLineDst; | |
357 srcPtr = pLineSrc + (-x >> 3); | |
358 dest = *destPtr; | |
359 dest = (*srcPtr & m2) | (dest & m1); | |
360 *destPtr = (uint8_t)dest; | |
361 pLineDst += pDst->m_nStride; | |
362 pLineSrc += m_nStride; | |
363 } | |
364 } break; | |
365 } | |
366 } | |
367 } else { | |
368 if (x >= 0) { | |
369 switch (op) { | |
370 case JBIG2_COMPOSE_OR: { | |
371 for (yy = y0; yy < y1; ++yy) { | |
372 destPtr = pLineDst + (x >> 3); | |
373 srcPtr = pLineSrc; | |
374 src1 = *srcPtr++; | |
375 dest = *destPtr; | |
376 dest |= src1 >> s1; | |
377 *destPtr++ = (uint8_t)dest; | |
378 xx = x0 + 8; | |
379 for (; xx < x1 - 8; xx += 8) { | |
380 dest = *destPtr; | |
381 src0 = src1; | |
382 src1 = *srcPtr++; | |
383 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
384 dest |= src; | |
385 *destPtr++ = (uint8_t)dest; | |
386 } | |
387 dest = *destPtr; | |
388 src0 = src1; | |
389 if (srcPtr - pLineSrc < m_nStride) { | |
390 src1 = *srcPtr++; | |
391 } else { | |
392 src1 = 0; | |
393 } | |
394 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
395 dest |= src & m2; | |
396 *destPtr = (uint8_t)dest; | |
397 pLineDst += pDst->m_nStride; | |
398 pLineSrc += m_nStride; | |
399 } | |
400 } break; | |
401 case JBIG2_COMPOSE_AND: { | |
402 for (yy = y0; yy < y1; ++yy) { | |
403 destPtr = pLineDst + (x >> 3); | |
404 srcPtr = pLineSrc; | |
405 src1 = *srcPtr++; | |
406 dest = *destPtr; | |
407 dest &= (0xff00 | src1) >> s1; | |
408 *destPtr++ = (uint8_t)dest; | |
409 xx = x0 + 8; | |
410 for (; xx < x1 - 8; xx += 8) { | |
411 dest = *destPtr; | |
412 src0 = src1; | |
413 src1 = *srcPtr++; | |
414 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
415 dest &= src; | |
416 *destPtr++ = (uint8_t)dest; | |
417 } | |
418 dest = *destPtr; | |
419 src0 = src1; | |
420 if (srcPtr - pLineSrc < m_nStride) { | |
421 src1 = *srcPtr++; | |
422 } else { | |
423 src1 = 0; | |
424 } | |
425 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
426 dest &= src | m1; | |
427 *destPtr = (uint8_t)dest; | |
428 pLineDst += pDst->m_nStride; | |
429 pLineSrc += m_nStride; | |
430 } | |
431 } break; | |
432 case JBIG2_COMPOSE_XOR: { | |
433 for (yy = y0; yy < y1; ++yy) { | |
434 destPtr = pLineDst + (x >> 3); | |
435 srcPtr = pLineSrc; | |
436 src1 = *srcPtr++; | |
437 dest = *destPtr; | |
438 dest ^= src1 >> s1; | |
439 *destPtr++ = (uint8_t)dest; | |
440 xx = x0 + 8; | |
441 for (; xx < x1 - 8; xx += 8) { | |
442 dest = *destPtr; | |
443 src0 = src1; | |
444 src1 = *srcPtr++; | |
445 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
446 dest ^= src; | |
447 *destPtr++ = (uint8_t)dest; | |
448 } | |
449 dest = *destPtr; | |
450 src0 = src1; | |
451 if (srcPtr - pLineSrc < m_nStride) { | |
452 src1 = *srcPtr++; | |
453 } else { | |
454 src1 = 0; | |
455 } | |
456 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
457 dest ^= src & m2; | |
458 *destPtr = (uint8_t)dest; | |
459 pLineDst += pDst->m_nStride; | |
460 pLineSrc += m_nStride; | |
461 } | |
462 } break; | |
463 case JBIG2_COMPOSE_XNOR: { | |
464 for (yy = y0; yy < y1; ++yy) { | |
465 destPtr = pLineDst + (x >> 3); | |
466 srcPtr = pLineSrc; | |
467 src1 = *srcPtr++; | |
468 dest = *destPtr; | |
469 dest ^= (src1 ^ 0xff) >> s1; | |
470 *destPtr++ = (uint8_t)dest; | |
471 xx = x0 + 8; | |
472 for (; xx < x1 - 8; xx += 8) { | |
473 dest = *destPtr; | |
474 src0 = src1; | |
475 src1 = *srcPtr++; | |
476 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
477 dest ^= src ^ 0xff; | |
478 *destPtr++ = (uint8_t)dest; | |
479 } | |
480 dest = *destPtr; | |
481 src0 = src1; | |
482 if (srcPtr - pLineSrc < m_nStride) { | |
483 src1 = *srcPtr++; | |
484 } else { | |
485 src1 = 0; | |
486 } | |
487 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
488 dest ^= (src ^ 0xff) & m2; | |
489 *destPtr = (uint8_t)dest; | |
490 pLineDst += pDst->m_nStride; | |
491 pLineSrc += m_nStride; | |
492 } | |
493 } break; | |
494 case JBIG2_COMPOSE_REPLACE: { | |
495 for (yy = y0; yy < y1; ++yy) { | |
496 destPtr = pLineDst + (x >> 3); | |
497 srcPtr = pLineSrc; | |
498 src1 = *srcPtr++; | |
499 dest = *destPtr; | |
500 dest = (dest & (0xff << s2)) | (src1 >> s1); | |
501 *destPtr++ = (uint8_t)dest; | |
502 xx = x0 + 8; | |
503 for (; xx < x1 - 8; xx += 8) { | |
504 dest = *destPtr; | |
505 src0 = src1; | |
506 src1 = *srcPtr++; | |
507 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
508 dest = src; | |
509 *destPtr++ = (uint8_t)dest; | |
510 } | |
511 dest = *destPtr; | |
512 src0 = src1; | |
513 if (srcPtr - pLineSrc < m_nStride) { | |
514 src1 = *srcPtr++; | |
515 } else { | |
516 src1 = 0; | |
517 } | |
518 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
519 dest = (src & m2) | (dest & m1); | |
520 *destPtr = (uint8_t)dest; | |
521 pLineDst += pDst->m_nStride; | |
522 pLineSrc += m_nStride; | |
523 } | |
524 } break; | |
525 } | |
526 } else { | |
527 switch (op) { | |
528 case JBIG2_COMPOSE_OR: { | |
529 for (yy = y0; yy < y1; ++yy) { | |
530 destPtr = pLineDst; | |
531 srcPtr = pLineSrc + (-x >> 3); | |
532 src1 = *srcPtr++; | |
533 xx = x0; | |
534 for (; xx < x1 - 8; xx += 8) { | |
535 dest = *destPtr; | |
536 src0 = src1; | |
537 src1 = *srcPtr++; | |
538 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
539 dest |= src; | |
540 *destPtr++ = (uint8_t)dest; | |
541 } | |
542 dest = *destPtr; | |
543 src0 = src1; | |
544 if (srcPtr - pLineSrc < m_nStride) { | |
545 src1 = *srcPtr++; | |
546 } else { | |
547 src1 = 0; | |
548 } | |
549 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
550 dest |= src & m2; | |
551 *destPtr = (uint8_t)dest; | |
552 pLineDst += pDst->m_nStride; | |
553 pLineSrc += m_nStride; | |
554 } | |
555 } break; | |
556 case JBIG2_COMPOSE_AND: { | |
557 for (yy = y0; yy < y1; ++yy) { | |
558 destPtr = pLineDst; | |
559 srcPtr = pLineSrc + (-x >> 3); | |
560 src1 = *srcPtr++; | |
561 xx = x0; | |
562 for (; xx < x1 - 8; xx += 8) { | |
563 dest = *destPtr; | |
564 src0 = src1; | |
565 src1 = *srcPtr++; | |
566 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
567 dest &= src; | |
568 *destPtr++ = (uint8_t)dest; | |
569 } | |
570 dest = *destPtr; | |
571 src0 = src1; | |
572 if (srcPtr - pLineSrc < m_nStride) { | |
573 src1 = *srcPtr++; | |
574 } else { | |
575 src1 = 0; | |
576 } | |
577 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
578 dest &= src | m1; | |
579 *destPtr = (uint8_t)dest; | |
580 pLineDst += pDst->m_nStride; | |
581 pLineSrc += m_nStride; | |
582 } | |
583 } break; | |
584 case JBIG2_COMPOSE_XOR: { | |
585 for (yy = y0; yy < y1; ++yy) { | |
586 destPtr = pLineDst; | |
587 srcPtr = pLineSrc + (-x >> 3); | |
588 src1 = *srcPtr++; | |
589 xx = x0; | |
590 for (; xx < x1 - 8; xx += 8) { | |
591 dest = *destPtr; | |
592 src0 = src1; | |
593 src1 = *srcPtr++; | |
594 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
595 dest ^= src; | |
596 *destPtr++ = (uint8_t)dest; | |
597 } | |
598 dest = *destPtr; | |
599 src0 = src1; | |
600 if (srcPtr - pLineSrc < m_nStride) { | |
601 src1 = *srcPtr++; | |
602 } else { | |
603 src1 = 0; | |
604 } | |
605 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
606 dest ^= src & m2; | |
607 *destPtr = (uint8_t)dest; | |
608 pLineDst += pDst->m_nStride; | |
609 pLineSrc += m_nStride; | |
610 } | |
611 } break; | |
612 case JBIG2_COMPOSE_XNOR: { | |
613 for (yy = y0; yy < y1; ++yy) { | |
614 destPtr = pLineDst; | |
615 srcPtr = pLineSrc + (-x >> 3); | |
616 src1 = *srcPtr++; | |
617 xx = x0; | |
618 for (; xx < x1 - 8; xx += 8) { | |
619 dest = *destPtr; | |
620 src0 = src1; | |
621 src1 = *srcPtr++; | |
622 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
623 dest ^= src ^ 0xff; | |
624 *destPtr++ = (uint8_t)dest; | |
625 } | |
626 dest = *destPtr; | |
627 src0 = src1; | |
628 if (srcPtr - pLineSrc < m_nStride) { | |
629 src1 = *srcPtr++; | |
630 } else { | |
631 src1 = 0; | |
632 } | |
633 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
634 dest ^= (src ^ 0xff) & m2; | |
635 *destPtr = (uint8_t)dest; | |
636 pLineDst += pDst->m_nStride; | |
637 pLineSrc += m_nStride; | |
638 } | |
639 } break; | |
640 case JBIG2_COMPOSE_REPLACE: { | |
641 for (yy = y0; yy < y1; ++yy) { | |
642 destPtr = pLineDst; | |
643 srcPtr = pLineSrc + (-x >> 3); | |
644 src1 = *srcPtr++; | |
645 xx = x0; | |
646 for (; xx < x1 - 8; xx += 8) { | |
647 dest = *destPtr; | |
648 src0 = src1; | |
649 src1 = *srcPtr++; | |
650 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
651 dest = src; | |
652 *destPtr++ = (uint8_t)dest; | |
653 } | |
654 dest = *destPtr; | |
655 src0 = src1; | |
656 if (srcPtr - pLineSrc < m_nStride) { | |
657 src1 = *srcPtr++; | |
658 } else { | |
659 src1 = 0; | |
660 } | |
661 src = (((src0 << 8) | src1) >> s1) & 0xff; | |
662 dest = (src & m2) | (dest & m1); | |
663 *destPtr = (uint8_t)dest; | |
664 pLineDst += pDst->m_nStride; | |
665 pLineSrc += m_nStride; | |
666 } | |
667 } break; | |
668 } | |
669 } | |
670 } | |
671 return TRUE; | |
672 } | |
673 FX_BOOL CJBig2_Image::composeFrom(int32_t x, | 133 FX_BOOL CJBig2_Image::composeFrom(int32_t x, |
674 int32_t y, | 134 int32_t y, |
675 CJBig2_Image* pSrc, | 135 CJBig2_Image* pSrc, |
676 JBig2ComposeOp op) { | 136 JBig2ComposeOp op) { |
677 if (!m_pData) { | 137 if (!m_pData) { |
678 return FALSE; | 138 return FALSE; |
679 } | 139 } |
680 return pSrc->composeTo(this, x, y, op); | 140 return pSrc->composeTo(this, x, y, op); |
681 } | 141 } |
682 FX_BOOL CJBig2_Image::composeFrom(int32_t x, | 142 FX_BOOL CJBig2_Image::composeFrom(int32_t x, |
683 int32_t y, | 143 int32_t y, |
684 CJBig2_Image* pSrc, | 144 CJBig2_Image* pSrc, |
685 JBig2ComposeOp op, | 145 JBig2ComposeOp op, |
686 const FX_RECT* pSrcRect) { | 146 const FX_RECT* pSrcRect) { |
687 if (!m_pData) { | 147 if (!m_pData) { |
688 return FALSE; | 148 return FALSE; |
689 } | 149 } |
690 return pSrc->composeTo(this, x, y, op, pSrcRect); | 150 return pSrc->composeTo(this, x, y, op, pSrcRect); |
691 } | 151 } |
692 CJBig2_Image* CJBig2_Image::subImage_unopt(int32_t x, | |
693 int32_t y, | |
694 int32_t w, | |
695 int32_t h) { | |
696 CJBig2_Image* pImage; | |
697 int32_t i, j; | |
698 JBIG2_ALLOC(pImage, CJBig2_Image(w, h)); | |
699 for (j = 0; j < h; j++) { | |
700 for (i = 0; i < w; i++) { | |
701 pImage->setPixel(i, j, getPixel(x + i, y + j)); | |
702 } | |
703 } | |
704 return pImage; | |
705 } | |
706 #define JBIG2_GETDWORD(buf) \ | 152 #define JBIG2_GETDWORD(buf) \ |
707 ((FX_DWORD)(((buf)[0] << 24) | ((buf)[1] << 16) | ((buf)[2] << 8) | (buf)[3])) | 153 ((FX_DWORD)(((buf)[0] << 24) | ((buf)[1] << 16) | ((buf)[2] << 8) | (buf)[3])) |
708 CJBig2_Image* CJBig2_Image::subImage(int32_t x, | 154 CJBig2_Image* CJBig2_Image::subImage(int32_t x, |
709 int32_t y, | 155 int32_t y, |
710 int32_t w, | 156 int32_t w, |
711 int32_t h) { | 157 int32_t h) { |
712 CJBig2_Image* pImage; | 158 CJBig2_Image* pImage; |
713 int32_t m, n, j; | 159 int32_t m, n, j; |
714 uint8_t *pLineSrc, *pLineDst; | 160 uint8_t *pLineSrc, *pLineDst; |
715 FX_DWORD wTmp; | 161 FX_DWORD wTmp; |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 dp[2] = (uint8_t)(tmp >> 8); | 1092 dp[2] = (uint8_t)(tmp >> 8); |
1647 dp[3] = (uint8_t)tmp; | 1093 dp[3] = (uint8_t)tmp; |
1648 } | 1094 } |
1649 lineSrc += m_nStride; | 1095 lineSrc += m_nStride; |
1650 lineDst += pDst->m_nStride; | 1096 lineDst += pDst->m_nStride; |
1651 } | 1097 } |
1652 } | 1098 } |
1653 } | 1099 } |
1654 return 1; | 1100 return 1; |
1655 } | 1101 } |
OLD | NEW |