| 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 "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
| 8 #include "../../../include/fxcodec/fx_codec.h" | 8 #include "../../../include/fxcodec/fx_codec.h" |
| 9 #include "dib_int.h" | 9 #include "dib_int.h" |
| 10 const FX_BYTE g_GammaRamp[256] = { | 10 const FX_BYTE g_GammaRamp[256] = { |
| 11 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1
, | 11 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, |
| 12 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3
, | 12 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, |
| 13 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7
, | 13 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, |
| 14 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13
, | 14 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, |
| 15 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 2
0, | 15 12, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 17, |
| 16 20, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 2
9, | 16 18, 18, 19, 19, 20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 25, |
| 17 30, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 37, 38, 39, 40, 4
1, | 17 26, 27, 27, 28, 29, 29, 30, 30, 31, 32, 32, 33, 34, 35, 35, |
| 18 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 51, 51, 52, 53, 5
4, | 18 36, 37, 37, 38, 39, 40, 41, 41, 42, 43, 44, 45, 45, 46, 47, |
| 19 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 7
0, | 19 48, 49, 50, 51, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, |
| 20 71, 72, 73, 74, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 8
8, | 20 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, |
| 21 90, 91, 92, 93, 95, 96, 97, 99, 100, 101, 103, 104, 105, 107, 108, 10
9, | 21 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 95, |
| 22 111, 112, 114, 115, 116, 118, 119, 121, 122, 124, 125, 127, 128, 130, 131, 1
33, | 22 96, 97, 99, 100, 101, 103, 104, 105, 107, 108, 109, 111, 112, 114, 115, |
| 23 134, 136, 138, 139, 141, 142, 144, 146, 147, 149, 151, 152, 154, 156, 157, 1
59, | 23 116, 118, 119, 121, 122, 124, 125, 127, 128, 130, 131, 133, 134, 136, 138, |
| 24 161, 163, 164, 166, 168, 170, 171, 173, 175, 177, 179, 181, 183, 184, 186, 1
88, | 24 139, 141, 142, 144, 146, 147, 149, 151, 152, 154, 156, 157, 159, 161, 163, |
| 25 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 2
20, | 25 164, 166, 168, 170, 171, 173, 175, 177, 179, 181, 183, 184, 186, 188, 190, |
| 26 222, 224, 226, 229, 231, 233, 235, 237, 239, 242, 244, 246, 248, 250, 253, 2
55, | 26 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, |
| 27 222, 224, 226, 229, 231, 233, 235, 237, 239, 242, 244, 246, 248, 250, 253, |
| 28 255, |
| 27 }; | 29 }; |
| 28 const FX_BYTE g_GammaInverse[256] = { | 30 const FX_BYTE g_GammaInverse[256] = { |
| 29 0, 13, 22, 28, 34, 38, 42, 46, 50, 53, 56, 59, 61, 64, 66, 69
, | 31 0, 13, 22, 28, 34, 38, 42, 46, 50, 53, 56, 59, 61, 64, 66, |
| 30 71, 73, 75, 77, 79, 81, 83, 85, 86, 88, 90, 92, 93, 95, 96, 9
8, | 32 69, 71, 73, 75, 77, 79, 81, 83, 85, 86, 88, 90, 92, 93, 95, |
| 31 99, 101, 102, 104, 105, 106, 108, 109, 110, 112, 113, 114, 115, 117, 118, 11
9, | 33 96, 98, 99, 101, 102, 104, 105, 106, 108, 109, 110, 112, 113, 114, 115, |
| 32 120, 121, 122, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 1
36, | 34 117, 118, 119, 120, 121, 122, 124, 125, 126, 127, 128, 129, 130, 131, 132, |
| 33 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 148, 149, 150, 1
51, | 35 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, |
| 34 152, 153, 154, 155, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 163, 1
64, | 36 148, 148, 149, 150, 151, 152, 153, 154, 155, 155, 156, 157, 158, 159, 159, |
| 35 165, 166, 167, 167, 168, 169, 170, 170, 171, 172, 173, 173, 174, 175, 175, 1
76, | 37 160, 161, 162, 163, 163, 164, 165, 166, 167, 167, 168, 169, 170, 170, 171, |
| 36 177, 178, 178, 179, 180, 180, 181, 182, 182, 183, 184, 185, 185, 186, 187, 1
87, | 38 172, 173, 173, 174, 175, 175, 176, 177, 178, 178, 179, 180, 180, 181, 182, |
| 37 188, 189, 189, 190, 190, 191, 192, 192, 193, 194, 194, 195, 196, 196, 197, 1
97, | 39 182, 183, 184, 185, 185, 186, 187, 187, 188, 189, 189, 190, 190, 191, 192, |
| 38 198, 199, 199, 200, 200, 201, 202, 202, 203, 203, 204, 205, 205, 206, 206, 2
07, | 40 192, 193, 194, 194, 195, 196, 196, 197, 197, 198, 199, 199, 200, 200, 201, |
| 39 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 214, 215, 215, 2
16, | 41 202, 202, 203, 203, 204, 205, 205, 206, 206, 207, 208, 208, 209, 209, 210, |
| 40 216, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224, 2
24, | 42 210, 211, 212, 212, 213, 213, 214, 214, 215, 215, 216, 216, 217, 218, 218, |
| 41 225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 2
33, | 43 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224, 224, 225, 226, 226, |
| 42 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 238, 239, 239, 240, 2
40, | 44 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, 233, 234, |
| 43 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, 246, 247, 247, 2
48, | 45 234, 235, 235, 236, 236, 237, 237, 238, 238, 238, 239, 239, 240, 240, 241, |
| 44 248, 249, 249, 250, 250, 251, 251, 251, 252, 252, 253, 253, 254, 254, 255, 2
55, | 46 241, 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, 246, 247, 247, 248, |
| 47 248, 249, 249, 250, 250, 251, 251, 251, 252, 252, 253, 253, 254, 254, 255, |
| 48 255, |
| 45 }; | 49 }; |
| 46 const FX_BYTE _color_sqrt[256] = { | 50 const FX_BYTE _color_sqrt[256] = { |
| 47 0x00, 0x03, 0x07, 0x0B, 0x0F, 0x12, 0x16, 0x19, 0x1D, 0x20, 0x23, 0x26, 0x29
, 0x2C, 0x2F, 0x32, | 51 0x00, 0x03, 0x07, 0x0B, 0x0F, 0x12, 0x16, 0x19, 0x1D, 0x20, 0x23, 0x26, 0x29, |
| 48 0x35, 0x37, 0x3A, 0x3C, 0x3F, 0x41, 0x43, 0x46, 0x48, 0x4A, 0x4C, 0x4E, 0x50
, 0x52, 0x54, 0x56, | 52 0x2C, 0x2F, 0x32, 0x35, 0x37, 0x3A, 0x3C, 0x3F, 0x41, 0x43, 0x46, 0x48, 0x4A, |
| 49 0x57, 0x59, 0x5B, 0x5C, 0x5E, 0x60, 0x61, 0x63, 0x64, 0x65, 0x67, 0x68, 0x69
, 0x6B, 0x6C, 0x6D, | 53 0x4C, 0x4E, 0x50, 0x52, 0x54, 0x56, 0x57, 0x59, 0x5B, 0x5C, 0x5E, 0x60, 0x61, |
| 50 0x6E, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B
, 0x7C, 0x7D, 0x7E, | 54 0x63, 0x64, 0x65, 0x67, 0x68, 0x69, 0x6B, 0x6C, 0x6D, 0x6E, 0x70, 0x71, 0x72, |
| 51 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x87, 0x88, 0x89, 0x8A, 0x8B
, 0x8C, 0x8D, 0x8E, | 55 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x80, |
| 52 0x8F, 0x90, 0x91, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x97, 0x98, 0x99
, 0x9A, 0x9B, 0x9C, | 56 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, |
| 53 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA4, 0xA5, 0xA6
, 0xA7, 0xA7, 0xA8, | 57 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x97, |
| 54 0xA9, 0xAA, 0xAA, 0xAB, 0xAC, 0xAD, 0xAD, 0xAE, 0xAF, 0xB0, 0xB0, 0xB1, 0xB2
, 0xB3, 0xB3, 0xB4, | 58 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA0, 0xA1, 0xA2, |
| 55 0xB5, 0xB5, 0xB6, 0xB7, 0xB7, 0xB8, 0xB9, 0xBA, 0xBA, 0xBB, 0xBC, 0xBC, 0xBD
, 0xBE, 0xBE, 0xBF, | 59 0xA3, 0xA4, 0xA4, 0xA5, 0xA6, 0xA7, 0xA7, 0xA8, 0xA9, 0xAA, 0xAA, 0xAB, 0xAC, |
| 56 0xC0, 0xC0, 0xC1, 0xC2, 0xC2, 0xC3, 0xC4, 0xC4, 0xC5, 0xC6, 0xC6, 0xC7, 0xC7
, 0xC8, 0xC9, 0xC9, | 60 0xAD, 0xAD, 0xAE, 0xAF, 0xB0, 0xB0, 0xB1, 0xB2, 0xB3, 0xB3, 0xB4, 0xB5, 0xB5, |
| 57 0xCA, 0xCB, 0xCB, 0xCC, 0xCC, 0xCD, 0xCE, 0xCE, 0xCF, 0xD0, 0xD0, 0xD1, 0xD1
, 0xD2, 0xD3, 0xD3, | 61 0xB6, 0xB7, 0xB7, 0xB8, 0xB9, 0xBA, 0xBA, 0xBB, 0xBC, 0xBC, 0xBD, 0xBE, 0xBE, |
| 58 0xD4, 0xD4, 0xD5, 0xD6, 0xD6, 0xD7, 0xD7, 0xD8, 0xD9, 0xD9, 0xDA, 0xDA, 0xDB
, 0xDC, 0xDC, 0xDD, | 62 0xBF, 0xC0, 0xC0, 0xC1, 0xC2, 0xC2, 0xC3, 0xC4, 0xC4, 0xC5, 0xC6, 0xC6, 0xC7, |
| 59 0xDD, 0xDE, 0xDE, 0xDF, 0xE0, 0xE0, 0xE1, 0xE1, 0xE2, 0xE2, 0xE3, 0xE4, 0xE4
, 0xE5, 0xE5, 0xE6, | 63 0xC7, 0xC8, 0xC9, 0xC9, 0xCA, 0xCB, 0xCB, 0xCC, 0xCC, 0xCD, 0xCE, 0xCE, 0xCF, |
| 60 0xE6, 0xE7, 0xE7, 0xE8, 0xE9, 0xE9, 0xEA, 0xEA, 0xEB, 0xEB, 0xEC, 0xEC, 0xED
, 0xED, 0xEE, 0xEE, | 64 0xD0, 0xD0, 0xD1, 0xD1, 0xD2, 0xD3, 0xD3, 0xD4, 0xD4, 0xD5, 0xD6, 0xD6, 0xD7, |
| 61 0xEF, 0xF0, 0xF0, 0xF1, 0xF1, 0xF2, 0xF2, 0xF3, 0xF3, 0xF4, 0xF4, 0xF5, 0xF5
, 0xF6, 0xF6, 0xF7, | 65 0xD7, 0xD8, 0xD9, 0xD9, 0xDA, 0xDA, 0xDB, 0xDC, 0xDC, 0xDD, 0xDD, 0xDE, 0xDE, |
| 62 0xF7, 0xF8, 0xF8, 0xF9, 0xF9, 0xFA, 0xFA, 0xFB, 0xFB, 0xFC, 0xFC, 0xFD, 0xFD
, 0xFE, 0xFE, 0xFF | 66 0xDF, 0xE0, 0xE0, 0xE1, 0xE1, 0xE2, 0xE2, 0xE3, 0xE4, 0xE4, 0xE5, 0xE5, 0xE6, |
| 67 0xE6, 0xE7, 0xE7, 0xE8, 0xE9, 0xE9, 0xEA, 0xEA, 0xEB, 0xEB, 0xEC, 0xEC, 0xED, |
| 68 0xED, 0xEE, 0xEE, 0xEF, 0xF0, 0xF0, 0xF1, 0xF1, 0xF2, 0xF2, 0xF3, 0xF3, 0xF4, |
| 69 0xF4, 0xF5, 0xF5, 0xF6, 0xF6, 0xF7, 0xF7, 0xF8, 0xF8, 0xF9, 0xF9, 0xFA, 0xFA, |
| 70 0xFB, 0xFB, 0xFC, 0xFC, 0xFD, 0xFD, 0xFE, 0xFE, 0xFF |
| 63 }; | 71 }; |
| 64 int _BLEND(int blend_mode, int back_color, int src_color) | 72 int _BLEND(int blend_mode, int back_color, int src_color) { |
| 65 { | 73 switch (blend_mode) { |
| 66 switch (blend_mode) { | 74 case FXDIB_BLEND_NORMAL: |
| 67 case FXDIB_BLEND_NORMAL: | 75 return src_color; |
| 68 return src_color; | 76 case FXDIB_BLEND_MULTIPLY: |
| 69 case FXDIB_BLEND_MULTIPLY: | 77 return src_color * back_color / 255; |
| 70 return src_color * back_color / 255; | 78 case FXDIB_BLEND_SCREEN: |
| 71 case FXDIB_BLEND_SCREEN: | 79 return src_color + back_color - src_color * back_color / 255; |
| 72 return src_color + back_color - src_color * back_color / 255; | 80 case FXDIB_BLEND_OVERLAY: |
| 73 case FXDIB_BLEND_OVERLAY: | 81 return _BLEND(FXDIB_BLEND_HARDLIGHT, src_color, back_color); |
| 74 return _BLEND(FXDIB_BLEND_HARDLIGHT, src_color, back_color); | 82 case FXDIB_BLEND_DARKEN: |
| 75 case FXDIB_BLEND_DARKEN: | 83 return src_color < back_color ? src_color : back_color; |
| 76 return src_color < back_color ? src_color : back_color; | 84 case FXDIB_BLEND_LIGHTEN: |
| 77 case FXDIB_BLEND_LIGHTEN: | 85 return src_color > back_color ? src_color : back_color; |
| 78 return src_color > back_color ? src_color : back_color; | 86 case FXDIB_BLEND_COLORDODGE: { |
| 79 case FXDIB_BLEND_COLORDODGE: { | 87 if (src_color == 255) { |
| 80 if (src_color == 255) { | 88 return src_color; |
| 81 return src_color; | 89 } |
| 82 } | 90 int result = back_color * 255 / (255 - src_color); |
| 83 int result = back_color * 255 / (255 - src_color); | 91 if (result > 255) { |
| 84 if (result > 255) { | 92 return 255; |
| 85 return 255; | 93 } |
| 86 } | 94 return result; |
| 87 return result; | 95 } |
| 96 case FXDIB_BLEND_COLORBURN: { |
| 97 if (src_color == 0) { |
| 98 return src_color; |
| 99 } |
| 100 int result = (255 - back_color) * 255 / src_color; |
| 101 if (result > 255) { |
| 102 result = 255; |
| 103 } |
| 104 return 255 - result; |
| 105 } |
| 106 case FXDIB_BLEND_HARDLIGHT: |
| 107 if (src_color < 128) { |
| 108 return (src_color * back_color * 2) / 255; |
| 109 } |
| 110 return _BLEND(FXDIB_BLEND_SCREEN, back_color, 2 * src_color - 255); |
| 111 case FXDIB_BLEND_SOFTLIGHT: { |
| 112 if (src_color < 128) { |
| 113 return back_color - |
| 114 (255 - 2 * src_color) * back_color * (255 - back_color) / 255 / |
| 115 255; |
| 116 } |
| 117 return back_color + |
| 118 (2 * src_color - 255) * (_color_sqrt[back_color] - back_color) / |
| 119 255; |
| 120 } |
| 121 case FXDIB_BLEND_DIFFERENCE: |
| 122 return back_color < src_color ? src_color - back_color |
| 123 : back_color - src_color; |
| 124 case FXDIB_BLEND_EXCLUSION: |
| 125 return back_color + src_color - 2 * back_color * src_color / 255; |
| 126 } |
| 127 return src_color; |
| 128 } |
| 129 struct _RGB { |
| 130 int red; |
| 131 int green; |
| 132 int blue; |
| 133 }; |
| 134 static inline int _Lum(_RGB color) { |
| 135 return (color.red * 30 + color.green * 59 + color.blue * 11) / 100; |
| 136 } |
| 137 static _RGB _ClipColor(_RGB color) { |
| 138 int l = _Lum(color); |
| 139 int n = color.red; |
| 140 if (color.green < n) { |
| 141 n = color.green; |
| 142 } |
| 143 if (color.blue < n) { |
| 144 n = color.blue; |
| 145 } |
| 146 int x = color.red; |
| 147 if (color.green > x) { |
| 148 x = color.green; |
| 149 } |
| 150 if (color.blue > x) { |
| 151 x = color.blue; |
| 152 } |
| 153 if (n < 0) { |
| 154 color.red = l + ((color.red - l) * l / (l - n)); |
| 155 color.green = l + ((color.green - l) * l / (l - n)); |
| 156 color.blue = l + ((color.blue - l) * l / (l - n)); |
| 157 } |
| 158 if (x > 255) { |
| 159 color.red = l + ((color.red - l) * (255 - l) / (x - l)); |
| 160 color.green = l + ((color.green - l) * (255 - l) / (x - l)); |
| 161 color.blue = l + ((color.blue - l) * (255 - l) / (x - l)); |
| 162 } |
| 163 return color; |
| 164 } |
| 165 static _RGB _SetLum(_RGB color, int l) { |
| 166 int d = l - _Lum(color); |
| 167 color.red += d; |
| 168 color.green += d; |
| 169 color.blue += d; |
| 170 return _ClipColor(color); |
| 171 } |
| 172 static int _Sat(_RGB color) { |
| 173 int n = color.red; |
| 174 if (color.green < n) { |
| 175 n = color.green; |
| 176 } |
| 177 if (color.blue < n) { |
| 178 n = color.blue; |
| 179 } |
| 180 int x = color.red; |
| 181 if (color.green > x) { |
| 182 x = color.green; |
| 183 } |
| 184 if (color.blue > x) { |
| 185 x = color.blue; |
| 186 } |
| 187 return x - n; |
| 188 } |
| 189 static _RGB _SetSat(_RGB color, int s) { |
| 190 int* max = &color.red; |
| 191 int* mid = &color.red; |
| 192 int* min = &color.red; |
| 193 if (color.green > *max) { |
| 194 max = &color.green; |
| 195 } |
| 196 if (color.blue > *max) { |
| 197 max = &color.blue; |
| 198 } |
| 199 if (color.green < *min) { |
| 200 min = &color.green; |
| 201 } |
| 202 if (color.blue < *min) { |
| 203 min = &color.blue; |
| 204 } |
| 205 if (*max == *min) { |
| 206 color.red = 0; |
| 207 color.green = 0; |
| 208 color.blue = 0; |
| 209 return color; |
| 210 } |
| 211 if (max == &color.red) { |
| 212 if (min == &color.green) { |
| 213 mid = &color.blue; |
| 214 } else { |
| 215 mid = &color.green; |
| 216 } |
| 217 } else if (max == &color.green) { |
| 218 if (min == &color.red) { |
| 219 mid = &color.blue; |
| 220 } else { |
| 221 mid = &color.red; |
| 222 } |
| 223 } else { |
| 224 if (min == &color.green) { |
| 225 mid = &color.red; |
| 226 } else { |
| 227 mid = &color.green; |
| 228 } |
| 229 } |
| 230 if (*max > *min) { |
| 231 *mid = (*mid - *min) * s / (*max - *min); |
| 232 *max = s; |
| 233 *min = 0; |
| 234 } |
| 235 return color; |
| 236 } |
| 237 void _RGB_Blend(int blend_mode, |
| 238 FX_LPCBYTE src_scan, |
| 239 FX_BYTE* dest_scan, |
| 240 int results[3]) { |
| 241 _RGB src, back, result; |
| 242 src.red = src_scan[2]; |
| 243 src.green = src_scan[1]; |
| 244 src.blue = src_scan[0]; |
| 245 back.red = dest_scan[2]; |
| 246 back.green = dest_scan[1]; |
| 247 back.blue = dest_scan[0]; |
| 248 switch (blend_mode) { |
| 249 case FXDIB_BLEND_HUE: |
| 250 result = _SetLum(_SetSat(src, _Sat(back)), _Lum(back)); |
| 251 break; |
| 252 case FXDIB_BLEND_SATURATION: |
| 253 result = _SetLum(_SetSat(back, _Sat(src)), _Lum(back)); |
| 254 break; |
| 255 case FXDIB_BLEND_COLOR: |
| 256 result = _SetLum(src, _Lum(back)); |
| 257 break; |
| 258 case FXDIB_BLEND_LUMINOSITY: |
| 259 result = _SetLum(back, _Lum(src)); |
| 260 break; |
| 261 } |
| 262 results[0] = result.blue; |
| 263 results[1] = result.green; |
| 264 results[2] = result.red; |
| 265 } |
| 266 inline void _CompositeRow_Argb2Mask(FX_LPBYTE dest_scan, |
| 267 FX_LPCBYTE src_scan, |
| 268 int pixel_count, |
| 269 FX_LPCBYTE clip_scan) { |
| 270 src_scan += 3; |
| 271 for (int col = 0; col < pixel_count; col++) { |
| 272 int src_alpha = *src_scan; |
| 273 if (clip_scan) { |
| 274 src_alpha = clip_scan[col] * src_alpha / 255; |
| 275 } |
| 276 FX_BYTE back_alpha = *dest_scan; |
| 277 if (!back_alpha) { |
| 278 *dest_scan = src_alpha; |
| 279 } else if (src_alpha) { |
| 280 *dest_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 281 } |
| 282 dest_scan++; |
| 283 src_scan += 4; |
| 284 } |
| 285 } |
| 286 void _CompositeRow_Rgba2Mask(FX_LPBYTE dest_scan, |
| 287 FX_LPCBYTE src_alpha_scan, |
| 288 int pixel_count, |
| 289 FX_LPCBYTE clip_scan) { |
| 290 for (int col = 0; col < pixel_count; col++) { |
| 291 int src_alpha = *src_alpha_scan++; |
| 292 if (clip_scan) { |
| 293 src_alpha = clip_scan[col] * src_alpha / 255; |
| 294 } |
| 295 FX_BYTE back_alpha = *dest_scan; |
| 296 if (!back_alpha) { |
| 297 *dest_scan = src_alpha; |
| 298 } else if (src_alpha) { |
| 299 *dest_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 300 } |
| 301 dest_scan++; |
| 302 } |
| 303 } |
| 304 void _CompositeRow_Rgb2Mask(FX_LPBYTE dest_scan, |
| 305 FX_LPCBYTE src_scan, |
| 306 int width, |
| 307 FX_LPCBYTE clip_scan) { |
| 308 if (clip_scan) { |
| 309 for (int i = 0; i < width; i++) { |
| 310 *dest_scan = FXDIB_ALPHA_UNION(*dest_scan, *clip_scan); |
| 311 dest_scan++; |
| 312 clip_scan++; |
| 313 } |
| 314 } else { |
| 315 FXSYS_memset8(dest_scan, 0xff, width); |
| 316 } |
| 317 } |
| 318 void _CompositeRow_Argb2Graya(FX_LPBYTE dest_scan, |
| 319 FX_LPCBYTE src_scan, |
| 320 int pixel_count, |
| 321 int blend_type, |
| 322 FX_LPCBYTE clip_scan, |
| 323 FX_LPCBYTE src_alpha_scan, |
| 324 FX_LPBYTE dst_alpha_scan, |
| 325 void* pIccTransform) { |
| 326 ICodec_IccModule* pIccModule = NULL; |
| 327 if (pIccTransform) { |
| 328 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 329 } |
| 330 if (blend_type) { |
| 331 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 332 int blended_color; |
| 333 if (src_alpha_scan) { |
| 334 for (int col = 0; col < pixel_count; col++) { |
| 335 FX_BYTE back_alpha = *dst_alpha_scan; |
| 336 if (back_alpha == 0) { |
| 337 int src_alpha = *src_alpha_scan++; |
| 338 if (clip_scan) { |
| 339 src_alpha = clip_scan[col] * src_alpha / 255; |
| 340 } |
| 341 if (src_alpha) { |
| 342 if (pIccTransform) { |
| 343 pIccModule->TranslateScanline( |
| 344 pIccTransform, dest_scan, src_scan, 1); |
| 345 } else { |
| 346 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 88 } | 347 } |
| 89 case FXDIB_BLEND_COLORBURN: { | 348 *dst_alpha_scan = src_alpha; |
| 90 if (src_color == 0) { | 349 } |
| 91 return src_color; | 350 dest_scan++; |
| 92 } | 351 dst_alpha_scan++; |
| 93 int result = (255 - back_color) * 255 / src_color; | 352 src_scan += 3; |
| 94 if (result > 255) { | 353 continue; |
| 95 result = 255; | 354 } |
| 96 } | 355 FX_BYTE src_alpha = *src_alpha_scan++; |
| 97 return 255 - result; | 356 if (clip_scan) { |
| 357 src_alpha = clip_scan[col] * src_alpha / 255; |
| 358 } |
| 359 if (src_alpha == 0) { |
| 360 dest_scan++; |
| 361 dst_alpha_scan++; |
| 362 src_scan += 3; |
| 363 continue; |
| 364 } |
| 365 *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); |
| 366 int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); |
| 367 FX_BYTE gray; |
| 368 if (pIccTransform) { |
| 369 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 370 } else { |
| 371 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 372 } |
| 373 if (bNonseparableBlend) { |
| 374 blended_color = |
| 375 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 376 } |
| 377 gray = bNonseparableBlend ? blended_color |
| 378 : _BLEND(blend_type, *dest_scan, gray); |
| 379 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 380 dest_scan++; |
| 381 dst_alpha_scan++; |
| 382 src_scan += 3; |
| 383 } |
| 384 } else |
| 385 for (int col = 0; col < pixel_count; col++) { |
| 386 FX_BYTE back_alpha = *dst_alpha_scan; |
| 387 if (back_alpha == 0) { |
| 388 int src_alpha = src_scan[3]; |
| 389 if (clip_scan) { |
| 390 src_alpha = clip_scan[col] * src_alpha / 255; |
| 391 } |
| 392 if (src_alpha) { |
| 393 if (pIccTransform) { |
| 394 pIccModule->TranslateScanline( |
| 395 pIccTransform, dest_scan, src_scan, 1); |
| 396 } else { |
| 397 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 98 } | 398 } |
| 99 case FXDIB_BLEND_HARDLIGHT: | 399 *dst_alpha_scan = src_alpha; |
| 100 if (src_color < 128) { | 400 } |
| 101 return (src_color * back_color * 2) / 255; | 401 dest_scan++; |
| 102 } | 402 dst_alpha_scan++; |
| 103 return _BLEND(FXDIB_BLEND_SCREEN, back_color, 2 * src_color - 255); | 403 src_scan += 4; |
| 104 case FXDIB_BLEND_SOFTLIGHT: { | 404 continue; |
| 105 if (src_color < 128) { | 405 } |
| 106 return back_color - (255 - 2 * src_color) * back_color * (25
5 - back_color) / 255 / 255; | 406 FX_BYTE src_alpha = src_scan[3]; |
| 107 } | 407 if (clip_scan) { |
| 108 return back_color + (2 * src_color - 255) * (_color_sqrt[back_co
lor] - back_color) / 255; | 408 src_alpha = clip_scan[col] * src_alpha / 255; |
| 109 } | 409 } |
| 110 case FXDIB_BLEND_DIFFERENCE: | 410 if (src_alpha == 0) { |
| 111 return back_color < src_color ? src_color - back_color : back_color
- src_color; | 411 dest_scan++; |
| 112 case FXDIB_BLEND_EXCLUSION: | 412 dst_alpha_scan++; |
| 113 return back_color + src_color - 2 * back_color * src_color / 255; | 413 src_scan += 4; |
| 114 } | 414 continue; |
| 115 return src_color; | 415 } |
| 116 } | 416 *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); |
| 117 struct _RGB { | 417 int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); |
| 118 int red; | 418 FX_BYTE gray; |
| 119 int green; | 419 if (pIccTransform) { |
| 120 int blue; | 420 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 121 }; | |
| 122 static inline int _Lum(_RGB color) | |
| 123 { | |
| 124 return (color.red * 30 + color.green * 59 + color.blue * 11) / 100; | |
| 125 } | |
| 126 static _RGB _ClipColor(_RGB color) | |
| 127 { | |
| 128 int l = _Lum(color); | |
| 129 int n = color.red; | |
| 130 if (color.green < n) { | |
| 131 n = color.green; | |
| 132 } | |
| 133 if (color.blue < n) { | |
| 134 n = color.blue; | |
| 135 } | |
| 136 int x = color.red; | |
| 137 if (color.green > x) { | |
| 138 x = color.green; | |
| 139 } | |
| 140 if (color.blue > x) { | |
| 141 x = color.blue; | |
| 142 } | |
| 143 if (n < 0) { | |
| 144 color.red = l + ((color.red - l) * l / (l - n)); | |
| 145 color.green = l + ((color.green - l) * l / (l - n)); | |
| 146 color.blue = l + ((color.blue - l) * l / (l - n)); | |
| 147 } | |
| 148 if (x > 255) { | |
| 149 color.red = l + ((color.red - l) * (255 - l) / (x - l)); | |
| 150 color.green = l + ((color.green - l) * (255 - l) / (x - l)); | |
| 151 color.blue = l + ((color.blue - l) * (255 - l) / (x - l)); | |
| 152 } | |
| 153 return color; | |
| 154 } | |
| 155 static _RGB _SetLum(_RGB color, int l) | |
| 156 { | |
| 157 int d = l - _Lum(color); | |
| 158 color.red += d; | |
| 159 color.green += d; | |
| 160 color.blue += d; | |
| 161 return _ClipColor(color); | |
| 162 } | |
| 163 static int _Sat(_RGB color) | |
| 164 { | |
| 165 int n = color.red; | |
| 166 if (color.green < n) { | |
| 167 n = color.green; | |
| 168 } | |
| 169 if (color.blue < n) { | |
| 170 n = color.blue; | |
| 171 } | |
| 172 int x = color.red; | |
| 173 if (color.green > x) { | |
| 174 x = color.green; | |
| 175 } | |
| 176 if (color.blue > x) { | |
| 177 x = color.blue; | |
| 178 } | |
| 179 return x - n; | |
| 180 } | |
| 181 static _RGB _SetSat(_RGB color, int s) | |
| 182 { | |
| 183 int* max = &color.red; | |
| 184 int* mid = &color.red; | |
| 185 int* min = &color.red; | |
| 186 if (color.green > *max) { | |
| 187 max = &color.green; | |
| 188 } | |
| 189 if (color.blue > *max) { | |
| 190 max = &color.blue; | |
| 191 } | |
| 192 if (color.green < *min) { | |
| 193 min = &color.green; | |
| 194 } | |
| 195 if (color.blue < *min) { | |
| 196 min = &color.blue; | |
| 197 } | |
| 198 if (*max == *min) { | |
| 199 color.red = 0; | |
| 200 color.green = 0; | |
| 201 color.blue = 0; | |
| 202 return color; | |
| 203 } | |
| 204 if (max == &color.red) { | |
| 205 if (min == &color.green) { | |
| 206 mid = &color.blue; | |
| 207 } else { | 421 } else { |
| 208 mid = &color.green; | 422 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 209 } | 423 } |
| 210 } else if (max == &color.green) { | 424 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 211 if (min == &color.red) { | 425 dest_scan++; |
| 212 mid = &color.blue; | 426 dst_alpha_scan++; |
| 213 } else { | |
| 214 mid = &color.red; | |
| 215 } | |
| 216 } else { | |
| 217 if (min == &color.green) { | |
| 218 mid = &color.red; | |
| 219 } else { | |
| 220 mid = &color.green; | |
| 221 } | |
| 222 } | |
| 223 if (*max > *min) { | |
| 224 *mid = (*mid - *min) * s / (*max - *min); | |
| 225 *max = s; | |
| 226 *min = 0; | |
| 227 } | |
| 228 return color; | |
| 229 } | |
| 230 void _RGB_Blend(int blend_mode, FX_LPCBYTE src_scan, FX_BYTE* dest_scan, int res
ults[3]) | |
| 231 { | |
| 232 _RGB src, back, result; | |
| 233 src.red = src_scan[2]; | |
| 234 src.green = src_scan[1]; | |
| 235 src.blue = src_scan[0]; | |
| 236 back.red = dest_scan[2]; | |
| 237 back.green = dest_scan[1]; | |
| 238 back.blue = dest_scan[0]; | |
| 239 switch (blend_mode) { | |
| 240 case FXDIB_BLEND_HUE: | |
| 241 result = _SetLum(_SetSat(src, _Sat(back)), _Lum(back)); | |
| 242 break; | |
| 243 case FXDIB_BLEND_SATURATION: | |
| 244 result = _SetLum(_SetSat(back, _Sat(src)), _Lum(back)); | |
| 245 break; | |
| 246 case FXDIB_BLEND_COLOR: | |
| 247 result = _SetLum(src, _Lum(back)); | |
| 248 break; | |
| 249 case FXDIB_BLEND_LUMINOSITY: | |
| 250 result = _SetLum(back, _Lum(src)); | |
| 251 break; | |
| 252 } | |
| 253 results[0] = result.blue; | |
| 254 results[1] = result.green; | |
| 255 results[2] = result.red; | |
| 256 } | |
| 257 inline void _CompositeRow_Argb2Mask(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, in
t pixel_count, FX_LPCBYTE clip_scan) | |
| 258 { | |
| 259 src_scan += 3; | |
| 260 for (int col = 0; col < pixel_count; col ++) { | |
| 261 int src_alpha = *src_scan; | |
| 262 if (clip_scan) { | |
| 263 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 264 } | |
| 265 FX_BYTE back_alpha = *dest_scan; | |
| 266 if (!back_alpha) { | |
| 267 *dest_scan = src_alpha; | |
| 268 } else if (src_alpha) { | |
| 269 *dest_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; | |
| 270 } | |
| 271 dest_scan ++; | |
| 272 src_scan += 4; | 427 src_scan += 4; |
| 273 } | 428 } |
| 274 } | 429 return; |
| 275 void _CompositeRow_Rgba2Mask(FX_LPBYTE dest_scan, FX_LPCBYTE src_alpha_scan, int
pixel_count, FX_LPCBYTE clip_scan) | 430 } |
| 276 { | 431 if (src_alpha_scan) { |
| 277 for (int col = 0; col < pixel_count; col ++) { | 432 for (int col = 0; col < pixel_count; col++) { |
| 433 FX_BYTE back_alpha = *dst_alpha_scan; |
| 434 if (back_alpha == 0) { |
| 278 int src_alpha = *src_alpha_scan++; | 435 int src_alpha = *src_alpha_scan++; |
| 279 if (clip_scan) { | 436 if (clip_scan) { |
| 280 src_alpha = clip_scan[col] * src_alpha / 255; | 437 src_alpha = clip_scan[col] * src_alpha / 255; |
| 281 } | 438 } |
| 282 FX_BYTE back_alpha = *dest_scan; | 439 if (src_alpha) { |
| 283 if (!back_alpha) { | 440 if (pIccTransform) { |
| 284 *dest_scan = src_alpha; | 441 pIccModule->TranslateScanline( |
| 285 } else if (src_alpha) { | 442 pIccTransform, dest_scan, src_scan, 1); |
| 286 *dest_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; | 443 } else { |
| 287 } | 444 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 288 dest_scan ++; | 445 } |
| 289 } | 446 *dst_alpha_scan = src_alpha; |
| 290 } | 447 } |
| 291 void _CompositeRow_Rgb2Mask(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int width,
FX_LPCBYTE clip_scan) | 448 dest_scan++; |
| 292 { | 449 dst_alpha_scan++; |
| 450 src_scan += 3; |
| 451 continue; |
| 452 } |
| 453 FX_BYTE src_alpha = *src_alpha_scan++; |
| 454 if (clip_scan) { |
| 455 src_alpha = clip_scan[col] * src_alpha / 255; |
| 456 } |
| 457 if (src_alpha == 0) { |
| 458 dest_scan++; |
| 459 dst_alpha_scan++; |
| 460 src_scan += 3; |
| 461 continue; |
| 462 } |
| 463 *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); |
| 464 int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); |
| 465 FX_BYTE gray; |
| 466 if (pIccTransform) { |
| 467 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 468 } else { |
| 469 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 470 } |
| 471 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 472 dest_scan++; |
| 473 dst_alpha_scan++; |
| 474 src_scan += 3; |
| 475 } |
| 476 } else |
| 477 for (int col = 0; col < pixel_count; col++) { |
| 478 FX_BYTE back_alpha = *dst_alpha_scan; |
| 479 if (back_alpha == 0) { |
| 480 int src_alpha = src_scan[3]; |
| 481 if (clip_scan) { |
| 482 src_alpha = clip_scan[col] * src_alpha / 255; |
| 483 } |
| 484 if (src_alpha) { |
| 485 if (pIccTransform) { |
| 486 pIccModule->TranslateScanline( |
| 487 pIccTransform, dest_scan, src_scan, 1); |
| 488 } else { |
| 489 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 490 } |
| 491 *dst_alpha_scan = src_alpha; |
| 492 } |
| 493 dest_scan++; |
| 494 dst_alpha_scan++; |
| 495 src_scan += 4; |
| 496 continue; |
| 497 } |
| 498 FX_BYTE src_alpha = src_scan[3]; |
| 499 if (clip_scan) { |
| 500 src_alpha = clip_scan[col] * src_alpha / 255; |
| 501 } |
| 502 if (src_alpha == 0) { |
| 503 dest_scan++; |
| 504 dst_alpha_scan++; |
| 505 src_scan += 4; |
| 506 continue; |
| 507 } |
| 508 *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); |
| 509 int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); |
| 510 FX_BYTE gray; |
| 511 if (pIccTransform) { |
| 512 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 513 } else { |
| 514 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 515 } |
| 516 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 517 dest_scan++; |
| 518 dst_alpha_scan++; |
| 519 src_scan += 4; |
| 520 } |
| 521 } |
| 522 inline void _CompositeRow_Argb2Gray(FX_LPBYTE dest_scan, |
| 523 FX_LPCBYTE src_scan, |
| 524 int pixel_count, |
| 525 int blend_type, |
| 526 FX_LPCBYTE clip_scan, |
| 527 FX_LPCBYTE src_alpha_scan, |
| 528 void* pIccTransform) { |
| 529 ICodec_IccModule* pIccModule = NULL; |
| 530 FX_BYTE gray; |
| 531 if (pIccTransform) { |
| 532 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 533 } |
| 534 if (blend_type) { |
| 535 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 536 int blended_color; |
| 537 if (src_alpha_scan) { |
| 538 for (int col = 0; col < pixel_count; col++) { |
| 539 int src_alpha = *src_alpha_scan++; |
| 540 if (clip_scan) { |
| 541 src_alpha = clip_scan[col] * src_alpha / 255; |
| 542 } |
| 543 if (src_alpha) { |
| 544 if (pIccTransform) { |
| 545 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 546 } else { |
| 547 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 548 } |
| 549 if (bNonseparableBlend) { |
| 550 blended_color = |
| 551 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 552 } |
| 553 gray = bNonseparableBlend ? blended_color |
| 554 : _BLEND(blend_type, *dest_scan, gray); |
| 555 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 556 } |
| 557 dest_scan++; |
| 558 src_scan += 3; |
| 559 } |
| 560 } else |
| 561 for (int col = 0; col < pixel_count; col++) { |
| 562 int src_alpha = src_scan[3]; |
| 563 if (clip_scan) { |
| 564 src_alpha = clip_scan[col] * src_alpha / 255; |
| 565 } |
| 566 if (src_alpha) { |
| 567 if (pIccTransform) { |
| 568 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 569 } else { |
| 570 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 571 } |
| 572 if (bNonseparableBlend) { |
| 573 blended_color = |
| 574 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 575 } |
| 576 gray = bNonseparableBlend ? blended_color |
| 577 : _BLEND(blend_type, *dest_scan, gray); |
| 578 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 579 } |
| 580 dest_scan++; |
| 581 src_scan += 4; |
| 582 } |
| 583 return; |
| 584 } |
| 585 if (src_alpha_scan) { |
| 586 for (int col = 0; col < pixel_count; col++) { |
| 587 int src_alpha = *src_alpha_scan++; |
| 588 if (clip_scan) { |
| 589 src_alpha = clip_scan[col] * src_alpha / 255; |
| 590 } |
| 591 if (src_alpha) { |
| 592 if (pIccTransform) { |
| 593 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 594 } else { |
| 595 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 596 } |
| 597 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 598 } |
| 599 dest_scan++; |
| 600 src_scan += 3; |
| 601 } |
| 602 } else |
| 603 for (int col = 0; col < pixel_count; col++) { |
| 604 int src_alpha = src_scan[3]; |
| 605 if (clip_scan) { |
| 606 src_alpha = clip_scan[col] * src_alpha / 255; |
| 607 } |
| 608 if (src_alpha) { |
| 609 if (pIccTransform) { |
| 610 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 611 } else { |
| 612 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 613 } |
| 614 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 615 } |
| 616 dest_scan++; |
| 617 src_scan += 4; |
| 618 } |
| 619 } |
| 620 inline void _CompositeRow_Rgb2Gray(FX_LPBYTE dest_scan, |
| 621 FX_LPCBYTE src_scan, |
| 622 int src_Bpp, |
| 623 int pixel_count, |
| 624 int blend_type, |
| 625 FX_LPCBYTE clip_scan, |
| 626 void* pIccTransform) { |
| 627 ICodec_IccModule* pIccModule = NULL; |
| 628 FX_BYTE gray; |
| 629 if (pIccTransform) { |
| 630 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 631 } |
| 632 if (blend_type) { |
| 633 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 634 int blended_color; |
| 635 for (int col = 0; col < pixel_count; col++) { |
| 636 if (pIccTransform) { |
| 637 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 638 } else { |
| 639 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 640 } |
| 641 if (bNonseparableBlend) { |
| 642 blended_color = |
| 643 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 644 } |
| 645 gray = bNonseparableBlend ? blended_color |
| 646 : _BLEND(blend_type, *dest_scan, gray); |
| 647 if (clip_scan && clip_scan[col] < 255) { |
| 648 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); |
| 649 } else { |
| 650 *dest_scan = gray; |
| 651 } |
| 652 dest_scan++; |
| 653 src_scan += src_Bpp; |
| 654 } |
| 655 return; |
| 656 } |
| 657 for (int col = 0; col < pixel_count; col++) { |
| 658 if (pIccTransform) { |
| 659 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 660 } else { |
| 661 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 662 } |
| 663 if (clip_scan && clip_scan[col] < 255) { |
| 664 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); |
| 665 } else { |
| 666 *dest_scan = gray; |
| 667 } |
| 668 dest_scan++; |
| 669 src_scan += src_Bpp; |
| 670 } |
| 671 } |
| 672 void _CompositeRow_Rgb2Graya(FX_LPBYTE dest_scan, |
| 673 FX_LPCBYTE src_scan, |
| 674 int src_Bpp, |
| 675 int pixel_count, |
| 676 int blend_type, |
| 677 FX_LPCBYTE clip_scan, |
| 678 FX_LPBYTE dest_alpha_scan, |
| 679 void* pIccTransform) { |
| 680 ICodec_IccModule* pIccModule = NULL; |
| 681 if (pIccTransform) { |
| 682 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 683 } |
| 684 if (blend_type) { |
| 685 int blended_color; |
| 686 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 687 for (int col = 0; col < pixel_count; col++) { |
| 688 int back_alpha = *dest_alpha_scan; |
| 689 if (back_alpha == 0) { |
| 690 if (pIccTransform) { |
| 691 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, 1); |
| 692 } else { |
| 693 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 694 } |
| 695 dest_scan++; |
| 696 dest_alpha_scan++; |
| 697 src_scan += src_Bpp; |
| 698 continue; |
| 699 } |
| 700 int src_alpha = 255; |
| 701 if (clip_scan) { |
| 702 src_alpha = clip_scan[col]; |
| 703 } |
| 704 if (src_alpha == 0) { |
| 705 dest_scan++; |
| 706 dest_alpha_scan++; |
| 707 src_scan += src_Bpp; |
| 708 continue; |
| 709 } |
| 710 FX_BYTE dest_alpha = |
| 711 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 712 *dest_alpha_scan++ = dest_alpha; |
| 713 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 714 FX_BYTE gray; |
| 715 if (pIccTransform) { |
| 716 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 717 } else { |
| 718 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 719 } |
| 720 if (bNonseparableBlend) { |
| 721 blended_color = |
| 722 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 723 } |
| 724 gray = bNonseparableBlend ? blended_color |
| 725 : _BLEND(blend_type, *dest_scan, gray); |
| 726 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 727 dest_scan++; |
| 728 src_scan += src_Bpp; |
| 729 } |
| 730 return; |
| 731 } |
| 732 for (int col = 0; col < pixel_count; col++) { |
| 733 int src_alpha = 255; |
| 293 if (clip_scan) { | 734 if (clip_scan) { |
| 294 for (int i = 0; i < width; i ++) { | 735 src_alpha = clip_scan[col]; |
| 295 *dest_scan = FXDIB_ALPHA_UNION(*dest_scan, *clip_scan); | 736 } |
| 296 dest_scan ++; | 737 if (src_alpha == 255) { |
| 297 clip_scan ++; | 738 if (pIccTransform) { |
| 298 } | 739 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, 1); |
| 299 } else { | 740 } else { |
| 300 FXSYS_memset8(dest_scan, 0xff, width); | 741 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 301 } | 742 } |
| 302 } | 743 dest_scan++; |
| 303 void _CompositeRow_Argb2Graya(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int pixe
l_count, int blend_type, FX_LPCBYTE clip_scan, | 744 *dest_alpha_scan++ = 255; |
| 304 FX_LPCBYTE src_alpha_scan, FX_LPBYTE dst_alpha_sca
n, void* pIccTransform) | 745 src_scan += src_Bpp; |
| 305 { | 746 continue; |
| 306 ICodec_IccModule* pIccModule = NULL; | 747 } |
| 307 if (pIccTransform) { | 748 if (src_alpha == 0) { |
| 308 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | 749 dest_scan++; |
| 309 } | 750 dest_alpha_scan++; |
| 310 if (blend_type) { | 751 src_scan += src_Bpp; |
| 311 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 752 continue; |
| 312 int blended_color; | 753 } |
| 313 if (src_alpha_scan) { | 754 int back_alpha = *dest_alpha_scan; |
| 314 for (int col = 0; col < pixel_count; col ++) { | 755 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 315 FX_BYTE back_alpha = *dst_alpha_scan; | 756 *dest_alpha_scan++ = dest_alpha; |
| 316 if (back_alpha == 0) { | 757 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 317 int src_alpha = *src_alpha_scan++; | |
| 318 if (clip_scan) { | |
| 319 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 320 } | |
| 321 if (src_alpha) { | |
| 322 if (pIccTransform) { | |
| 323 pIccModule->TranslateScanline(pIccTransform, dest_sc
an, src_scan, 1); | |
| 324 } else { | |
| 325 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *
src_scan); | |
| 326 } | |
| 327 *dst_alpha_scan = src_alpha; | |
| 328 } | |
| 329 dest_scan ++; | |
| 330 dst_alpha_scan ++; | |
| 331 src_scan += 3; | |
| 332 continue; | |
| 333 } | |
| 334 FX_BYTE src_alpha = *src_alpha_scan++; | |
| 335 if (clip_scan) { | |
| 336 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 337 } | |
| 338 if (src_alpha == 0) { | |
| 339 dest_scan ++; | |
| 340 dst_alpha_scan ++; | |
| 341 src_scan += 3; | |
| 342 continue; | |
| 343 } | |
| 344 *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); | |
| 345 int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); | |
| 346 FX_BYTE gray; | |
| 347 if (pIccTransform) { | |
| 348 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan
, 1); | |
| 349 } else { | |
| 350 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 351 } | |
| 352 if (bNonseparableBlend) { | |
| 353 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? gray
: *dest_scan; | |
| 354 } | |
| 355 gray = bNonseparableBlend ? blended_color : _BLEND(blend_type, *
dest_scan, gray); | |
| 356 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 357 dest_scan ++; | |
| 358 dst_alpha_scan++; | |
| 359 src_scan += 3; | |
| 360 } | |
| 361 } else | |
| 362 for (int col = 0; col < pixel_count; col ++) { | |
| 363 FX_BYTE back_alpha = *dst_alpha_scan; | |
| 364 if (back_alpha == 0) { | |
| 365 int src_alpha = src_scan[3]; | |
| 366 if (clip_scan) { | |
| 367 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 368 } | |
| 369 if (src_alpha) { | |
| 370 if (pIccTransform) { | |
| 371 pIccModule->TranslateScanline(pIccTransform, dest_sc
an, src_scan, 1); | |
| 372 } else { | |
| 373 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *
src_scan); | |
| 374 } | |
| 375 *dst_alpha_scan = src_alpha; | |
| 376 } | |
| 377 dest_scan ++; | |
| 378 dst_alpha_scan ++; | |
| 379 src_scan += 4; | |
| 380 continue; | |
| 381 } | |
| 382 FX_BYTE src_alpha = src_scan[3]; | |
| 383 if (clip_scan) { | |
| 384 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 385 } | |
| 386 if (src_alpha == 0) { | |
| 387 dest_scan ++; | |
| 388 dst_alpha_scan ++; | |
| 389 src_scan += 4; | |
| 390 continue; | |
| 391 } | |
| 392 *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); | |
| 393 int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); | |
| 394 FX_BYTE gray; | |
| 395 if (pIccTransform) { | |
| 396 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan
, 1); | |
| 397 } else { | |
| 398 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 399 } | |
| 400 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 401 dest_scan ++; | |
| 402 dst_alpha_scan++; | |
| 403 src_scan += 4; | |
| 404 } | |
| 405 return; | |
| 406 } | |
| 407 if (src_alpha_scan) { | |
| 408 for (int col = 0; col < pixel_count; col ++) { | |
| 409 FX_BYTE back_alpha = *dst_alpha_scan; | |
| 410 if (back_alpha == 0) { | |
| 411 int src_alpha = *src_alpha_scan++; | |
| 412 if (clip_scan) { | |
| 413 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 414 } | |
| 415 if (src_alpha) { | |
| 416 if (pIccTransform) { | |
| 417 pIccModule->TranslateScanline(pIccTransform, dest_scan,
src_scan, 1); | |
| 418 } else { | |
| 419 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_
scan); | |
| 420 } | |
| 421 *dst_alpha_scan = src_alpha; | |
| 422 } | |
| 423 dest_scan ++; | |
| 424 dst_alpha_scan ++; | |
| 425 src_scan += 3; | |
| 426 continue; | |
| 427 } | |
| 428 FX_BYTE src_alpha = *src_alpha_scan++; | |
| 429 if (clip_scan) { | |
| 430 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 431 } | |
| 432 if (src_alpha == 0) { | |
| 433 dest_scan ++; | |
| 434 dst_alpha_scan ++; | |
| 435 src_scan += 3; | |
| 436 continue; | |
| 437 } | |
| 438 *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); | |
| 439 int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); | |
| 440 FX_BYTE gray; | |
| 441 if (pIccTransform) { | |
| 442 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1)
; | |
| 443 } else { | |
| 444 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 445 } | |
| 446 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 447 dest_scan ++; | |
| 448 dst_alpha_scan++; | |
| 449 src_scan += 3; | |
| 450 } | |
| 451 } else | |
| 452 for (int col = 0; col < pixel_count; col ++) { | |
| 453 FX_BYTE back_alpha = *dst_alpha_scan; | |
| 454 if (back_alpha == 0) { | |
| 455 int src_alpha = src_scan[3]; | |
| 456 if (clip_scan) { | |
| 457 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 458 } | |
| 459 if (src_alpha) { | |
| 460 if (pIccTransform) { | |
| 461 pIccModule->TranslateScanline(pIccTransform, dest_scan,
src_scan, 1); | |
| 462 } else { | |
| 463 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_
scan); | |
| 464 } | |
| 465 *dst_alpha_scan = src_alpha; | |
| 466 } | |
| 467 dest_scan ++; | |
| 468 dst_alpha_scan ++; | |
| 469 src_scan += 4; | |
| 470 continue; | |
| 471 } | |
| 472 FX_BYTE src_alpha = src_scan[3]; | |
| 473 if (clip_scan) { | |
| 474 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 475 } | |
| 476 if (src_alpha == 0) { | |
| 477 dest_scan ++; | |
| 478 dst_alpha_scan ++; | |
| 479 src_scan += 4; | |
| 480 continue; | |
| 481 } | |
| 482 *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); | |
| 483 int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); | |
| 484 FX_BYTE gray; | |
| 485 if (pIccTransform) { | |
| 486 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1)
; | |
| 487 } else { | |
| 488 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 489 } | |
| 490 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 491 dest_scan ++; | |
| 492 dst_alpha_scan++; | |
| 493 src_scan += 4; | |
| 494 } | |
| 495 } | |
| 496 inline void _CompositeRow_Argb2Gray(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, in
t pixel_count, | |
| 497 int blend_type, FX_LPCBYTE clip_scan, | |
| 498 FX_LPCBYTE src_alpha_scan, void* pIccTransfo
rm) | |
| 499 { | |
| 500 ICodec_IccModule* pIccModule = NULL; | |
| 501 FX_BYTE gray; | 758 FX_BYTE gray; |
| 502 if (pIccTransform) { | 759 if (pIccTransform) { |
| 503 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | 760 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 504 } | 761 } else { |
| 505 if (blend_type) { | 762 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 506 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 763 } |
| 507 int blended_color; | 764 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 508 if (src_alpha_scan) { | 765 dest_scan++; |
| 509 for (int col = 0; col < pixel_count; col ++) { | 766 src_scan += src_Bpp; |
| 510 int src_alpha = *src_alpha_scan++; | 767 } |
| 511 if (clip_scan) { | 768 } |
| 512 src_alpha = clip_scan[col] * src_alpha / 255; | 769 void _CompositeRow_Argb2Argb(FX_LPBYTE dest_scan, |
| 513 } | 770 FX_LPCBYTE src_scan, |
| 514 if (src_alpha) { | 771 int pixel_count, |
| 515 if (pIccTransform) { | 772 int blend_type, |
| 516 pIccModule->TranslateScanline(pIccTransform, &gray, src_
scan, 1); | 773 FX_LPCBYTE clip_scan, |
| 517 } else { | 774 FX_LPBYTE dest_alpha_scan, |
| 518 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | 775 FX_LPCBYTE src_alpha_scan) { |
| 519 } | 776 int blended_colors[3]; |
| 520 if (bNonseparableBlend) { | 777 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 521 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? g
ray : *dest_scan; | 778 if (dest_alpha_scan == NULL) { |
| 522 } | 779 if (src_alpha_scan == NULL) { |
| 523 gray = bNonseparableBlend ? blended_color : _BLEND(blend_typ
e, *dest_scan, gray); | 780 FX_BYTE back_alpha = 0; |
| 524 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | 781 for (int col = 0; col < pixel_count; col++) { |
| 525 } | 782 back_alpha = dest_scan[3]; |
| 526 dest_scan ++; | 783 if (back_alpha == 0) { |
| 527 src_scan += 3; | 784 if (clip_scan) { |
| 528 } | 785 int src_alpha = clip_scan[col] * src_scan[3] / 255; |
| 529 } else | 786 FXARGB_SETDIB( |
| 530 for (int col = 0; col < pixel_count; col ++) { | 787 dest_scan, |
| 531 int src_alpha = src_scan[3]; | 788 (FXARGB_GETDIB(src_scan) & 0xffffff) | (src_alpha << 24)); |
| 532 if (clip_scan) { | 789 } else { |
| 533 src_alpha = clip_scan[col] * src_alpha / 255; | 790 FXARGB_COPY(dest_scan, src_scan); |
| 534 } | 791 } |
| 535 if (src_alpha) { | 792 dest_scan += 4; |
| 536 if (pIccTransform) { | 793 src_scan += 4; |
| 537 pIccModule->TranslateScanline(pIccTransform, &gray, src_
scan, 1); | 794 continue; |
| 538 } else { | 795 } |
| 539 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | 796 FX_BYTE src_alpha; |
| 540 } | 797 if (clip_scan == NULL) { |
| 541 if (bNonseparableBlend) { | 798 src_alpha = src_scan[3]; |
| 542 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? g
ray : *dest_scan; | 799 } else { |
| 543 } | 800 src_alpha = clip_scan[col] * src_scan[3] / 255; |
| 544 gray = bNonseparableBlend ? blended_color : _BLEND(blend_typ
e, *dest_scan, gray); | 801 } |
| 545 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | 802 if (src_alpha == 0) { |
| 546 } | 803 dest_scan += 4; |
| 547 dest_scan ++; | 804 src_scan += 4; |
| 548 src_scan += 4; | 805 continue; |
| 549 } | 806 } |
| 550 return; | 807 FX_BYTE dest_alpha = |
| 551 } | 808 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 809 dest_scan[3] = dest_alpha; |
| 810 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 811 if (bNonseparableBlend) { |
| 812 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 813 } |
| 814 for (int color = 0; color < 3; color++) { |
| 815 if (blend_type) { |
| 816 int blended = bNonseparableBlend |
| 817 ? blended_colors[color] |
| 818 : _BLEND(blend_type, *dest_scan, *src_scan); |
| 819 blended = FXDIB_ALPHA_MERGE(*src_scan, blended, back_alpha); |
| 820 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 821 } else { |
| 822 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio); |
| 823 } |
| 824 dest_scan++; |
| 825 src_scan++; |
| 826 } |
| 827 dest_scan++; |
| 828 src_scan++; |
| 829 } |
| 830 } else { |
| 831 for (int col = 0; col < pixel_count; col++) { |
| 832 FX_BYTE back_alpha = dest_scan[3]; |
| 833 if (back_alpha == 0) { |
| 834 if (clip_scan) { |
| 835 int src_alpha = clip_scan[col] * (*src_alpha_scan) / 255; |
| 836 FXARGB_SETDIB( |
| 837 dest_scan, |
| 838 FXARGB_MAKE( |
| 839 (src_alpha << 24), src_scan[2], src_scan[1], *src_scan)); |
| 840 } else { |
| 841 FXARGB_SETDIB(dest_scan, |
| 842 FXARGB_MAKE((*src_alpha_scan << 24), |
| 843 src_scan[2], |
| 844 src_scan[1], |
| 845 *src_scan)); |
| 846 } |
| 847 dest_scan += 4; |
| 848 src_scan += 3; |
| 849 src_alpha_scan++; |
| 850 continue; |
| 851 } |
| 852 FX_BYTE src_alpha; |
| 853 if (clip_scan == NULL) { |
| 854 src_alpha = *src_alpha_scan++; |
| 855 } else { |
| 856 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255; |
| 857 } |
| 858 if (src_alpha == 0) { |
| 859 dest_scan += 4; |
| 860 src_scan += 3; |
| 861 continue; |
| 862 } |
| 863 FX_BYTE dest_alpha = |
| 864 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 865 dest_scan[3] = dest_alpha; |
| 866 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 867 if (bNonseparableBlend) { |
| 868 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 869 } |
| 870 for (int color = 0; color < 3; color++) { |
| 871 if (blend_type) { |
| 872 int blended = bNonseparableBlend |
| 873 ? blended_colors[color] |
| 874 : _BLEND(blend_type, *dest_scan, *src_scan); |
| 875 blended = FXDIB_ALPHA_MERGE(*src_scan, blended, back_alpha); |
| 876 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 877 } else { |
| 878 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio); |
| 879 } |
| 880 dest_scan++; |
| 881 src_scan++; |
| 882 } |
| 883 dest_scan++; |
| 884 } |
| 885 } |
| 886 } else { |
| 552 if (src_alpha_scan) { | 887 if (src_alpha_scan) { |
| 553 for (int col = 0; col < pixel_count; col ++) { | 888 for (int col = 0; col < pixel_count; col++) { |
| 554 int src_alpha = *src_alpha_scan++; | 889 FX_BYTE back_alpha = *dest_alpha_scan; |
| 555 if (clip_scan) { | 890 if (back_alpha == 0) { |
| 556 src_alpha = clip_scan[col] * src_alpha / 255; | 891 if (clip_scan) { |
| 557 } | 892 int src_alpha = clip_scan[col] * (*src_alpha_scan) / 255; |
| 558 if (src_alpha) { | 893 *dest_alpha_scan = src_alpha; |
| 559 if (pIccTransform) { | |
| 560 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan
, 1); | |
| 561 } else { | |
| 562 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 563 } | |
| 564 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | |
| 565 } | |
| 566 dest_scan ++; | |
| 567 src_scan += 3; | |
| 568 } | |
| 569 } else | |
| 570 for (int col = 0; col < pixel_count; col ++) { | |
| 571 int src_alpha = src_scan[3]; | |
| 572 if (clip_scan) { | |
| 573 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 574 } | |
| 575 if (src_alpha) { | |
| 576 if (pIccTransform) { | |
| 577 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan
, 1); | |
| 578 } else { | |
| 579 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 580 } | |
| 581 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | |
| 582 } | |
| 583 dest_scan ++; | |
| 584 src_scan += 4; | |
| 585 } | |
| 586 } | |
| 587 inline void _CompositeRow_Rgb2Gray(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int
src_Bpp, int pixel_count, | |
| 588 int blend_type, FX_LPCBYTE clip_scan, | |
| 589 void* pIccTransform) | |
| 590 { | |
| 591 ICodec_IccModule* pIccModule = NULL; | |
| 592 FX_BYTE gray; | |
| 593 if (pIccTransform) { | |
| 594 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | |
| 595 } | |
| 596 if (blend_type) { | |
| 597 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 598 int blended_color; | |
| 599 for (int col = 0; col < pixel_count; col ++) { | |
| 600 if (pIccTransform) { | |
| 601 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1)
; | |
| 602 } else { | |
| 603 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 604 } | |
| 605 if (bNonseparableBlend) { | |
| 606 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *d
est_scan; | |
| 607 } | |
| 608 gray = bNonseparableBlend ? blended_color : _BLEND(blend_type, *dest
_scan, gray); | |
| 609 if (clip_scan && clip_scan[col] < 255) { | |
| 610 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col])
; | |
| 611 } else { | |
| 612 *dest_scan = gray; | |
| 613 } | |
| 614 dest_scan ++; | |
| 615 src_scan += src_Bpp; | |
| 616 } | |
| 617 return; | |
| 618 } | |
| 619 for (int col = 0; col < pixel_count; col ++) { | |
| 620 if (pIccTransform) { | |
| 621 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); | |
| 622 } else { | |
| 623 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 624 } | |
| 625 if (clip_scan && clip_scan[col] < 255) { | |
| 626 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); | |
| 627 } else { | |
| 628 *dest_scan = gray; | |
| 629 } | |
| 630 dest_scan ++; | |
| 631 src_scan += src_Bpp; | |
| 632 } | |
| 633 } | |
| 634 void _CompositeRow_Rgb2Graya(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int src_B
pp, int pixel_count, | |
| 635 int blend_type, FX_LPCBYTE clip_scan, | |
| 636 FX_LPBYTE dest_alpha_scan, void* pIccTransform) | |
| 637 { | |
| 638 ICodec_IccModule* pIccModule = NULL; | |
| 639 if (pIccTransform) { | |
| 640 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | |
| 641 } | |
| 642 if (blend_type) { | |
| 643 int blended_color; | |
| 644 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 645 for (int col = 0; col < pixel_count; col ++) { | |
| 646 int back_alpha = *dest_alpha_scan; | |
| 647 if (back_alpha == 0) { | |
| 648 if (pIccTransform) { | |
| 649 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_
scan, 1); | |
| 650 } else { | |
| 651 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan)
; | |
| 652 } | |
| 653 dest_scan ++; | |
| 654 dest_alpha_scan++; | |
| 655 src_scan += src_Bpp; | |
| 656 continue; | |
| 657 } | |
| 658 int src_alpha = 255; | |
| 659 if (clip_scan) { | |
| 660 src_alpha = clip_scan[col]; | |
| 661 } | |
| 662 if (src_alpha == 0) { | |
| 663 dest_scan ++; | |
| 664 dest_alpha_scan ++; | |
| 665 src_scan += src_Bpp; | |
| 666 continue; | |
| 667 } | |
| 668 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | |
| 669 *dest_alpha_scan++ = dest_alpha; | |
| 670 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 671 FX_BYTE gray; | |
| 672 if (pIccTransform) { | |
| 673 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1)
; | |
| 674 } else { | |
| 675 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 676 } | |
| 677 if (bNonseparableBlend) { | |
| 678 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *d
est_scan; | |
| 679 } | |
| 680 gray = bNonseparableBlend ? blended_color : _BLEND(blend_type, *dest
_scan, gray); | |
| 681 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 682 dest_scan ++; | |
| 683 src_scan += src_Bpp; | |
| 684 } | |
| 685 return; | |
| 686 } | |
| 687 for (int col = 0; col < pixel_count; col ++) { | |
| 688 int src_alpha = 255; | |
| 689 if (clip_scan) { | |
| 690 src_alpha = clip_scan[col]; | |
| 691 } | |
| 692 if (src_alpha == 255) { | |
| 693 if (pIccTransform) { | |
| 694 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan
, 1); | |
| 695 } else { | |
| 696 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 697 } | |
| 698 dest_scan ++; | |
| 699 *dest_alpha_scan++ = 255; | |
| 700 src_scan += src_Bpp; | |
| 701 continue; | |
| 702 } | |
| 703 if (src_alpha == 0) { | |
| 704 dest_scan ++; | |
| 705 dest_alpha_scan ++; | |
| 706 src_scan += src_Bpp; | |
| 707 continue; | |
| 708 } | |
| 709 int back_alpha = *dest_alpha_scan; | |
| 710 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 711 *dest_alpha_scan++ = dest_alpha; | |
| 712 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 713 FX_BYTE gray; | |
| 714 if (pIccTransform) { | |
| 715 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); | |
| 716 } else { | |
| 717 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | |
| 718 } | |
| 719 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 720 dest_scan ++; | |
| 721 src_scan += src_Bpp; | |
| 722 } | |
| 723 } | |
| 724 void _CompositeRow_Argb2Argb(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int pixel
_count, int blend_type, FX_LPCBYTE clip_scan, | |
| 725 FX_LPBYTE dest_alpha_scan, FX_LPCBYTE src_alpha_sca
n) | |
| 726 { | |
| 727 int blended_colors[3]; | |
| 728 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 729 if (dest_alpha_scan == NULL) { | |
| 730 if (src_alpha_scan == NULL) { | |
| 731 FX_BYTE back_alpha = 0; | |
| 732 for (int col = 0; col < pixel_count; col ++) { | |
| 733 back_alpha = dest_scan[3]; | |
| 734 if (back_alpha == 0) { | |
| 735 if (clip_scan) { | |
| 736 int src_alpha = clip_scan[col] * src_scan[3] / 255; | |
| 737 FXARGB_SETDIB(dest_scan, (FXARGB_GETDIB(src_scan) & 0xff
ffff) | (src_alpha << 24)); | |
| 738 } else { | |
| 739 FXARGB_COPY(dest_scan, src_scan); | |
| 740 } | |
| 741 dest_scan += 4; | |
| 742 src_scan += 4; | |
| 743 continue; | |
| 744 } | |
| 745 FX_BYTE src_alpha; | |
| 746 if (clip_scan == NULL) { | |
| 747 src_alpha = src_scan[3]; | |
| 748 } else { | |
| 749 src_alpha = clip_scan[col] * src_scan[3] / 255; | |
| 750 } | |
| 751 if (src_alpha == 0) { | |
| 752 dest_scan += 4; | |
| 753 src_scan += 4; | |
| 754 continue; | |
| 755 } | |
| 756 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_a
lpha / 255; | |
| 757 dest_scan[3] = dest_alpha; | |
| 758 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 759 if (bNonseparableBlend) { | |
| 760 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 761 } | |
| 762 for (int color = 0; color < 3; color ++) { | |
| 763 if (blend_type) { | |
| 764 int blended = bNonseparableBlend ? blended_colors[color]
: | |
| 765 _BLEND(blend_type, *dest_scan, *src_scan); | |
| 766 blended = FXDIB_ALPHA_MERGE(*src_scan, blended, back_alp
ha); | |
| 767 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alph
a_ratio); | |
| 768 } else { | |
| 769 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, al
pha_ratio); | |
| 770 } | |
| 771 dest_scan ++; | |
| 772 src_scan ++; | |
| 773 } | |
| 774 dest_scan ++; | |
| 775 src_scan ++; | |
| 776 } | |
| 777 } else { | |
| 778 for (int col = 0; col < pixel_count; col ++) { | |
| 779 FX_BYTE back_alpha = dest_scan[3]; | |
| 780 if (back_alpha == 0) { | |
| 781 if (clip_scan) { | |
| 782 int src_alpha = clip_scan[col] * (*src_alpha_scan) / 255
; | |
| 783 FXARGB_SETDIB(dest_scan, FXARGB_MAKE((src_alpha << 24),
src_scan[2], src_scan[1], *src_scan)); | |
| 784 } else { | |
| 785 FXARGB_SETDIB(dest_scan, FXARGB_MAKE((*src_alpha_scan <<
24), src_scan[2], src_scan[1], *src_scan)); | |
| 786 } | |
| 787 dest_scan += 4; | |
| 788 src_scan += 3; | |
| 789 src_alpha_scan ++; | |
| 790 continue; | |
| 791 } | |
| 792 FX_BYTE src_alpha; | |
| 793 if (clip_scan == NULL) { | |
| 794 src_alpha = *src_alpha_scan ++; | |
| 795 } else { | |
| 796 src_alpha = clip_scan[col] * (*src_alpha_scan ++) / 255; | |
| 797 } | |
| 798 if (src_alpha == 0) { | |
| 799 dest_scan += 4; | |
| 800 src_scan += 3; | |
| 801 continue; | |
| 802 } | |
| 803 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_a
lpha / 255; | |
| 804 dest_scan[3] = dest_alpha; | |
| 805 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 806 if (bNonseparableBlend) { | |
| 807 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 808 } | |
| 809 for (int color = 0; color < 3; color ++) { | |
| 810 if (blend_type) { | |
| 811 int blended = bNonseparableBlend ? blended_colors[color]
: | |
| 812 _BLEND(blend_type, *dest_scan, *src_scan); | |
| 813 blended = FXDIB_ALPHA_MERGE(*src_scan, blended, back_alp
ha); | |
| 814 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alph
a_ratio); | |
| 815 } else { | |
| 816 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, al
pha_ratio); | |
| 817 } | |
| 818 dest_scan ++; | |
| 819 src_scan ++; | |
| 820 } | |
| 821 dest_scan ++; | |
| 822 } | |
| 823 } | |
| 824 } else { | |
| 825 if (src_alpha_scan) { | |
| 826 for (int col = 0; col < pixel_count; col ++) { | |
| 827 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 828 if (back_alpha == 0) { | |
| 829 if (clip_scan) { | |
| 830 int src_alpha = clip_scan[col] * (*src_alpha_scan) / 255
; | |
| 831 *dest_alpha_scan = src_alpha; | |
| 832 *dest_scan++ = *src_scan++; | |
| 833 *dest_scan++ = *src_scan++; | |
| 834 *dest_scan++ = *src_scan++; | |
| 835 } else { | |
| 836 *dest_alpha_scan = *src_alpha_scan; | |
| 837 *dest_scan++ = *src_scan++; | |
| 838 *dest_scan++ = *src_scan++; | |
| 839 *dest_scan++ = *src_scan++; | |
| 840 } | |
| 841 dest_alpha_scan ++; | |
| 842 src_alpha_scan ++; | |
| 843 continue; | |
| 844 } | |
| 845 FX_BYTE src_alpha; | |
| 846 if (clip_scan == NULL) { | |
| 847 src_alpha = *src_alpha_scan ++; | |
| 848 } else { | |
| 849 src_alpha = clip_scan[col] * (*src_alpha_scan ++) / 255; | |
| 850 } | |
| 851 if (src_alpha == 0) { | |
| 852 dest_scan += 3; | |
| 853 src_scan += 3; | |
| 854 dest_alpha_scan ++; | |
| 855 continue; | |
| 856 } | |
| 857 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_a
lpha / 255; | |
| 858 *dest_alpha_scan ++ = dest_alpha; | |
| 859 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 860 if (bNonseparableBlend) { | |
| 861 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 862 } | |
| 863 for (int color = 0; color < 3; color ++) { | |
| 864 if (blend_type) { | |
| 865 int blended = bNonseparableBlend ? blended_colors[color]
: | |
| 866 _BLEND(blend_type, *dest_scan, *src_scan); | |
| 867 blended = FXDIB_ALPHA_MERGE(*src_scan, blended, back_alp
ha); | |
| 868 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alph
a_ratio); | |
| 869 } else { | |
| 870 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, al
pha_ratio); | |
| 871 } | |
| 872 dest_scan ++; | |
| 873 src_scan ++; | |
| 874 } | |
| 875 } | |
| 876 } else { | |
| 877 for (int col = 0; col < pixel_count; col ++) { | |
| 878 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 879 if (back_alpha == 0) { | |
| 880 if (clip_scan) { | |
| 881 int src_alpha = clip_scan[col] * src_scan[3] / 255; | |
| 882 *dest_alpha_scan = src_alpha; | |
| 883 *dest_scan++ = *src_scan++; | |
| 884 *dest_scan++ = *src_scan++; | |
| 885 *dest_scan++ = *src_scan++; | |
| 886 } else { | |
| 887 *dest_alpha_scan = src_scan[3]; | |
| 888 *dest_scan++ = *src_scan++; | |
| 889 *dest_scan++ = *src_scan++; | |
| 890 *dest_scan++ = *src_scan++; | |
| 891 } | |
| 892 dest_alpha_scan ++; | |
| 893 src_scan ++; | |
| 894 continue; | |
| 895 } | |
| 896 FX_BYTE src_alpha; | |
| 897 if (clip_scan == NULL) { | |
| 898 src_alpha = src_scan[3]; | |
| 899 } else { | |
| 900 src_alpha = clip_scan[col] * src_scan[3] / 255; | |
| 901 } | |
| 902 if (src_alpha == 0) { | |
| 903 dest_scan += 3; | |
| 904 src_scan += 4; | |
| 905 dest_alpha_scan ++; | |
| 906 continue; | |
| 907 } | |
| 908 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_a
lpha / 255; | |
| 909 *dest_alpha_scan++ = dest_alpha; | |
| 910 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 911 if (bNonseparableBlend) { | |
| 912 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 913 } | |
| 914 for (int color = 0; color < 3; color ++) { | |
| 915 if (blend_type) { | |
| 916 int blended = bNonseparableBlend ? blended_colors[color]
: | |
| 917 _BLEND(blend_type, *dest_scan, *src_scan); | |
| 918 blended = FXDIB_ALPHA_MERGE(*src_scan, blended, back_alp
ha); | |
| 919 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alph
a_ratio); | |
| 920 } else { | |
| 921 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, al
pha_ratio); | |
| 922 } | |
| 923 dest_scan ++; | |
| 924 src_scan ++; | |
| 925 } | |
| 926 src_scan ++; | |
| 927 } | |
| 928 } | |
| 929 } | |
| 930 } | |
| 931 void _CompositeRow_Rgb2Argb_Blend_NoClip(FX_LPBYTE dest_scan, FX_LPCBYTE src_sca
n, int width, int blend_type, int src_Bpp, | |
| 932 FX_LPBYTE dest_alpha_scan) | |
| 933 { | |
| 934 int blended_colors[3]; | |
| 935 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 936 int src_gap = src_Bpp - 3; | |
| 937 if (dest_alpha_scan == NULL) { | |
| 938 for (int col = 0; col < width; col ++) { | |
| 939 FX_BYTE back_alpha = dest_scan[3]; | |
| 940 if (back_alpha == 0) { | |
| 941 if (src_Bpp == 4) { | |
| 942 FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan
)); | |
| 943 } else { | |
| 944 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[2], src_
scan[1], src_scan[0])); | |
| 945 } | |
| 946 dest_scan += 4; | |
| 947 src_scan += src_Bpp; | |
| 948 continue; | |
| 949 } | |
| 950 dest_scan[3] = 0xff; | |
| 951 if (bNonseparableBlend) { | |
| 952 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 953 } | |
| 954 for (int color = 0; color < 3; color ++) { | |
| 955 int src_color = *src_scan; | |
| 956 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 957 _BLEND(blend_type, *dest_scan, src_color); | |
| 958 *dest_scan = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); | |
| 959 dest_scan ++; | |
| 960 src_scan ++; | |
| 961 } | |
| 962 dest_scan ++; | |
| 963 src_scan += src_gap; | |
| 964 } | |
| 965 } else { | |
| 966 for (int col = 0; col < width; col ++) { | |
| 967 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 968 if (back_alpha == 0) { | |
| 969 *dest_scan++ = *src_scan++; | |
| 970 *dest_scan++ = *src_scan++; | |
| 971 *dest_scan++ = *src_scan++; | |
| 972 *dest_alpha_scan++ = 0xff; | |
| 973 src_scan += src_gap; | |
| 974 continue; | |
| 975 } | |
| 976 *dest_alpha_scan++ = 0xff; | |
| 977 if (bNonseparableBlend) { | |
| 978 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 979 } | |
| 980 for (int color = 0; color < 3; color ++) { | |
| 981 int src_color = *src_scan; | |
| 982 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 983 _BLEND(blend_type, *dest_scan, src_color); | |
| 984 *dest_scan = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); | |
| 985 dest_scan ++; | |
| 986 src_scan ++; | |
| 987 } | |
| 988 src_scan += src_gap; | |
| 989 } | |
| 990 } | |
| 991 } | |
| 992 inline void _CompositeRow_Rgb2Argb_Blend_Clip(FX_LPBYTE dest_scan, FX_LPCBYTE sr
c_scan, int width, int blend_type, int src_Bpp, FX_LPCBYTE clip_scan, | |
| 993 FX_LPBYTE dest_alpha_scan) | |
| 994 { | |
| 995 int blended_colors[3]; | |
| 996 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 997 int src_gap = src_Bpp - 3; | |
| 998 if (dest_alpha_scan == NULL) { | |
| 999 for (int col = 0; col < width; col ++) { | |
| 1000 int src_alpha = *clip_scan ++; | |
| 1001 FX_BYTE back_alpha = dest_scan[3]; | |
| 1002 if (back_alpha == 0) { | |
| 1003 *dest_scan++ = *src_scan++; | |
| 1004 *dest_scan++ = *src_scan++; | |
| 1005 *dest_scan++ = *src_scan++; | |
| 1006 src_scan += src_gap; | |
| 1007 dest_scan ++; | |
| 1008 continue; | |
| 1009 } | |
| 1010 if (src_alpha == 0) { | |
| 1011 dest_scan += 4; | |
| 1012 src_scan += src_Bpp; | |
| 1013 continue; | |
| 1014 } | |
| 1015 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | |
| 1016 dest_scan[3] = dest_alpha; | |
| 1017 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 1018 if (bNonseparableBlend) { | |
| 1019 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 1020 } | |
| 1021 for (int color = 0; color < 3; color ++) { | |
| 1022 int src_color = *src_scan; | |
| 1023 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 1024 _BLEND(blend_type, *dest_scan, src_color); | |
| 1025 blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); | |
| 1026 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio)
; | |
| 1027 dest_scan ++; | |
| 1028 src_scan ++; | |
| 1029 } | |
| 1030 dest_scan ++; | |
| 1031 src_scan += src_gap; | |
| 1032 } | |
| 1033 } else { | |
| 1034 for (int col = 0; col < width; col ++) { | |
| 1035 int src_alpha = *clip_scan ++; | |
| 1036 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 1037 if (back_alpha == 0) { | |
| 1038 *dest_scan++ = *src_scan++; | |
| 1039 *dest_scan++ = *src_scan++; | |
| 1040 *dest_scan++ = *src_scan++; | |
| 1041 src_scan += src_gap; | |
| 1042 dest_alpha_scan++; | |
| 1043 continue; | |
| 1044 } | |
| 1045 if (src_alpha == 0) { | |
| 1046 dest_scan += 3; | |
| 1047 dest_alpha_scan++; | |
| 1048 src_scan += src_Bpp; | |
| 1049 continue; | |
| 1050 } | |
| 1051 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | |
| 1052 *dest_alpha_scan++ = dest_alpha; | |
| 1053 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 1054 if (bNonseparableBlend) { | |
| 1055 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 1056 } | |
| 1057 for (int color = 0; color < 3; color ++) { | |
| 1058 int src_color = *src_scan; | |
| 1059 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 1060 _BLEND(blend_type, *dest_scan, src_color); | |
| 1061 blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); | |
| 1062 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio)
; | |
| 1063 dest_scan ++; | |
| 1064 src_scan ++; | |
| 1065 } | |
| 1066 src_scan += src_gap; | |
| 1067 } | |
| 1068 } | |
| 1069 } | |
| 1070 inline void _CompositeRow_Rgb2Argb_NoBlend_Clip(FX_LPBYTE dest_scan, FX_LPCBYTE
src_scan, int width, int src_Bpp, FX_LPCBYTE clip_scan, | |
| 1071 FX_LPBYTE dest_alpha_scan) | |
| 1072 { | |
| 1073 int src_gap = src_Bpp - 3; | |
| 1074 if (dest_alpha_scan == NULL) { | |
| 1075 for (int col = 0; col < width; col ++) { | |
| 1076 int src_alpha = clip_scan[col]; | |
| 1077 if (src_alpha == 255) { | |
| 1078 *dest_scan++ = *src_scan++; | |
| 1079 *dest_scan++ = *src_scan++; | |
| 1080 *dest_scan++ = *src_scan++; | |
| 1081 *dest_scan++ = 255; | |
| 1082 src_scan += src_gap; | |
| 1083 continue; | |
| 1084 } | |
| 1085 if (src_alpha == 0) { | |
| 1086 dest_scan += 4; | |
| 1087 src_scan += src_Bpp; | |
| 1088 continue; | |
| 1089 } | |
| 1090 int back_alpha = dest_scan[3]; | |
| 1091 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | |
| 1092 dest_scan[3] = dest_alpha; | |
| 1093 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 1094 for (int color = 0; color < 3; color ++) { | |
| 1095 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_rati
o); | |
| 1096 dest_scan ++; | |
| 1097 src_scan ++; | |
| 1098 } | |
| 1099 dest_scan ++; | |
| 1100 src_scan += src_gap; | |
| 1101 } | |
| 1102 } else { | |
| 1103 for (int col = 0; col < width; col ++) { | |
| 1104 int src_alpha = clip_scan[col]; | |
| 1105 if (src_alpha == 255) { | |
| 1106 *dest_scan++ = *src_scan++; | |
| 1107 *dest_scan++ = *src_scan++; | |
| 1108 *dest_scan++ = *src_scan++; | |
| 1109 *dest_alpha_scan++ = 255; | |
| 1110 src_scan += src_gap; | |
| 1111 continue; | |
| 1112 } | |
| 1113 if (src_alpha == 0) { | |
| 1114 dest_scan += 3; | |
| 1115 dest_alpha_scan ++; | |
| 1116 src_scan += src_Bpp; | |
| 1117 continue; | |
| 1118 } | |
| 1119 int back_alpha = *dest_alpha_scan; | |
| 1120 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | |
| 1121 *dest_alpha_scan ++ = dest_alpha; | |
| 1122 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 1123 for (int color = 0; color < 3; color ++) { | |
| 1124 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_rati
o); | |
| 1125 dest_scan ++; | |
| 1126 src_scan ++; | |
| 1127 } | |
| 1128 src_scan += src_gap; | |
| 1129 } | |
| 1130 } | |
| 1131 } | |
| 1132 inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip(FX_LPBYTE dest_scan, FX_LPCBYT
E src_scan, int width, int src_Bpp, | |
| 1133 FX_LPBYTE dest_alpha_scan) | |
| 1134 { | |
| 1135 if (dest_alpha_scan == NULL) { | |
| 1136 for (int col = 0; col < width; col ++) { | |
| 1137 if (src_Bpp == 4) { | |
| 1138 FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan)); | |
| 1139 } else { | |
| 1140 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[2], src_scan
[1], src_scan[0])); | |
| 1141 } | |
| 1142 dest_scan += 4; | |
| 1143 src_scan += src_Bpp; | |
| 1144 } | |
| 1145 } else { | |
| 1146 int src_gap = src_Bpp - 3; | |
| 1147 for (int col = 0; col < width; col ++) { | |
| 1148 *dest_scan++ = *src_scan++; | 894 *dest_scan++ = *src_scan++; |
| 1149 *dest_scan++ = *src_scan++; | 895 *dest_scan++ = *src_scan++; |
| 1150 *dest_scan++ = *src_scan++; | 896 *dest_scan++ = *src_scan++; |
| 1151 *dest_alpha_scan++ = 0xff; | 897 } else { |
| 1152 src_scan += src_gap; | 898 *dest_alpha_scan = *src_alpha_scan; |
| 1153 } | 899 *dest_scan++ = *src_scan++; |
| 1154 } | 900 *dest_scan++ = *src_scan++; |
| 1155 } | 901 *dest_scan++ = *src_scan++; |
| 1156 inline void _CompositeRow_Argb2Rgb_Blend(FX_LPBYTE dest_scan, FX_LPCBYTE src_sca
n, int width, int blend_type, int dest_Bpp, FX_LPCBYTE clip_scan, | 902 } |
| 1157 FX_LPCBYTE src_alpha_scan) | 903 dest_alpha_scan++; |
| 1158 { | 904 src_alpha_scan++; |
| 905 continue; |
| 906 } |
| 907 FX_BYTE src_alpha; |
| 908 if (clip_scan == NULL) { |
| 909 src_alpha = *src_alpha_scan++; |
| 910 } else { |
| 911 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255; |
| 912 } |
| 913 if (src_alpha == 0) { |
| 914 dest_scan += 3; |
| 915 src_scan += 3; |
| 916 dest_alpha_scan++; |
| 917 continue; |
| 918 } |
| 919 FX_BYTE dest_alpha = |
| 920 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 921 *dest_alpha_scan++ = dest_alpha; |
| 922 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 923 if (bNonseparableBlend) { |
| 924 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 925 } |
| 926 for (int color = 0; color < 3; color++) { |
| 927 if (blend_type) { |
| 928 int blended = bNonseparableBlend |
| 929 ? blended_colors[color] |
| 930 : _BLEND(blend_type, *dest_scan, *src_scan); |
| 931 blended = FXDIB_ALPHA_MERGE(*src_scan, blended, back_alpha); |
| 932 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 933 } else { |
| 934 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio); |
| 935 } |
| 936 dest_scan++; |
| 937 src_scan++; |
| 938 } |
| 939 } |
| 940 } else { |
| 941 for (int col = 0; col < pixel_count; col++) { |
| 942 FX_BYTE back_alpha = *dest_alpha_scan; |
| 943 if (back_alpha == 0) { |
| 944 if (clip_scan) { |
| 945 int src_alpha = clip_scan[col] * src_scan[3] / 255; |
| 946 *dest_alpha_scan = src_alpha; |
| 947 *dest_scan++ = *src_scan++; |
| 948 *dest_scan++ = *src_scan++; |
| 949 *dest_scan++ = *src_scan++; |
| 950 } else { |
| 951 *dest_alpha_scan = src_scan[3]; |
| 952 *dest_scan++ = *src_scan++; |
| 953 *dest_scan++ = *src_scan++; |
| 954 *dest_scan++ = *src_scan++; |
| 955 } |
| 956 dest_alpha_scan++; |
| 957 src_scan++; |
| 958 continue; |
| 959 } |
| 960 FX_BYTE src_alpha; |
| 961 if (clip_scan == NULL) { |
| 962 src_alpha = src_scan[3]; |
| 963 } else { |
| 964 src_alpha = clip_scan[col] * src_scan[3] / 255; |
| 965 } |
| 966 if (src_alpha == 0) { |
| 967 dest_scan += 3; |
| 968 src_scan += 4; |
| 969 dest_alpha_scan++; |
| 970 continue; |
| 971 } |
| 972 FX_BYTE dest_alpha = |
| 973 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 974 *dest_alpha_scan++ = dest_alpha; |
| 975 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 976 if (bNonseparableBlend) { |
| 977 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 978 } |
| 979 for (int color = 0; color < 3; color++) { |
| 980 if (blend_type) { |
| 981 int blended = bNonseparableBlend |
| 982 ? blended_colors[color] |
| 983 : _BLEND(blend_type, *dest_scan, *src_scan); |
| 984 blended = FXDIB_ALPHA_MERGE(*src_scan, blended, back_alpha); |
| 985 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 986 } else { |
| 987 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio); |
| 988 } |
| 989 dest_scan++; |
| 990 src_scan++; |
| 991 } |
| 992 src_scan++; |
| 993 } |
| 994 } |
| 995 } |
| 996 } |
| 997 void _CompositeRow_Rgb2Argb_Blend_NoClip(FX_LPBYTE dest_scan, |
| 998 FX_LPCBYTE src_scan, |
| 999 int width, |
| 1000 int blend_type, |
| 1001 int src_Bpp, |
| 1002 FX_LPBYTE dest_alpha_scan) { |
| 1003 int blended_colors[3]; |
| 1004 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1005 int src_gap = src_Bpp - 3; |
| 1006 if (dest_alpha_scan == NULL) { |
| 1007 for (int col = 0; col < width; col++) { |
| 1008 FX_BYTE back_alpha = dest_scan[3]; |
| 1009 if (back_alpha == 0) { |
| 1010 if (src_Bpp == 4) { |
| 1011 FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan)); |
| 1012 } else { |
| 1013 FXARGB_SETDIB( |
| 1014 dest_scan, |
| 1015 FXARGB_MAKE(0xff, src_scan[2], src_scan[1], src_scan[0])); |
| 1016 } |
| 1017 dest_scan += 4; |
| 1018 src_scan += src_Bpp; |
| 1019 continue; |
| 1020 } |
| 1021 dest_scan[3] = 0xff; |
| 1022 if (bNonseparableBlend) { |
| 1023 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 1024 } |
| 1025 for (int color = 0; color < 3; color++) { |
| 1026 int src_color = *src_scan; |
| 1027 int blended = bNonseparableBlend |
| 1028 ? blended_colors[color] |
| 1029 : _BLEND(blend_type, *dest_scan, src_color); |
| 1030 *dest_scan = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); |
| 1031 dest_scan++; |
| 1032 src_scan++; |
| 1033 } |
| 1034 dest_scan++; |
| 1035 src_scan += src_gap; |
| 1036 } |
| 1037 } else { |
| 1038 for (int col = 0; col < width; col++) { |
| 1039 FX_BYTE back_alpha = *dest_alpha_scan; |
| 1040 if (back_alpha == 0) { |
| 1041 *dest_scan++ = *src_scan++; |
| 1042 *dest_scan++ = *src_scan++; |
| 1043 *dest_scan++ = *src_scan++; |
| 1044 *dest_alpha_scan++ = 0xff; |
| 1045 src_scan += src_gap; |
| 1046 continue; |
| 1047 } |
| 1048 *dest_alpha_scan++ = 0xff; |
| 1049 if (bNonseparableBlend) { |
| 1050 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 1051 } |
| 1052 for (int color = 0; color < 3; color++) { |
| 1053 int src_color = *src_scan; |
| 1054 int blended = bNonseparableBlend |
| 1055 ? blended_colors[color] |
| 1056 : _BLEND(blend_type, *dest_scan, src_color); |
| 1057 *dest_scan = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); |
| 1058 dest_scan++; |
| 1059 src_scan++; |
| 1060 } |
| 1061 src_scan += src_gap; |
| 1062 } |
| 1063 } |
| 1064 } |
| 1065 inline void _CompositeRow_Rgb2Argb_Blend_Clip(FX_LPBYTE dest_scan, |
| 1066 FX_LPCBYTE src_scan, |
| 1067 int width, |
| 1068 int blend_type, |
| 1069 int src_Bpp, |
| 1070 FX_LPCBYTE clip_scan, |
| 1071 FX_LPBYTE dest_alpha_scan) { |
| 1072 int blended_colors[3]; |
| 1073 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1074 int src_gap = src_Bpp - 3; |
| 1075 if (dest_alpha_scan == NULL) { |
| 1076 for (int col = 0; col < width; col++) { |
| 1077 int src_alpha = *clip_scan++; |
| 1078 FX_BYTE back_alpha = dest_scan[3]; |
| 1079 if (back_alpha == 0) { |
| 1080 *dest_scan++ = *src_scan++; |
| 1081 *dest_scan++ = *src_scan++; |
| 1082 *dest_scan++ = *src_scan++; |
| 1083 src_scan += src_gap; |
| 1084 dest_scan++; |
| 1085 continue; |
| 1086 } |
| 1087 if (src_alpha == 0) { |
| 1088 dest_scan += 4; |
| 1089 src_scan += src_Bpp; |
| 1090 continue; |
| 1091 } |
| 1092 FX_BYTE dest_alpha = |
| 1093 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 1094 dest_scan[3] = dest_alpha; |
| 1095 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 1096 if (bNonseparableBlend) { |
| 1097 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 1098 } |
| 1099 for (int color = 0; color < 3; color++) { |
| 1100 int src_color = *src_scan; |
| 1101 int blended = bNonseparableBlend |
| 1102 ? blended_colors[color] |
| 1103 : _BLEND(blend_type, *dest_scan, src_color); |
| 1104 blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); |
| 1105 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 1106 dest_scan++; |
| 1107 src_scan++; |
| 1108 } |
| 1109 dest_scan++; |
| 1110 src_scan += src_gap; |
| 1111 } |
| 1112 } else { |
| 1113 for (int col = 0; col < width; col++) { |
| 1114 int src_alpha = *clip_scan++; |
| 1115 FX_BYTE back_alpha = *dest_alpha_scan; |
| 1116 if (back_alpha == 0) { |
| 1117 *dest_scan++ = *src_scan++; |
| 1118 *dest_scan++ = *src_scan++; |
| 1119 *dest_scan++ = *src_scan++; |
| 1120 src_scan += src_gap; |
| 1121 dest_alpha_scan++; |
| 1122 continue; |
| 1123 } |
| 1124 if (src_alpha == 0) { |
| 1125 dest_scan += 3; |
| 1126 dest_alpha_scan++; |
| 1127 src_scan += src_Bpp; |
| 1128 continue; |
| 1129 } |
| 1130 FX_BYTE dest_alpha = |
| 1131 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 1132 *dest_alpha_scan++ = dest_alpha; |
| 1133 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 1134 if (bNonseparableBlend) { |
| 1135 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 1136 } |
| 1137 for (int color = 0; color < 3; color++) { |
| 1138 int src_color = *src_scan; |
| 1139 int blended = bNonseparableBlend |
| 1140 ? blended_colors[color] |
| 1141 : _BLEND(blend_type, *dest_scan, src_color); |
| 1142 blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); |
| 1143 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 1144 dest_scan++; |
| 1145 src_scan++; |
| 1146 } |
| 1147 src_scan += src_gap; |
| 1148 } |
| 1149 } |
| 1150 } |
| 1151 inline void _CompositeRow_Rgb2Argb_NoBlend_Clip(FX_LPBYTE dest_scan, |
| 1152 FX_LPCBYTE src_scan, |
| 1153 int width, |
| 1154 int src_Bpp, |
| 1155 FX_LPCBYTE clip_scan, |
| 1156 FX_LPBYTE dest_alpha_scan) { |
| 1157 int src_gap = src_Bpp - 3; |
| 1158 if (dest_alpha_scan == NULL) { |
| 1159 for (int col = 0; col < width; col++) { |
| 1160 int src_alpha = clip_scan[col]; |
| 1161 if (src_alpha == 255) { |
| 1162 *dest_scan++ = *src_scan++; |
| 1163 *dest_scan++ = *src_scan++; |
| 1164 *dest_scan++ = *src_scan++; |
| 1165 *dest_scan++ = 255; |
| 1166 src_scan += src_gap; |
| 1167 continue; |
| 1168 } |
| 1169 if (src_alpha == 0) { |
| 1170 dest_scan += 4; |
| 1171 src_scan += src_Bpp; |
| 1172 continue; |
| 1173 } |
| 1174 int back_alpha = dest_scan[3]; |
| 1175 FX_BYTE dest_alpha = |
| 1176 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 1177 dest_scan[3] = dest_alpha; |
| 1178 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 1179 for (int color = 0; color < 3; color++) { |
| 1180 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio); |
| 1181 dest_scan++; |
| 1182 src_scan++; |
| 1183 } |
| 1184 dest_scan++; |
| 1185 src_scan += src_gap; |
| 1186 } |
| 1187 } else { |
| 1188 for (int col = 0; col < width; col++) { |
| 1189 int src_alpha = clip_scan[col]; |
| 1190 if (src_alpha == 255) { |
| 1191 *dest_scan++ = *src_scan++; |
| 1192 *dest_scan++ = *src_scan++; |
| 1193 *dest_scan++ = *src_scan++; |
| 1194 *dest_alpha_scan++ = 255; |
| 1195 src_scan += src_gap; |
| 1196 continue; |
| 1197 } |
| 1198 if (src_alpha == 0) { |
| 1199 dest_scan += 3; |
| 1200 dest_alpha_scan++; |
| 1201 src_scan += src_Bpp; |
| 1202 continue; |
| 1203 } |
| 1204 int back_alpha = *dest_alpha_scan; |
| 1205 FX_BYTE dest_alpha = |
| 1206 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 1207 *dest_alpha_scan++ = dest_alpha; |
| 1208 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 1209 for (int color = 0; color < 3; color++) { |
| 1210 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio); |
| 1211 dest_scan++; |
| 1212 src_scan++; |
| 1213 } |
| 1214 src_scan += src_gap; |
| 1215 } |
| 1216 } |
| 1217 } |
| 1218 inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip(FX_LPBYTE dest_scan, |
| 1219 FX_LPCBYTE src_scan, |
| 1220 int width, |
| 1221 int src_Bpp, |
| 1222 FX_LPBYTE dest_alpha_scan) { |
| 1223 if (dest_alpha_scan == NULL) { |
| 1224 for (int col = 0; col < width; col++) { |
| 1225 if (src_Bpp == 4) { |
| 1226 FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan)); |
| 1227 } else { |
| 1228 FXARGB_SETDIB(dest_scan, |
| 1229 FXARGB_MAKE(0xff, src_scan[2], src_scan[1], src_scan[0])); |
| 1230 } |
| 1231 dest_scan += 4; |
| 1232 src_scan += src_Bpp; |
| 1233 } |
| 1234 } else { |
| 1235 int src_gap = src_Bpp - 3; |
| 1236 for (int col = 0; col < width; col++) { |
| 1237 *dest_scan++ = *src_scan++; |
| 1238 *dest_scan++ = *src_scan++; |
| 1239 *dest_scan++ = *src_scan++; |
| 1240 *dest_alpha_scan++ = 0xff; |
| 1241 src_scan += src_gap; |
| 1242 } |
| 1243 } |
| 1244 } |
| 1245 inline void _CompositeRow_Argb2Rgb_Blend(FX_LPBYTE dest_scan, |
| 1246 FX_LPCBYTE src_scan, |
| 1247 int width, |
| 1248 int blend_type, |
| 1249 int dest_Bpp, |
| 1250 FX_LPCBYTE clip_scan, |
| 1251 FX_LPCBYTE src_alpha_scan) { |
| 1252 int blended_colors[3]; |
| 1253 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1254 int dest_gap = dest_Bpp - 3; |
| 1255 if (src_alpha_scan == NULL) { |
| 1256 for (int col = 0; col < width; col++) { |
| 1257 FX_BYTE src_alpha; |
| 1258 if (clip_scan) { |
| 1259 src_alpha = src_scan[3] * (*clip_scan++) / 255; |
| 1260 } else { |
| 1261 src_alpha = src_scan[3]; |
| 1262 } |
| 1263 if (src_alpha == 0) { |
| 1264 dest_scan += dest_Bpp; |
| 1265 src_scan += 4; |
| 1266 continue; |
| 1267 } |
| 1268 if (bNonseparableBlend) { |
| 1269 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 1270 } |
| 1271 for (int color = 0; color < 3; color++) { |
| 1272 int back_color = *dest_scan; |
| 1273 int blended = bNonseparableBlend |
| 1274 ? blended_colors[color] |
| 1275 : _BLEND(blend_type, back_color, *src_scan); |
| 1276 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); |
| 1277 dest_scan++; |
| 1278 src_scan++; |
| 1279 } |
| 1280 dest_scan += dest_gap; |
| 1281 src_scan++; |
| 1282 } |
| 1283 } else { |
| 1284 for (int col = 0; col < width; col++) { |
| 1285 FX_BYTE src_alpha; |
| 1286 if (clip_scan) { |
| 1287 src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255; |
| 1288 } else { |
| 1289 src_alpha = *src_alpha_scan++; |
| 1290 } |
| 1291 if (src_alpha == 0) { |
| 1292 dest_scan += dest_Bpp; |
| 1293 src_scan += 3; |
| 1294 continue; |
| 1295 } |
| 1296 if (bNonseparableBlend) { |
| 1297 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 1298 } |
| 1299 for (int color = 0; color < 3; color++) { |
| 1300 int back_color = *dest_scan; |
| 1301 int blended = bNonseparableBlend |
| 1302 ? blended_colors[color] |
| 1303 : _BLEND(blend_type, back_color, *src_scan); |
| 1304 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); |
| 1305 dest_scan++; |
| 1306 src_scan++; |
| 1307 } |
| 1308 dest_scan += dest_gap; |
| 1309 } |
| 1310 } |
| 1311 } |
| 1312 inline void _CompositeRow_Argb2Rgb_NoBlend(FX_LPBYTE dest_scan, |
| 1313 FX_LPCBYTE src_scan, |
| 1314 int width, |
| 1315 int dest_Bpp, |
| 1316 FX_LPCBYTE clip_scan, |
| 1317 FX_LPCBYTE src_alpha_scan) { |
| 1318 int dest_gap = dest_Bpp - 3; |
| 1319 if (src_alpha_scan == NULL) { |
| 1320 for (int col = 0; col < width; col++) { |
| 1321 FX_BYTE src_alpha; |
| 1322 if (clip_scan) { |
| 1323 src_alpha = src_scan[3] * (*clip_scan++) / 255; |
| 1324 } else { |
| 1325 src_alpha = src_scan[3]; |
| 1326 } |
| 1327 if (src_alpha == 255) { |
| 1328 *dest_scan++ = *src_scan++; |
| 1329 *dest_scan++ = *src_scan++; |
| 1330 *dest_scan++ = *src_scan++; |
| 1331 dest_scan += dest_gap; |
| 1332 src_scan++; |
| 1333 continue; |
| 1334 } |
| 1335 if (src_alpha == 0) { |
| 1336 dest_scan += dest_Bpp; |
| 1337 src_scan += 4; |
| 1338 continue; |
| 1339 } |
| 1340 for (int color = 0; color < 3; color++) { |
| 1341 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha); |
| 1342 dest_scan++; |
| 1343 src_scan++; |
| 1344 } |
| 1345 dest_scan += dest_gap; |
| 1346 src_scan++; |
| 1347 } |
| 1348 } else { |
| 1349 for (int col = 0; col < width; col++) { |
| 1350 FX_BYTE src_alpha; |
| 1351 if (clip_scan) { |
| 1352 src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255; |
| 1353 } else { |
| 1354 src_alpha = *src_alpha_scan++; |
| 1355 } |
| 1356 if (src_alpha == 255) { |
| 1357 *dest_scan++ = *src_scan++; |
| 1358 *dest_scan++ = *src_scan++; |
| 1359 *dest_scan++ = *src_scan++; |
| 1360 dest_scan += dest_gap; |
| 1361 continue; |
| 1362 } |
| 1363 if (src_alpha == 0) { |
| 1364 dest_scan += dest_Bpp; |
| 1365 src_scan += 3; |
| 1366 continue; |
| 1367 } |
| 1368 for (int color = 0; color < 3; color++) { |
| 1369 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha); |
| 1370 dest_scan++; |
| 1371 src_scan++; |
| 1372 } |
| 1373 dest_scan += dest_gap; |
| 1374 } |
| 1375 } |
| 1376 } |
| 1377 inline void _CompositeRow_Rgb2Rgb_Blend_NoClip(FX_LPBYTE dest_scan, |
| 1378 FX_LPCBYTE src_scan, |
| 1379 int width, |
| 1380 int blend_type, |
| 1381 int dest_Bpp, |
| 1382 int src_Bpp) { |
| 1383 int blended_colors[3]; |
| 1384 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1385 int dest_gap = dest_Bpp - 3; |
| 1386 int src_gap = src_Bpp - 3; |
| 1387 for (int col = 0; col < width; col++) { |
| 1388 if (bNonseparableBlend) { |
| 1389 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 1390 } |
| 1391 for (int color = 0; color < 3; color++) { |
| 1392 int back_color = *dest_scan; |
| 1393 int src_color = *src_scan; |
| 1394 int blended = bNonseparableBlend |
| 1395 ? blended_colors[color] |
| 1396 : _BLEND(blend_type, back_color, src_color); |
| 1397 *dest_scan = blended; |
| 1398 dest_scan++; |
| 1399 src_scan++; |
| 1400 } |
| 1401 dest_scan += dest_gap; |
| 1402 src_scan += src_gap; |
| 1403 } |
| 1404 } |
| 1405 inline void _CompositeRow_Rgb2Rgb_Blend_Clip(FX_LPBYTE dest_scan, |
| 1406 FX_LPCBYTE src_scan, |
| 1407 int width, |
| 1408 int blend_type, |
| 1409 int dest_Bpp, |
| 1410 int src_Bpp, |
| 1411 FX_LPCBYTE clip_scan) { |
| 1412 int blended_colors[3]; |
| 1413 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1414 int dest_gap = dest_Bpp - 3; |
| 1415 int src_gap = src_Bpp - 3; |
| 1416 for (int col = 0; col < width; col++) { |
| 1417 FX_BYTE src_alpha = *clip_scan++; |
| 1418 if (src_alpha == 0) { |
| 1419 dest_scan += dest_Bpp; |
| 1420 src_scan += src_Bpp; |
| 1421 continue; |
| 1422 } |
| 1423 if (bNonseparableBlend) { |
| 1424 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 1425 } |
| 1426 for (int color = 0; color < 3; color++) { |
| 1427 int src_color = *src_scan; |
| 1428 int back_color = *dest_scan; |
| 1429 int blended = bNonseparableBlend |
| 1430 ? blended_colors[color] |
| 1431 : _BLEND(blend_type, back_color, src_color); |
| 1432 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); |
| 1433 dest_scan++; |
| 1434 src_scan++; |
| 1435 } |
| 1436 dest_scan += dest_gap; |
| 1437 src_scan += src_gap; |
| 1438 } |
| 1439 } |
| 1440 inline void _CompositeRow_Rgb2Rgb_NoBlend_NoClip(FX_LPBYTE dest_scan, |
| 1441 FX_LPCBYTE src_scan, |
| 1442 int width, |
| 1443 int dest_Bpp, |
| 1444 int src_Bpp) { |
| 1445 if (dest_Bpp == src_Bpp) { |
| 1446 FXSYS_memcpy32(dest_scan, src_scan, width * dest_Bpp); |
| 1447 return; |
| 1448 } |
| 1449 for (int col = 0; col < width; col++) { |
| 1450 dest_scan[0] = src_scan[0]; |
| 1451 dest_scan[1] = src_scan[1]; |
| 1452 dest_scan[2] = src_scan[2]; |
| 1453 dest_scan += dest_Bpp; |
| 1454 src_scan += src_Bpp; |
| 1455 } |
| 1456 } |
| 1457 inline void _CompositeRow_Rgb2Rgb_NoBlend_Clip(FX_LPBYTE dest_scan, |
| 1458 FX_LPCBYTE src_scan, |
| 1459 int width, |
| 1460 int dest_Bpp, |
| 1461 int src_Bpp, |
| 1462 FX_LPCBYTE clip_scan) { |
| 1463 for (int col = 0; col < width; col++) { |
| 1464 int src_alpha = clip_scan[col]; |
| 1465 if (src_alpha == 255) { |
| 1466 dest_scan[0] = src_scan[0]; |
| 1467 dest_scan[1] = src_scan[1]; |
| 1468 dest_scan[2] = src_scan[2]; |
| 1469 } else if (src_alpha) { |
| 1470 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha); |
| 1471 dest_scan++; |
| 1472 src_scan++; |
| 1473 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha); |
| 1474 dest_scan++; |
| 1475 src_scan++; |
| 1476 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha); |
| 1477 dest_scan += dest_Bpp - 2; |
| 1478 src_scan += src_Bpp - 2; |
| 1479 continue; |
| 1480 } |
| 1481 dest_scan += dest_Bpp; |
| 1482 src_scan += src_Bpp; |
| 1483 } |
| 1484 } |
| 1485 void _CompositeRow_Argb2Argb_Transform(FX_LPBYTE dest_scan, |
| 1486 FX_LPCBYTE src_scan, |
| 1487 int pixel_count, |
| 1488 int blend_type, |
| 1489 FX_LPCBYTE clip_scan, |
| 1490 FX_LPBYTE dest_alpha_scan, |
| 1491 FX_LPCBYTE src_alpha_scan, |
| 1492 FX_LPBYTE src_cache_scan, |
| 1493 void* pIccTransform) { |
| 1494 FX_LPBYTE dp = src_cache_scan; |
| 1495 ICodec_IccModule* pIccModule = |
| 1496 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1497 if (src_alpha_scan) { |
| 1498 if (dest_alpha_scan == NULL) { |
| 1499 for (int col = 0; col < pixel_count; col++) { |
| 1500 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); |
| 1501 dp[3] = *src_alpha_scan++; |
| 1502 src_scan += 3; |
| 1503 dp += 4; |
| 1504 } |
| 1505 src_alpha_scan = NULL; |
| 1506 } else { |
| 1507 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_count); |
| 1508 } |
| 1509 } else { |
| 1510 if (dest_alpha_scan == NULL) { |
| 1511 for (int col = 0; col < pixel_count; col++) { |
| 1512 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); |
| 1513 dp[3] = src_scan[3]; |
| 1514 src_scan += 4; |
| 1515 dp += 4; |
| 1516 } |
| 1517 } else { |
| 1518 int blended_colors[3]; |
| 1519 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1520 for (int col = 0; col < pixel_count; col++) { |
| 1521 pIccModule->TranslateScanline( |
| 1522 pIccTransform, src_cache_scan, src_scan, 1); |
| 1523 FX_BYTE back_alpha = *dest_alpha_scan; |
| 1524 if (back_alpha == 0) { |
| 1525 if (clip_scan) { |
| 1526 int src_alpha = clip_scan[col] * src_scan[3] / 255; |
| 1527 *dest_alpha_scan = src_alpha; |
| 1528 *dest_scan++ = *src_cache_scan++; |
| 1529 *dest_scan++ = *src_cache_scan++; |
| 1530 *dest_scan++ = *src_cache_scan++; |
| 1531 } else { |
| 1532 *dest_alpha_scan = src_scan[3]; |
| 1533 *dest_scan++ = *src_cache_scan++; |
| 1534 *dest_scan++ = *src_cache_scan++; |
| 1535 *dest_scan++ = *src_cache_scan++; |
| 1536 } |
| 1537 dest_alpha_scan++; |
| 1538 src_scan += 4; |
| 1539 continue; |
| 1540 } |
| 1541 FX_BYTE src_alpha; |
| 1542 if (clip_scan == NULL) { |
| 1543 src_alpha = src_scan[3]; |
| 1544 } else { |
| 1545 src_alpha = clip_scan[col] * src_scan[3] / 255; |
| 1546 } |
| 1547 src_scan += 4; |
| 1548 if (src_alpha == 0) { |
| 1549 dest_scan += 3; |
| 1550 src_cache_scan += 3; |
| 1551 dest_alpha_scan++; |
| 1552 continue; |
| 1553 } |
| 1554 FX_BYTE dest_alpha = |
| 1555 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 1556 *dest_alpha_scan++ = dest_alpha; |
| 1557 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 1558 if (bNonseparableBlend) { |
| 1559 _RGB_Blend(blend_type, src_cache_scan, dest_scan, blended_colors); |
| 1560 } |
| 1561 for (int color = 0; color < 3; color++) { |
| 1562 if (blend_type) { |
| 1563 int blended = bNonseparableBlend |
| 1564 ? blended_colors[color] |
| 1565 : _BLEND(blend_type, *dest_scan, *src_cache_scan); |
| 1566 blended = FXDIB_ALPHA_MERGE(*src_cache_scan, blended, back_alpha); |
| 1567 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 1568 } else { |
| 1569 *dest_scan = |
| 1570 FXDIB_ALPHA_MERGE(*dest_scan, *src_cache_scan, alpha_ratio); |
| 1571 } |
| 1572 dest_scan++; |
| 1573 src_cache_scan++; |
| 1574 } |
| 1575 } |
| 1576 return; |
| 1577 } |
| 1578 } |
| 1579 _CompositeRow_Argb2Argb(dest_scan, |
| 1580 src_cache_scan, |
| 1581 pixel_count, |
| 1582 blend_type, |
| 1583 clip_scan, |
| 1584 dest_alpha_scan, |
| 1585 src_alpha_scan); |
| 1586 } |
| 1587 void _CompositeRow_Rgb2Argb_Blend_NoClip_Transform(FX_LPBYTE dest_scan, |
| 1588 FX_LPCBYTE src_scan, |
| 1589 int width, |
| 1590 int blend_type, |
| 1591 int src_Bpp, |
| 1592 FX_LPBYTE dest_alpha_scan, |
| 1593 FX_LPBYTE src_cache_scan, |
| 1594 void* pIccTransform) { |
| 1595 ICodec_IccModule* pIccModule = |
| 1596 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1597 if (src_Bpp == 3) { |
| 1598 pIccModule->TranslateScanline( |
| 1599 pIccTransform, src_cache_scan, src_scan, width); |
| 1600 } else { |
| 1601 FX_LPBYTE dp = src_cache_scan; |
| 1602 for (int col = 0; col < width; col++) { |
| 1603 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); |
| 1604 src_scan += 4; |
| 1605 dp += 3; |
| 1606 } |
| 1607 } |
| 1608 _CompositeRow_Rgb2Argb_Blend_NoClip( |
| 1609 dest_scan, src_cache_scan, width, blend_type, 3, dest_alpha_scan); |
| 1610 } |
| 1611 inline void _CompositeRow_Rgb2Argb_Blend_Clip_Transform( |
| 1612 FX_LPBYTE dest_scan, |
| 1613 FX_LPCBYTE src_scan, |
| 1614 int width, |
| 1615 int blend_type, |
| 1616 int src_Bpp, |
| 1617 FX_LPCBYTE clip_scan, |
| 1618 FX_LPBYTE dest_alpha_scan, |
| 1619 FX_LPBYTE src_cache_scan, |
| 1620 void* pIccTransform) { |
| 1621 ICodec_IccModule* pIccModule = |
| 1622 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1623 if (src_Bpp == 3) { |
| 1624 pIccModule->TranslateScanline( |
| 1625 pIccTransform, src_cache_scan, src_scan, width); |
| 1626 } else { |
| 1627 FX_LPBYTE dp = src_cache_scan; |
| 1628 for (int col = 0; col < width; col++) { |
| 1629 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); |
| 1630 src_scan += 4; |
| 1631 dp += 3; |
| 1632 } |
| 1633 } |
| 1634 _CompositeRow_Rgb2Argb_Blend_Clip(dest_scan, |
| 1635 src_cache_scan, |
| 1636 width, |
| 1637 blend_type, |
| 1638 3, |
| 1639 clip_scan, |
| 1640 dest_alpha_scan); |
| 1641 } |
| 1642 inline void _CompositeRow_Rgb2Argb_NoBlend_Clip_Transform( |
| 1643 FX_LPBYTE dest_scan, |
| 1644 FX_LPCBYTE src_scan, |
| 1645 int width, |
| 1646 int src_Bpp, |
| 1647 FX_LPCBYTE clip_scan, |
| 1648 FX_LPBYTE dest_alpha_scan, |
| 1649 FX_LPBYTE src_cache_scan, |
| 1650 void* pIccTransform) { |
| 1651 ICodec_IccModule* pIccModule = |
| 1652 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1653 if (src_Bpp == 3) { |
| 1654 pIccModule->TranslateScanline( |
| 1655 pIccTransform, src_cache_scan, src_scan, width); |
| 1656 } else { |
| 1657 FX_LPBYTE dp = src_cache_scan; |
| 1658 for (int col = 0; col < width; col++) { |
| 1659 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); |
| 1660 src_scan += 4; |
| 1661 dp += 3; |
| 1662 } |
| 1663 } |
| 1664 _CompositeRow_Rgb2Argb_NoBlend_Clip( |
| 1665 dest_scan, src_cache_scan, width, 3, clip_scan, dest_alpha_scan); |
| 1666 } |
| 1667 inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip_Transform( |
| 1668 FX_LPBYTE dest_scan, |
| 1669 FX_LPCBYTE src_scan, |
| 1670 int width, |
| 1671 int src_Bpp, |
| 1672 FX_LPBYTE dest_alpha_scan, |
| 1673 FX_LPBYTE src_cache_scan, |
| 1674 void* pIccTransform) { |
| 1675 ICodec_IccModule* pIccModule = |
| 1676 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1677 if (src_Bpp == 3) { |
| 1678 pIccModule->TranslateScanline( |
| 1679 pIccTransform, src_cache_scan, src_scan, width); |
| 1680 } else { |
| 1681 FX_LPBYTE dp = src_cache_scan; |
| 1682 for (int col = 0; col < width; col++) { |
| 1683 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); |
| 1684 src_scan += 4; |
| 1685 dp += 3; |
| 1686 } |
| 1687 } |
| 1688 _CompositeRow_Rgb2Argb_NoBlend_NoClip( |
| 1689 dest_scan, src_cache_scan, width, 3, dest_alpha_scan); |
| 1690 } |
| 1691 inline void _CompositeRow_Argb2Rgb_Blend_Transform(FX_LPBYTE dest_scan, |
| 1692 FX_LPCBYTE src_scan, |
| 1693 int width, |
| 1694 int blend_type, |
| 1695 int dest_Bpp, |
| 1696 FX_LPCBYTE clip_scan, |
| 1697 FX_LPCBYTE src_alpha_scan, |
| 1698 FX_LPBYTE src_cache_scan, |
| 1699 void* pIccTransform) { |
| 1700 ICodec_IccModule* pIccModule = |
| 1701 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1702 if (src_alpha_scan) { |
| 1703 pIccModule->TranslateScanline( |
| 1704 pIccTransform, src_cache_scan, src_scan, width); |
| 1705 } else { |
| 1159 int blended_colors[3]; | 1706 int blended_colors[3]; |
| 1160 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 1707 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1161 int dest_gap = dest_Bpp - 3; | 1708 int dest_gap = dest_Bpp - 3; |
| 1162 if (src_alpha_scan == NULL) { | 1709 for (int col = 0; col < width; col++) { |
| 1163 for (int col = 0; col < width; col ++) { | 1710 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, 1); |
| 1164 FX_BYTE src_alpha; | 1711 FX_BYTE src_alpha; |
| 1165 if (clip_scan) { | 1712 if (clip_scan) { |
| 1166 src_alpha = src_scan[3] * (*clip_scan++) / 255; | 1713 src_alpha = src_scan[3] * (*clip_scan++) / 255; |
| 1167 } else { | 1714 } else { |
| 1168 src_alpha = src_scan[3]; | 1715 src_alpha = src_scan[3]; |
| 1169 } | 1716 } |
| 1170 if (src_alpha == 0) { | 1717 src_scan += 4; |
| 1171 dest_scan += dest_Bpp; | 1718 if (src_alpha == 0) { |
| 1172 src_scan += 4; | 1719 dest_scan += dest_Bpp; |
| 1173 continue; | 1720 src_cache_scan += 3; |
| 1174 } | 1721 continue; |
| 1175 if (bNonseparableBlend) { | 1722 } |
| 1176 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | 1723 if (bNonseparableBlend) { |
| 1177 } | 1724 _RGB_Blend(blend_type, src_cache_scan, dest_scan, blended_colors); |
| 1178 for (int color = 0; color < 3; color ++) { | 1725 } |
| 1179 int back_color = *dest_scan; | 1726 for (int color = 0; color < 3; color++) { |
| 1180 int blended = bNonseparableBlend ? blended_colors[color] : | 1727 int back_color = *dest_scan; |
| 1181 _BLEND(blend_type, back_color, *src_scan); | 1728 int blended = bNonseparableBlend |
| 1182 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); | 1729 ? blended_colors[color] |
| 1183 dest_scan ++; | 1730 : _BLEND(blend_type, back_color, *src_cache_scan); |
| 1184 src_scan ++; | 1731 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); |
| 1185 } | 1732 dest_scan++; |
| 1186 dest_scan += dest_gap; | 1733 src_cache_scan++; |
| 1187 src_scan ++; | 1734 } |
| 1188 } | 1735 dest_scan += dest_gap; |
| 1189 } else { | 1736 } |
| 1190 for (int col = 0; col < width; col ++) { | 1737 return; |
| 1191 FX_BYTE src_alpha; | 1738 } |
| 1192 if (clip_scan) { | 1739 _CompositeRow_Argb2Rgb_Blend(dest_scan, |
| 1193 src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255; | 1740 src_cache_scan, |
| 1194 } else { | 1741 width, |
| 1195 src_alpha = *src_alpha_scan++; | 1742 blend_type, |
| 1196 } | 1743 dest_Bpp, |
| 1197 if (src_alpha == 0) { | 1744 clip_scan, |
| 1198 dest_scan += dest_Bpp; | 1745 src_alpha_scan); |
| 1199 src_scan += 3; | 1746 } |
| 1200 continue; | 1747 inline void _CompositeRow_Argb2Rgb_NoBlend_Transform(FX_LPBYTE dest_scan, |
| 1201 } | 1748 FX_LPCBYTE src_scan, |
| 1202 if (bNonseparableBlend) { | 1749 int width, |
| 1203 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | 1750 int dest_Bpp, |
| 1204 } | 1751 FX_LPCBYTE clip_scan, |
| 1205 for (int color = 0; color < 3; color ++) { | 1752 FX_LPCBYTE src_alpha_scan, |
| 1206 int back_color = *dest_scan; | 1753 FX_LPBYTE src_cache_scan, |
| 1207 int blended = bNonseparableBlend ? blended_colors[color] : | 1754 void* pIccTransform) { |
| 1208 _BLEND(blend_type, back_color, *src_scan); | 1755 ICodec_IccModule* pIccModule = |
| 1209 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); | 1756 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1210 dest_scan ++; | 1757 if (src_alpha_scan) { |
| 1211 src_scan ++; | 1758 pIccModule->TranslateScanline( |
| 1212 } | 1759 pIccTransform, src_cache_scan, src_scan, width); |
| 1213 dest_scan += dest_gap; | 1760 } else { |
| 1214 } | |
| 1215 } | |
| 1216 } | |
| 1217 inline void _CompositeRow_Argb2Rgb_NoBlend(FX_LPBYTE dest_scan, FX_LPCBYTE src_s
can, int width, int dest_Bpp, FX_LPCBYTE clip_scan, | |
| 1218 FX_LPCBYTE src_alpha_scan) | |
| 1219 { | |
| 1220 int dest_gap = dest_Bpp - 3; | 1761 int dest_gap = dest_Bpp - 3; |
| 1221 if (src_alpha_scan == NULL) { | 1762 for (int col = 0; col < width; col++) { |
| 1222 for (int col = 0; col < width; col ++) { | 1763 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, 1); |
| 1223 FX_BYTE src_alpha; | 1764 FX_BYTE src_alpha; |
| 1224 if (clip_scan) { | 1765 if (clip_scan) { |
| 1225 src_alpha = src_scan[3] * (*clip_scan++) / 255; | 1766 src_alpha = src_scan[3] * (*clip_scan++) / 255; |
| 1226 } else { | 1767 } else { |
| 1227 src_alpha = src_scan[3]; | 1768 src_alpha = src_scan[3]; |
| 1228 } | 1769 } |
| 1229 if (src_alpha == 255) { | 1770 src_scan += 4; |
| 1230 *dest_scan++ = *src_scan++; | 1771 if (src_alpha == 255) { |
| 1231 *dest_scan++ = *src_scan++; | 1772 *dest_scan++ = *src_cache_scan++; |
| 1232 *dest_scan++ = *src_scan++; | 1773 *dest_scan++ = *src_cache_scan++; |
| 1233 dest_scan += dest_gap; | 1774 *dest_scan++ = *src_cache_scan++; |
| 1234 src_scan ++; | 1775 dest_scan += dest_gap; |
| 1235 continue; | 1776 continue; |
| 1236 } | 1777 } |
| 1237 if (src_alpha == 0) { | 1778 if (src_alpha == 0) { |
| 1238 dest_scan += dest_Bpp; | 1779 dest_scan += dest_Bpp; |
| 1239 src_scan += 4; | 1780 src_cache_scan += 3; |
| 1240 continue; | 1781 continue; |
| 1241 } | 1782 } |
| 1242 for (int color = 0; color < 3; color ++) { | 1783 for (int color = 0; color < 3; color++) { |
| 1243 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha)
; | 1784 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_cache_scan, src_alpha); |
| 1244 dest_scan ++; | 1785 dest_scan++; |
| 1245 src_scan ++; | 1786 src_cache_scan++; |
| 1246 } | 1787 } |
| 1247 dest_scan += dest_gap; | 1788 dest_scan += dest_gap; |
| 1248 src_scan ++; | 1789 } |
| 1249 } | 1790 return; |
| 1250 } else { | 1791 } |
| 1251 for (int col = 0; col < width; col ++) { | 1792 _CompositeRow_Argb2Rgb_NoBlend( |
| 1252 FX_BYTE src_alpha; | 1793 dest_scan, src_cache_scan, width, dest_Bpp, clip_scan, src_alpha_scan); |
| 1253 if (clip_scan) { | 1794 } |
| 1254 src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255; | 1795 inline void _CompositeRow_Rgb2Rgb_Blend_NoClip_Transform( |
| 1255 } else { | 1796 FX_LPBYTE dest_scan, |
| 1256 src_alpha = *src_alpha_scan++; | 1797 FX_LPCBYTE src_scan, |
| 1257 } | 1798 int width, |
| 1258 if (src_alpha == 255) { | 1799 int blend_type, |
| 1259 *dest_scan++ = *src_scan++; | 1800 int dest_Bpp, |
| 1260 *dest_scan++ = *src_scan++; | 1801 int src_Bpp, |
| 1261 *dest_scan++ = *src_scan++; | 1802 FX_LPBYTE src_cache_scan, |
| 1262 dest_scan += dest_gap; | 1803 void* pIccTransform) { |
| 1263 continue; | 1804 ICodec_IccModule* pIccModule = |
| 1264 } | 1805 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1265 if (src_alpha == 0) { | 1806 if (src_Bpp == 3) { |
| 1266 dest_scan += dest_Bpp; | 1807 pIccModule->TranslateScanline( |
| 1267 src_scan += 3; | 1808 pIccTransform, src_cache_scan, src_scan, width); |
| 1268 continue; | 1809 } else { |
| 1269 } | 1810 FX_LPBYTE dp = src_cache_scan; |
| 1270 for (int color = 0; color < 3; color ++) { | 1811 for (int col = 0; col < width; col++) { |
| 1271 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha)
; | 1812 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); |
| 1272 dest_scan ++; | 1813 src_scan += 4; |
| 1273 src_scan ++; | 1814 dp += 3; |
| 1274 } | 1815 } |
| 1275 dest_scan += dest_gap; | 1816 } |
| 1276 } | 1817 _CompositeRow_Rgb2Rgb_Blend_NoClip( |
| 1277 } | 1818 dest_scan, src_cache_scan, width, blend_type, dest_Bpp, 3); |
| 1278 } | 1819 } |
| 1279 inline void _CompositeRow_Rgb2Rgb_Blend_NoClip(FX_LPBYTE dest_scan, FX_LPCBYTE s
rc_scan, int width, int blend_type, int dest_Bpp, int src_Bpp) | 1820 inline void _CompositeRow_Rgb2Rgb_Blend_Clip_Transform(FX_LPBYTE dest_scan, |
| 1280 { | 1821 FX_LPCBYTE src_scan, |
| 1281 int blended_colors[3]; | 1822 int width, |
| 1282 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 1823 int blend_type, |
| 1283 int dest_gap = dest_Bpp - 3; | 1824 int dest_Bpp, |
| 1284 int src_gap = src_Bpp - 3; | 1825 int src_Bpp, |
| 1285 for (int col = 0; col < width; col ++) { | 1826 FX_LPCBYTE clip_scan, |
| 1827 FX_LPBYTE src_cache_scan, |
| 1828 void* pIccTransform) { |
| 1829 ICodec_IccModule* pIccModule = |
| 1830 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1831 if (src_Bpp == 3) { |
| 1832 pIccModule->TranslateScanline( |
| 1833 pIccTransform, src_cache_scan, src_scan, width); |
| 1834 } else { |
| 1835 FX_LPBYTE dp = src_cache_scan; |
| 1836 for (int col = 0; col < width; col++) { |
| 1837 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); |
| 1838 src_scan += 4; |
| 1839 dp += 3; |
| 1840 } |
| 1841 } |
| 1842 _CompositeRow_Rgb2Rgb_Blend_Clip( |
| 1843 dest_scan, src_cache_scan, width, blend_type, dest_Bpp, 3, clip_scan); |
| 1844 } |
| 1845 inline void _CompositeRow_Rgb2Rgb_NoBlend_NoClip_Transform( |
| 1846 FX_LPBYTE dest_scan, |
| 1847 FX_LPCBYTE src_scan, |
| 1848 int width, |
| 1849 int dest_Bpp, |
| 1850 int src_Bpp, |
| 1851 FX_LPBYTE src_cache_scan, |
| 1852 void* pIccTransform) { |
| 1853 ICodec_IccModule* pIccModule = |
| 1854 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1855 if (src_Bpp == 3) { |
| 1856 pIccModule->TranslateScanline( |
| 1857 pIccTransform, src_cache_scan, src_scan, width); |
| 1858 } else { |
| 1859 FX_LPBYTE dp = src_cache_scan; |
| 1860 for (int col = 0; col < width; col++) { |
| 1861 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); |
| 1862 src_scan += 4; |
| 1863 dp += 3; |
| 1864 } |
| 1865 } |
| 1866 _CompositeRow_Rgb2Rgb_NoBlend_NoClip( |
| 1867 dest_scan, src_cache_scan, width, dest_Bpp, 3); |
| 1868 } |
| 1869 inline void _CompositeRow_Rgb2Rgb_NoBlend_Clip_Transform( |
| 1870 FX_LPBYTE dest_scan, |
| 1871 FX_LPCBYTE src_scan, |
| 1872 int width, |
| 1873 int dest_Bpp, |
| 1874 int src_Bpp, |
| 1875 FX_LPCBYTE clip_scan, |
| 1876 FX_LPBYTE src_cache_scan, |
| 1877 void* pIccTransform) { |
| 1878 ICodec_IccModule* pIccModule = |
| 1879 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1880 if (src_Bpp == 3) { |
| 1881 pIccModule->TranslateScanline( |
| 1882 pIccTransform, src_cache_scan, src_scan, width); |
| 1883 } else { |
| 1884 FX_LPBYTE dp = src_cache_scan; |
| 1885 for (int col = 0; col < width; col++) { |
| 1886 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); |
| 1887 src_scan += 4; |
| 1888 dp += 3; |
| 1889 } |
| 1890 } |
| 1891 _CompositeRow_Rgb2Rgb_NoBlend_Clip( |
| 1892 dest_scan, src_cache_scan, width, dest_Bpp, 3, clip_scan); |
| 1893 } |
| 1894 inline void _CompositeRow_8bppPal2Gray(FX_LPBYTE dest_scan, |
| 1895 FX_LPCBYTE src_scan, |
| 1896 FX_LPCBYTE pPalette, |
| 1897 int pixel_count, |
| 1898 int blend_type, |
| 1899 FX_LPCBYTE clip_scan, |
| 1900 FX_LPCBYTE src_alpha_scan) { |
| 1901 if (src_alpha_scan) { |
| 1902 if (blend_type) { |
| 1903 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1904 int blended_color; |
| 1905 for (int col = 0; col < pixel_count; col++) { |
| 1906 FX_BYTE gray = pPalette[*src_scan]; |
| 1907 int src_alpha = *src_alpha_scan++; |
| 1908 if (clip_scan) { |
| 1909 src_alpha = clip_scan[col] * src_alpha / 255; |
| 1910 } |
| 1286 if (bNonseparableBlend) { | 1911 if (bNonseparableBlend) { |
| 1287 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | 1912 blended_color = |
| 1288 } | 1913 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 1289 for (int color = 0; color < 3; color ++) { | 1914 } |
| 1290 int back_color = *dest_scan; | 1915 gray = bNonseparableBlend ? blended_color |
| 1291 int src_color = *src_scan; | 1916 : _BLEND(blend_type, *dest_scan, gray); |
| 1292 int blended = bNonseparableBlend ? blended_colors[color] : | 1917 if (src_alpha) { |
| 1293 _BLEND(blend_type, back_color, src_color); | 1918 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 1294 *dest_scan = blended; | 1919 } else { |
| 1295 dest_scan ++; | 1920 *dest_scan = gray; |
| 1296 src_scan ++; | 1921 } |
| 1297 } | 1922 dest_scan++; |
| 1298 dest_scan += dest_gap; | 1923 src_scan++; |
| 1299 src_scan += src_gap; | 1924 } |
| 1300 } | 1925 return; |
| 1301 } | 1926 } |
| 1302 inline void _CompositeRow_Rgb2Rgb_Blend_Clip(FX_LPBYTE dest_scan, FX_LPCBYTE src
_scan, int width, int blend_type, int dest_Bpp, int src_Bpp, FX_LPCBYTE clip_sca
n) | 1927 for (int col = 0; col < pixel_count; col++) { |
| 1303 { | 1928 FX_BYTE gray = pPalette[*src_scan]; |
| 1304 int blended_colors[3]; | 1929 int src_alpha = *src_alpha_scan++; |
| 1305 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 1930 if (clip_scan) { |
| 1306 int dest_gap = dest_Bpp - 3; | 1931 src_alpha = clip_scan[col] * src_alpha / 255; |
| 1307 int src_gap = src_Bpp - 3; | 1932 } |
| 1308 for (int col = 0; col < width; col ++) { | 1933 if (src_alpha) { |
| 1309 FX_BYTE src_alpha = *clip_scan ++; | 1934 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 1935 } else { |
| 1936 *dest_scan = gray; |
| 1937 } |
| 1938 dest_scan++; |
| 1939 src_scan++; |
| 1940 } |
| 1941 } else { |
| 1942 if (blend_type) { |
| 1943 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1944 int blended_color; |
| 1945 for (int col = 0; col < pixel_count; col++) { |
| 1946 FX_BYTE gray = pPalette[*src_scan]; |
| 1947 if (bNonseparableBlend) { |
| 1948 blended_color = |
| 1949 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 1950 } |
| 1951 gray = bNonseparableBlend ? blended_color |
| 1952 : _BLEND(blend_type, *dest_scan, gray); |
| 1953 if (clip_scan && clip_scan[col] < 255) { |
| 1954 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); |
| 1955 } else { |
| 1956 *dest_scan = gray; |
| 1957 } |
| 1958 dest_scan++; |
| 1959 src_scan++; |
| 1960 } |
| 1961 return; |
| 1962 } |
| 1963 for (int col = 0; col < pixel_count; col++) { |
| 1964 FX_BYTE gray = pPalette[*src_scan]; |
| 1965 if (clip_scan && clip_scan[col] < 255) { |
| 1966 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); |
| 1967 } else { |
| 1968 *dest_scan = gray; |
| 1969 } |
| 1970 dest_scan++; |
| 1971 src_scan++; |
| 1972 } |
| 1973 } |
| 1974 } |
| 1975 inline void _CompositeRow_8bppPal2Graya(FX_LPBYTE dest_scan, |
| 1976 FX_LPCBYTE src_scan, |
| 1977 FX_LPCBYTE pPalette, |
| 1978 int pixel_count, |
| 1979 int blend_type, |
| 1980 FX_LPCBYTE clip_scan, |
| 1981 FX_LPBYTE dest_alpha_scan, |
| 1982 FX_LPCBYTE src_alpha_scan) { |
| 1983 if (src_alpha_scan) { |
| 1984 if (blend_type) { |
| 1985 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1986 int blended_color; |
| 1987 for (int col = 0; col < pixel_count; col++) { |
| 1988 FX_BYTE gray = pPalette[*src_scan]; |
| 1989 src_scan++; |
| 1990 FX_BYTE back_alpha = *dest_alpha_scan; |
| 1991 if (back_alpha == 0) { |
| 1992 int src_alpha = *src_alpha_scan++; |
| 1993 if (clip_scan) { |
| 1994 src_alpha = clip_scan[col] * src_alpha / 255; |
| 1995 } |
| 1996 if (src_alpha) { |
| 1997 *dest_scan = gray; |
| 1998 *dest_alpha_scan = src_alpha; |
| 1999 } |
| 2000 dest_scan++; |
| 2001 dest_alpha_scan++; |
| 2002 continue; |
| 2003 } |
| 2004 FX_BYTE src_alpha = *src_alpha_scan++; |
| 2005 if (clip_scan) { |
| 2006 src_alpha = clip_scan[col] * src_alpha / 255; |
| 2007 } |
| 1310 if (src_alpha == 0) { | 2008 if (src_alpha == 0) { |
| 1311 dest_scan += dest_Bpp; | 2009 dest_scan++; |
| 1312 src_scan += src_Bpp; | 2010 dest_alpha_scan++; |
| 1313 continue; | 2011 continue; |
| 1314 } | 2012 } |
| 2013 *dest_alpha_scan = |
| 2014 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2015 int alpha_ratio = src_alpha * 255 / (*dest_alpha_scan); |
| 1315 if (bNonseparableBlend) { | 2016 if (bNonseparableBlend) { |
| 1316 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | 2017 blended_color = |
| 1317 } | 2018 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 1318 for (int color = 0; color < 3; color ++) { | 2019 } |
| 1319 int src_color = *src_scan; | 2020 gray = bNonseparableBlend ? blended_color |
| 1320 int back_color = *dest_scan; | 2021 : _BLEND(blend_type, *dest_scan, gray); |
| 1321 int blended = bNonseparableBlend ? blended_colors[color] : | 2022 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 1322 _BLEND(blend_type, back_color, src_color); | 2023 dest_alpha_scan++; |
| 1323 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); | 2024 dest_scan++; |
| 1324 dest_scan ++; | 2025 } |
| 1325 src_scan ++; | 2026 return; |
| 1326 } | 2027 } |
| 1327 dest_scan += dest_gap; | 2028 for (int col = 0; col < pixel_count; col++) { |
| 1328 src_scan += src_gap; | 2029 FX_BYTE gray = pPalette[*src_scan]; |
| 1329 } | 2030 src_scan++; |
| 1330 } | 2031 FX_BYTE back_alpha = *dest_alpha_scan; |
| 1331 inline void _CompositeRow_Rgb2Rgb_NoBlend_NoClip(FX_LPBYTE dest_scan, FX_LPCBYTE
src_scan, int width, int dest_Bpp, int src_Bpp) | 2032 if (back_alpha == 0) { |
| 1332 { | 2033 int src_alpha = *src_alpha_scan++; |
| 1333 if (dest_Bpp == src_Bpp) { | 2034 if (clip_scan) { |
| 1334 FXSYS_memcpy32(dest_scan, src_scan, width * dest_Bpp); | 2035 src_alpha = clip_scan[col] * src_alpha / 255; |
| 1335 return; | 2036 } |
| 1336 } | 2037 if (src_alpha) { |
| 1337 for (int col = 0; col < width; col ++) { | 2038 *dest_scan = gray; |
| 1338 dest_scan[0] = src_scan[0]; | 2039 *dest_alpha_scan = src_alpha; |
| 1339 dest_scan[1] = src_scan[1]; | 2040 } |
| 1340 dest_scan[2] = src_scan[2]; | 2041 dest_scan++; |
| 1341 dest_scan += dest_Bpp; | 2042 dest_alpha_scan++; |
| 1342 src_scan += src_Bpp; | 2043 continue; |
| 1343 } | 2044 } |
| 1344 } | 2045 FX_BYTE src_alpha = *src_alpha_scan++; |
| 1345 inline void _CompositeRow_Rgb2Rgb_NoBlend_Clip(FX_LPBYTE dest_scan, FX_LPCBYTE s
rc_scan, int width, int dest_Bpp, int src_Bpp, FX_LPCBYTE clip_scan) | 2046 if (clip_scan) { |
| 1346 { | 2047 src_alpha = clip_scan[col] * src_alpha / 255; |
| 1347 for (int col = 0; col < width; col ++) { | 2048 } |
| 1348 int src_alpha = clip_scan[col]; | 2049 if (src_alpha == 0) { |
| 1349 if (src_alpha == 255) { | 2050 dest_scan++; |
| 1350 dest_scan[0] = src_scan[0]; | 2051 dest_alpha_scan++; |
| 1351 dest_scan[1] = src_scan[1]; | 2052 continue; |
| 1352 dest_scan[2] = src_scan[2]; | 2053 } |
| 1353 } else if (src_alpha) { | 2054 *dest_alpha_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 1354 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha); | 2055 int alpha_ratio = src_alpha * 255 / (*dest_alpha_scan); |
| 1355 dest_scan ++; | 2056 dest_alpha_scan++; |
| 1356 src_scan ++; | 2057 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 1357 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha); | 2058 dest_scan++; |
| 1358 dest_scan ++; | 2059 } |
| 1359 src_scan ++; | 2060 } else { |
| 1360 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha); | |
| 1361 dest_scan += dest_Bpp - 2; | |
| 1362 src_scan += src_Bpp - 2; | |
| 1363 continue; | |
| 1364 } | |
| 1365 dest_scan += dest_Bpp; | |
| 1366 src_scan += src_Bpp; | |
| 1367 } | |
| 1368 } | |
| 1369 void _CompositeRow_Argb2Argb_Transform(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan,
int pixel_count, int blend_type, FX_LPCBYTE clip_scan, | |
| 1370 FX_LPBYTE dest_alpha_scan, FX_LPCBYTE src
_alpha_scan, FX_LPBYTE src_cache_scan, void* pIccTransform) | |
| 1371 { | |
| 1372 FX_LPBYTE dp = src_cache_scan; | |
| 1373 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1374 if (src_alpha_scan) { | |
| 1375 if (dest_alpha_scan == NULL) { | |
| 1376 for (int col = 0; col < pixel_count; col ++) { | |
| 1377 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); | |
| 1378 dp[3] = *src_alpha_scan++; | |
| 1379 src_scan += 3; | |
| 1380 dp += 4; | |
| 1381 } | |
| 1382 src_alpha_scan = NULL; | |
| 1383 } else { | |
| 1384 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_cou
nt); | |
| 1385 } | |
| 1386 } else { | |
| 1387 if (dest_alpha_scan == NULL) { | |
| 1388 for (int col = 0; col < pixel_count; col ++) { | |
| 1389 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); | |
| 1390 dp[3] = src_scan[3]; | |
| 1391 src_scan += 4; | |
| 1392 dp += 4; | |
| 1393 } | |
| 1394 } else { | |
| 1395 int blended_colors[3]; | |
| 1396 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 1397 for (int col = 0; col < pixel_count; col ++) { | |
| 1398 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src
_scan, 1); | |
| 1399 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 1400 if (back_alpha == 0) { | |
| 1401 if (clip_scan) { | |
| 1402 int src_alpha = clip_scan[col] * src_scan[3] / 255; | |
| 1403 *dest_alpha_scan = src_alpha; | |
| 1404 *dest_scan++ = *src_cache_scan++; | |
| 1405 *dest_scan++ = *src_cache_scan++; | |
| 1406 *dest_scan++ = *src_cache_scan++; | |
| 1407 } else { | |
| 1408 *dest_alpha_scan = src_scan[3]; | |
| 1409 *dest_scan++ = *src_cache_scan++; | |
| 1410 *dest_scan++ = *src_cache_scan++; | |
| 1411 *dest_scan++ = *src_cache_scan++; | |
| 1412 } | |
| 1413 dest_alpha_scan ++; | |
| 1414 src_scan += 4; | |
| 1415 continue; | |
| 1416 } | |
| 1417 FX_BYTE src_alpha; | |
| 1418 if (clip_scan == NULL) { | |
| 1419 src_alpha = src_scan[3]; | |
| 1420 } else { | |
| 1421 src_alpha = clip_scan[col] * src_scan[3] / 255; | |
| 1422 } | |
| 1423 src_scan += 4; | |
| 1424 if (src_alpha == 0) { | |
| 1425 dest_scan += 3; | |
| 1426 src_cache_scan += 3; | |
| 1427 dest_alpha_scan ++; | |
| 1428 continue; | |
| 1429 } | |
| 1430 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_a
lpha / 255; | |
| 1431 *dest_alpha_scan ++ = dest_alpha; | |
| 1432 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 1433 if (bNonseparableBlend) { | |
| 1434 _RGB_Blend(blend_type, src_cache_scan, dest_scan, blended_co
lors); | |
| 1435 } | |
| 1436 for (int color = 0; color < 3; color ++) { | |
| 1437 if (blend_type) { | |
| 1438 int blended = bNonseparableBlend ? blended_colors[color]
: | |
| 1439 _BLEND(blend_type, *dest_scan, *src_cache_
scan); | |
| 1440 blended = FXDIB_ALPHA_MERGE(*src_cache_scan, blended, ba
ck_alpha); | |
| 1441 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alph
a_ratio); | |
| 1442 } else { | |
| 1443 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_cache_sc
an, alpha_ratio); | |
| 1444 } | |
| 1445 dest_scan ++; | |
| 1446 src_cache_scan ++; | |
| 1447 } | |
| 1448 } | |
| 1449 return; | |
| 1450 } | |
| 1451 } | |
| 1452 _CompositeRow_Argb2Argb(dest_scan, src_cache_scan, pixel_count, blend_type,
clip_scan, dest_alpha_scan, src_alpha_scan); | |
| 1453 } | |
| 1454 void _CompositeRow_Rgb2Argb_Blend_NoClip_Transform(FX_LPBYTE dest_scan, FX_LPCBY
TE src_scan, int width, int blend_type, int src_Bpp, | |
| 1455 FX_LPBYTE dest_alpha_scan, FX_LPBYTE src_cache_scan, void* pIccTransform
) | |
| 1456 { | |
| 1457 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1458 if (src_Bpp == 3) { | |
| 1459 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, w
idth); | |
| 1460 } else { | |
| 1461 FX_LPBYTE dp = src_cache_scan; | |
| 1462 for (int col = 0; col < width; col ++) { | |
| 1463 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); | |
| 1464 src_scan += 4; | |
| 1465 dp += 3; | |
| 1466 } | |
| 1467 } | |
| 1468 _CompositeRow_Rgb2Argb_Blend_NoClip(dest_scan, src_cache_scan, width, blend_
type, 3, dest_alpha_scan); | |
| 1469 } | |
| 1470 inline void _CompositeRow_Rgb2Argb_Blend_Clip_Transform(FX_LPBYTE dest_scan, FX_
LPCBYTE src_scan, int width, int blend_type, int src_Bpp, FX_LPCBYTE clip_scan, | |
| 1471 FX_LPBYTE dest_alpha_scan, FX_LPBYTE src_cache_scan, void* pIccTransform
) | |
| 1472 { | |
| 1473 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1474 if (src_Bpp == 3) { | |
| 1475 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, w
idth); | |
| 1476 } else { | |
| 1477 FX_LPBYTE dp = src_cache_scan; | |
| 1478 for (int col = 0; col < width; col ++) { | |
| 1479 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); | |
| 1480 src_scan += 4; | |
| 1481 dp += 3; | |
| 1482 } | |
| 1483 } | |
| 1484 _CompositeRow_Rgb2Argb_Blend_Clip(dest_scan, src_cache_scan, width, blend_ty
pe, 3, clip_scan, dest_alpha_scan); | |
| 1485 } | |
| 1486 inline void _CompositeRow_Rgb2Argb_NoBlend_Clip_Transform(FX_LPBYTE dest_scan, F
X_LPCBYTE src_scan, int width, int src_Bpp, FX_LPCBYTE clip_scan, | |
| 1487 FX_LPBYTE dest_alpha_scan, FX_LPBYTE src_cache_scan, void* pIccTransform
) | |
| 1488 { | |
| 1489 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1490 if (src_Bpp == 3) { | |
| 1491 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, w
idth); | |
| 1492 } else { | |
| 1493 FX_LPBYTE dp = src_cache_scan; | |
| 1494 for (int col = 0; col < width; col ++) { | |
| 1495 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); | |
| 1496 src_scan += 4; | |
| 1497 dp += 3; | |
| 1498 } | |
| 1499 } | |
| 1500 _CompositeRow_Rgb2Argb_NoBlend_Clip(dest_scan, src_cache_scan, width, 3, cli
p_scan, dest_alpha_scan); | |
| 1501 } | |
| 1502 inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip_Transform(FX_LPBYTE dest_scan,
FX_LPCBYTE src_scan, int width, int src_Bpp, | |
| 1503 FX_LPBYTE dest_alpha_scan, FX_LPBYTE src_cache_scan, void* pIccTransform
) | |
| 1504 { | |
| 1505 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1506 if (src_Bpp == 3) { | |
| 1507 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, w
idth); | |
| 1508 } else { | |
| 1509 FX_LPBYTE dp = src_cache_scan; | |
| 1510 for (int col = 0; col < width; col ++) { | |
| 1511 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); | |
| 1512 src_scan += 4; | |
| 1513 dp += 3; | |
| 1514 } | |
| 1515 } | |
| 1516 _CompositeRow_Rgb2Argb_NoBlend_NoClip(dest_scan, src_cache_scan, width, 3, d
est_alpha_scan); | |
| 1517 } | |
| 1518 inline void _CompositeRow_Argb2Rgb_Blend_Transform(FX_LPBYTE dest_scan, FX_LPCBY
TE src_scan, int width, int blend_type, int dest_Bpp, FX_LPCBYTE clip_scan, | |
| 1519 FX_LPCBYTE src_alpha_scan, FX_LPBYTE src_cache_scan, void* pIccTransform
) | |
| 1520 { | |
| 1521 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1522 if (src_alpha_scan) { | |
| 1523 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, w
idth); | |
| 1524 } else { | |
| 1525 int blended_colors[3]; | |
| 1526 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 1527 int dest_gap = dest_Bpp - 3; | |
| 1528 for (int col = 0; col < width; col ++) { | |
| 1529 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_sca
n, 1); | |
| 1530 FX_BYTE src_alpha; | |
| 1531 if (clip_scan) { | |
| 1532 src_alpha = src_scan[3] * (*clip_scan++) / 255; | |
| 1533 } else { | |
| 1534 src_alpha = src_scan[3]; | |
| 1535 } | |
| 1536 src_scan += 4; | |
| 1537 if (src_alpha == 0) { | |
| 1538 dest_scan += dest_Bpp; | |
| 1539 src_cache_scan += 3; | |
| 1540 continue; | |
| 1541 } | |
| 1542 if (bNonseparableBlend) { | |
| 1543 _RGB_Blend(blend_type, src_cache_scan, dest_scan, blended_colors
); | |
| 1544 } | |
| 1545 for (int color = 0; color < 3; color ++) { | |
| 1546 int back_color = *dest_scan; | |
| 1547 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 1548 _BLEND(blend_type, back_color, *src_cache_scan); | |
| 1549 *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); | |
| 1550 dest_scan ++; | |
| 1551 src_cache_scan ++; | |
| 1552 } | |
| 1553 dest_scan += dest_gap; | |
| 1554 } | |
| 1555 return; | |
| 1556 } | |
| 1557 _CompositeRow_Argb2Rgb_Blend(dest_scan, src_cache_scan, width, blend_type, d
est_Bpp, clip_scan, src_alpha_scan); | |
| 1558 } | |
| 1559 inline void _CompositeRow_Argb2Rgb_NoBlend_Transform(FX_LPBYTE dest_scan, FX_LPC
BYTE src_scan, int width, int dest_Bpp, FX_LPCBYTE clip_scan, | |
| 1560 FX_LPCBYTE src_alpha_scan, FX_LPBYTE src_cache_scan, void* pIccTransform
) | |
| 1561 { | |
| 1562 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1563 if (src_alpha_scan) { | |
| 1564 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, w
idth); | |
| 1565 } else { | |
| 1566 int dest_gap = dest_Bpp - 3; | |
| 1567 for (int col = 0; col < width; col ++) { | |
| 1568 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_sca
n, 1); | |
| 1569 FX_BYTE src_alpha; | |
| 1570 if (clip_scan) { | |
| 1571 src_alpha = src_scan[3] * (*clip_scan++) / 255; | |
| 1572 } else { | |
| 1573 src_alpha = src_scan[3]; | |
| 1574 } | |
| 1575 src_scan += 4; | |
| 1576 if (src_alpha == 255) { | |
| 1577 *dest_scan++ = *src_cache_scan++; | |
| 1578 *dest_scan++ = *src_cache_scan++; | |
| 1579 *dest_scan++ = *src_cache_scan++; | |
| 1580 dest_scan += dest_gap; | |
| 1581 continue; | |
| 1582 } | |
| 1583 if (src_alpha == 0) { | |
| 1584 dest_scan += dest_Bpp; | |
| 1585 src_cache_scan += 3; | |
| 1586 continue; | |
| 1587 } | |
| 1588 for (int color = 0; color < 3; color ++) { | |
| 1589 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_cache_scan, src_
alpha); | |
| 1590 dest_scan ++; | |
| 1591 src_cache_scan ++; | |
| 1592 } | |
| 1593 dest_scan += dest_gap; | |
| 1594 } | |
| 1595 return; | |
| 1596 } | |
| 1597 _CompositeRow_Argb2Rgb_NoBlend(dest_scan, src_cache_scan, width, dest_Bpp, c
lip_scan, src_alpha_scan); | |
| 1598 } | |
| 1599 inline void _CompositeRow_Rgb2Rgb_Blend_NoClip_Transform(FX_LPBYTE dest_scan, FX
_LPCBYTE src_scan, int width, int blend_type, int dest_Bpp, int src_Bpp, | |
| 1600 FX_LPBYTE src_cache_scan, void* pIccTransform) | |
| 1601 { | |
| 1602 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1603 if (src_Bpp == 3) { | |
| 1604 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, w
idth); | |
| 1605 } else { | |
| 1606 FX_LPBYTE dp = src_cache_scan; | |
| 1607 for (int col = 0; col < width; col ++) { | |
| 1608 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); | |
| 1609 src_scan += 4; | |
| 1610 dp += 3; | |
| 1611 } | |
| 1612 } | |
| 1613 _CompositeRow_Rgb2Rgb_Blend_NoClip(dest_scan, src_cache_scan, width, blend_t
ype, dest_Bpp, 3); | |
| 1614 } | |
| 1615 inline void _CompositeRow_Rgb2Rgb_Blend_Clip_Transform(FX_LPBYTE dest_scan, FX_L
PCBYTE src_scan, int width, int blend_type, int dest_Bpp, int src_Bpp, FX_LPCBYT
E clip_scan, | |
| 1616 FX_LPBYTE src_cache_scan, void* pIccTransform) | |
| 1617 { | |
| 1618 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1619 if (src_Bpp == 3) { | |
| 1620 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, w
idth); | |
| 1621 } else { | |
| 1622 FX_LPBYTE dp = src_cache_scan; | |
| 1623 for (int col = 0; col < width; col ++) { | |
| 1624 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); | |
| 1625 src_scan += 4; | |
| 1626 dp += 3; | |
| 1627 } | |
| 1628 } | |
| 1629 _CompositeRow_Rgb2Rgb_Blend_Clip(dest_scan, src_cache_scan, width, blend_typ
e, dest_Bpp, 3, clip_scan); | |
| 1630 } | |
| 1631 inline void _CompositeRow_Rgb2Rgb_NoBlend_NoClip_Transform(FX_LPBYTE dest_scan,
FX_LPCBYTE src_scan, int width, int dest_Bpp, int src_Bpp, | |
| 1632 FX_LPBYTE src_cache_scan, void* pIccTransform) | |
| 1633 { | |
| 1634 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1635 if (src_Bpp == 3) { | |
| 1636 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, w
idth); | |
| 1637 } else { | |
| 1638 FX_LPBYTE dp = src_cache_scan; | |
| 1639 for (int col = 0; col < width; col ++) { | |
| 1640 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); | |
| 1641 src_scan += 4; | |
| 1642 dp += 3; | |
| 1643 } | |
| 1644 } | |
| 1645 _CompositeRow_Rgb2Rgb_NoBlend_NoClip(dest_scan, src_cache_scan, width, dest_
Bpp, 3); | |
| 1646 } | |
| 1647 inline void _CompositeRow_Rgb2Rgb_NoBlend_Clip_Transform(FX_LPBYTE dest_scan, FX
_LPCBYTE src_scan, int width, int dest_Bpp, int src_Bpp, FX_LPCBYTE clip_scan, | |
| 1648 FX_LPBYTE src_cache_scan, void* pIccTransform) | |
| 1649 { | |
| 1650 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIcc
Module(); | |
| 1651 if (src_Bpp == 3) { | |
| 1652 pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, w
idth); | |
| 1653 } else { | |
| 1654 FX_LPBYTE dp = src_cache_scan; | |
| 1655 for (int col = 0; col < width; col ++) { | |
| 1656 pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); | |
| 1657 src_scan += 4; | |
| 1658 dp += 3; | |
| 1659 } | |
| 1660 } | |
| 1661 _CompositeRow_Rgb2Rgb_NoBlend_Clip(dest_scan, src_cache_scan, width, dest_Bp
p, 3, clip_scan); | |
| 1662 } | |
| 1663 inline void _CompositeRow_8bppPal2Gray(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan,
FX_LPCBYTE pPalette, int pixel_count, | |
| 1664 int blend_type, FX_LPCBYTE clip_scan, | |
| 1665 FX_LPCBYTE src_alpha_scan) | |
| 1666 { | |
| 1667 if (src_alpha_scan) { | |
| 1668 if (blend_type) { | |
| 1669 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 1670 int blended_color; | |
| 1671 for (int col = 0; col < pixel_count; col ++) { | |
| 1672 FX_BYTE gray = pPalette[*src_scan]; | |
| 1673 int src_alpha = *src_alpha_scan++; | |
| 1674 if (clip_scan) { | |
| 1675 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 1676 } | |
| 1677 if (bNonseparableBlend) { | |
| 1678 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? gray
: *dest_scan; | |
| 1679 } | |
| 1680 gray = bNonseparableBlend ? blended_color : _BLEND(blend_type, *
dest_scan, gray); | |
| 1681 if (src_alpha) { | |
| 1682 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | |
| 1683 } else { | |
| 1684 *dest_scan = gray; | |
| 1685 } | |
| 1686 dest_scan ++; | |
| 1687 src_scan ++; | |
| 1688 } | |
| 1689 return; | |
| 1690 } | |
| 1691 for (int col = 0; col < pixel_count; col ++) { | |
| 1692 FX_BYTE gray = pPalette[*src_scan]; | |
| 1693 int src_alpha = *src_alpha_scan++; | |
| 1694 if (clip_scan) { | |
| 1695 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 1696 } | |
| 1697 if (src_alpha) { | |
| 1698 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | |
| 1699 } else { | |
| 1700 *dest_scan = gray; | |
| 1701 } | |
| 1702 dest_scan ++; | |
| 1703 src_scan ++; | |
| 1704 } | |
| 1705 } else { | |
| 1706 if (blend_type) { | |
| 1707 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 1708 int blended_color; | |
| 1709 for (int col = 0; col < pixel_count; col ++) { | |
| 1710 FX_BYTE gray = pPalette[*src_scan]; | |
| 1711 if (bNonseparableBlend) { | |
| 1712 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? gray
: *dest_scan; | |
| 1713 } | |
| 1714 gray = bNonseparableBlend ? blended_color : _BLEND(blend_type, *
dest_scan, gray); | |
| 1715 if (clip_scan && clip_scan[col] < 255) { | |
| 1716 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[c
ol]); | |
| 1717 } else { | |
| 1718 *dest_scan = gray; | |
| 1719 } | |
| 1720 dest_scan ++; | |
| 1721 src_scan ++; | |
| 1722 } | |
| 1723 return; | |
| 1724 } | |
| 1725 for (int col = 0; col < pixel_count; col ++) { | |
| 1726 FX_BYTE gray = pPalette[*src_scan]; | |
| 1727 if (clip_scan && clip_scan[col] < 255) { | |
| 1728 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col])
; | |
| 1729 } else { | |
| 1730 *dest_scan = gray; | |
| 1731 } | |
| 1732 dest_scan ++; | |
| 1733 src_scan ++; | |
| 1734 } | |
| 1735 } | |
| 1736 } | |
| 1737 inline void _CompositeRow_8bppPal2Graya(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan
, FX_LPCBYTE pPalette, int pixel_count, | |
| 1738 int blend_type, FX_LPCBYTE clip_scan, | |
| 1739 FX_LPBYTE dest_alpha_scan, FX_LPCBYTE sr
c_alpha_scan) | |
| 1740 { | |
| 1741 if (src_alpha_scan) { | |
| 1742 if (blend_type) { | |
| 1743 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 1744 int blended_color; | |
| 1745 for (int col = 0; col < pixel_count; col ++) { | |
| 1746 FX_BYTE gray = pPalette[*src_scan]; | |
| 1747 src_scan ++; | |
| 1748 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 1749 if (back_alpha == 0) { | |
| 1750 int src_alpha = *src_alpha_scan ++; | |
| 1751 if (clip_scan) { | |
| 1752 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 1753 } | |
| 1754 if (src_alpha) { | |
| 1755 *dest_scan = gray; | |
| 1756 *dest_alpha_scan = src_alpha; | |
| 1757 } | |
| 1758 dest_scan ++; | |
| 1759 dest_alpha_scan ++; | |
| 1760 continue; | |
| 1761 } | |
| 1762 FX_BYTE src_alpha = *src_alpha_scan++; | |
| 1763 if (clip_scan) { | |
| 1764 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 1765 } | |
| 1766 if (src_alpha == 0) { | |
| 1767 dest_scan ++; | |
| 1768 dest_alpha_scan ++; | |
| 1769 continue; | |
| 1770 } | |
| 1771 *dest_alpha_scan = back_alpha + src_alpha - back_alpha * src_alp
ha / 255; | |
| 1772 int alpha_ratio = src_alpha * 255 / (*dest_alpha_scan); | |
| 1773 if (bNonseparableBlend) { | |
| 1774 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? gray
: *dest_scan; | |
| 1775 } | |
| 1776 gray = bNonseparableBlend ? blended_color : _BLEND(blend_type, *
dest_scan, gray); | |
| 1777 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 1778 dest_alpha_scan ++; | |
| 1779 dest_scan ++; | |
| 1780 } | |
| 1781 return; | |
| 1782 } | |
| 1783 for (int col = 0; col < pixel_count; col ++) { | |
| 1784 FX_BYTE gray = pPalette[*src_scan]; | |
| 1785 src_scan ++; | |
| 1786 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 1787 if (back_alpha == 0) { | |
| 1788 int src_alpha = *src_alpha_scan ++; | |
| 1789 if (clip_scan) { | |
| 1790 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 1791 } | |
| 1792 if (src_alpha) { | |
| 1793 *dest_scan = gray; | |
| 1794 *dest_alpha_scan = src_alpha; | |
| 1795 } | |
| 1796 dest_scan ++; | |
| 1797 dest_alpha_scan ++; | |
| 1798 continue; | |
| 1799 } | |
| 1800 FX_BYTE src_alpha = *src_alpha_scan++; | |
| 1801 if (clip_scan) { | |
| 1802 src_alpha = clip_scan[col] * src_alpha / 255; | |
| 1803 } | |
| 1804 if (src_alpha == 0) { | |
| 1805 dest_scan ++; | |
| 1806 dest_alpha_scan ++; | |
| 1807 continue; | |
| 1808 } | |
| 1809 *dest_alpha_scan = back_alpha + src_alpha - back_alpha * src_alpha /
255; | |
| 1810 int alpha_ratio = src_alpha * 255 / (*dest_alpha_scan); | |
| 1811 dest_alpha_scan ++; | |
| 1812 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 1813 dest_scan ++; | |
| 1814 } | |
| 1815 } else { | |
| 1816 if (blend_type) { | |
| 1817 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 1818 int blended_color; | |
| 1819 for (int col = 0; col < pixel_count; col ++) { | |
| 1820 FX_BYTE gray = pPalette[*src_scan]; | |
| 1821 src_scan ++; | |
| 1822 if (clip_scan == NULL || clip_scan[col] == 255) { | |
| 1823 *dest_scan++ = gray; | |
| 1824 *dest_alpha_scan++ = 255; | |
| 1825 continue; | |
| 1826 } | |
| 1827 int src_alpha = clip_scan[col]; | |
| 1828 if (src_alpha == 0) { | |
| 1829 dest_scan ++; | |
| 1830 dest_alpha_scan ++; | |
| 1831 continue; | |
| 1832 } | |
| 1833 int back_alpha = *dest_alpha_scan; | |
| 1834 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_a
lpha / 255; | |
| 1835 *dest_alpha_scan ++ = dest_alpha; | |
| 1836 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 1837 if (bNonseparableBlend) { | |
| 1838 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? gray
: *dest_scan; | |
| 1839 } | |
| 1840 gray = bNonseparableBlend ? blended_color : _BLEND(blend_type, *
dest_scan, gray); | |
| 1841 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 1842 dest_scan ++; | |
| 1843 } | |
| 1844 return; | |
| 1845 } | |
| 1846 for (int col = 0; col < pixel_count; col ++) { | |
| 1847 FX_BYTE gray = pPalette[*src_scan]; | |
| 1848 src_scan ++; | |
| 1849 if (clip_scan == NULL || clip_scan[col] == 255) { | |
| 1850 *dest_scan++ = gray; | |
| 1851 *dest_alpha_scan++ = 255; | |
| 1852 continue; | |
| 1853 } | |
| 1854 int src_alpha = clip_scan[col]; | |
| 1855 if (src_alpha == 0) { | |
| 1856 dest_scan ++; | |
| 1857 dest_alpha_scan ++; | |
| 1858 continue; | |
| 1859 } | |
| 1860 int back_alpha = *dest_alpha_scan; | |
| 1861 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | |
| 1862 *dest_alpha_scan ++ = dest_alpha; | |
| 1863 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 1864 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 1865 dest_scan ++; | |
| 1866 } | |
| 1867 } | |
| 1868 } | |
| 1869 inline void _CompositeRow_1bppPal2Gray(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan,
int src_left, | |
| 1870 FX_LPCBYTE pPalette, int pixel_count, int
blend_type, FX_LPCBYTE clip_scan) | |
| 1871 { | |
| 1872 int reset_gray = pPalette[0]; | |
| 1873 int set_gray = pPalette[1]; | |
| 1874 if (blend_type) { | 2061 if (blend_type) { |
| 1875 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 2062 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1876 int blended_color; | 2063 int blended_color; |
| 1877 for (int col = 0; col < pixel_count; col ++) { | 2064 for (int col = 0; col < pixel_count; col++) { |
| 1878 FX_BYTE gray = (src_scan[(col + src_left) / 8] & (1 << (7 - (col + s
rc_left) % 8))) ? set_gray : reset_gray; | 2065 FX_BYTE gray = pPalette[*src_scan]; |
| 1879 if (bNonseparableBlend) { | 2066 src_scan++; |
| 1880 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *d
est_scan; | |
| 1881 } | |
| 1882 gray = bNonseparableBlend ? blended_color : _BLEND(blend_type, *dest
_scan, gray); | |
| 1883 if (clip_scan && clip_scan[col] < 255) { | |
| 1884 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col])
; | |
| 1885 } else { | |
| 1886 *dest_scan = gray; | |
| 1887 } | |
| 1888 dest_scan ++; | |
| 1889 } | |
| 1890 return; | |
| 1891 } | |
| 1892 for (int col = 0; col < pixel_count; col ++) { | |
| 1893 FX_BYTE gray = (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_l
eft) % 8))) ? set_gray : reset_gray; | |
| 1894 if (clip_scan && clip_scan[col] < 255) { | |
| 1895 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); | |
| 1896 } else { | |
| 1897 *dest_scan = gray; | |
| 1898 } | |
| 1899 dest_scan ++; | |
| 1900 } | |
| 1901 } | |
| 1902 inline void _CompositeRow_1bppPal2Graya(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan
, int src_left, | |
| 1903 FX_LPCBYTE pPalette, int pixel_count, in
t blend_type, FX_LPCBYTE clip_scan, | |
| 1904 FX_LPBYTE dest_alpha_scan) | |
| 1905 { | |
| 1906 int reset_gray = pPalette[0]; | |
| 1907 int set_gray = pPalette[1]; | |
| 1908 if (blend_type) { | |
| 1909 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 1910 int blended_color; | |
| 1911 for (int col = 0; col < pixel_count; col ++) { | |
| 1912 FX_BYTE gray = (src_scan[(col + src_left) / 8] & (1 << (7 - (col + s
rc_left) % 8))) ? set_gray : reset_gray; | |
| 1913 if (clip_scan == NULL || clip_scan[col] == 255) { | |
| 1914 *dest_scan++ = gray; | |
| 1915 *dest_alpha_scan ++ = 255; | |
| 1916 continue; | |
| 1917 } | |
| 1918 int src_alpha = clip_scan[col]; | |
| 1919 if (src_alpha == 0) { | |
| 1920 dest_scan ++; | |
| 1921 dest_alpha_scan ++; | |
| 1922 continue; | |
| 1923 } | |
| 1924 int back_alpha = *dest_alpha_scan; | |
| 1925 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | |
| 1926 *dest_alpha_scan ++ = dest_alpha; | |
| 1927 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 1928 if (bNonseparableBlend) { | |
| 1929 blended_color = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *d
est_scan; | |
| 1930 } | |
| 1931 gray = bNonseparableBlend ? blended_color : _BLEND(blend_type, *dest
_scan, gray); | |
| 1932 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | |
| 1933 dest_scan ++; | |
| 1934 } | |
| 1935 return; | |
| 1936 } | |
| 1937 for (int col = 0; col < pixel_count; col ++) { | |
| 1938 FX_BYTE gray = (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_l
eft) % 8))) ? set_gray : reset_gray; | |
| 1939 if (clip_scan == NULL || clip_scan[col] == 255) { | 2067 if (clip_scan == NULL || clip_scan[col] == 255) { |
| 1940 *dest_scan++ = gray; | 2068 *dest_scan++ = gray; |
| 1941 *dest_alpha_scan ++ = 255; | 2069 *dest_alpha_scan++ = 255; |
| 1942 continue; | 2070 continue; |
| 1943 } | 2071 } |
| 1944 int src_alpha = clip_scan[col]; | 2072 int src_alpha = clip_scan[col]; |
| 1945 if (src_alpha == 0) { | 2073 if (src_alpha == 0) { |
| 1946 dest_scan ++; | 2074 dest_scan++; |
| 1947 dest_alpha_scan ++; | 2075 dest_alpha_scan++; |
| 1948 continue; | 2076 continue; |
| 1949 } | 2077 } |
| 1950 int back_alpha = *dest_alpha_scan; | 2078 int back_alpha = *dest_alpha_scan; |
| 1951 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | 2079 FX_BYTE dest_alpha = |
| 1952 *dest_alpha_scan ++ = dest_alpha; | 2080 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2081 *dest_alpha_scan++ = dest_alpha; |
| 1953 int alpha_ratio = src_alpha * 255 / dest_alpha; | 2082 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2083 if (bNonseparableBlend) { |
| 2084 blended_color = |
| 2085 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 2086 } |
| 2087 gray = bNonseparableBlend ? blended_color |
| 2088 : _BLEND(blend_type, *dest_scan, gray); |
| 1954 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | 2089 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 1955 dest_scan ++; | 2090 dest_scan++; |
| 1956 } | 2091 } |
| 1957 } | 2092 return; |
| 1958 inline void _CompositeRow_8bppRgb2Rgb_NoBlend(FX_LPBYTE dest_scan, FX_LPCBYTE sr
c_scan, FX_DWORD* pPalette, int pixel_count, | 2093 } |
| 1959 int DestBpp, FX_LPCBYTE clip_scan, | 2094 for (int col = 0; col < pixel_count; col++) { |
| 1960 FX_LPCBYTE src_alpha_scan) | 2095 FX_BYTE gray = pPalette[*src_scan]; |
| 1961 { | 2096 src_scan++; |
| 1962 if (src_alpha_scan) { | 2097 if (clip_scan == NULL || clip_scan[col] == 255) { |
| 1963 int dest_gap = DestBpp - 3; | 2098 *dest_scan++ = gray; |
| 1964 FX_ARGB argb = 0; | 2099 *dest_alpha_scan++ = 255; |
| 1965 for (int col = 0; col < pixel_count; col ++) { | 2100 continue; |
| 1966 argb = pPalette[*src_scan]; | 2101 } |
| 1967 int src_r = FXARGB_R(argb); | 2102 int src_alpha = clip_scan[col]; |
| 1968 int src_g = FXARGB_G(argb); | 2103 if (src_alpha == 0) { |
| 1969 int src_b = FXARGB_B(argb); | 2104 dest_scan++; |
| 1970 src_scan ++; | 2105 dest_alpha_scan++; |
| 1971 FX_BYTE src_alpha = 0; | 2106 continue; |
| 1972 if (clip_scan) { | 2107 } |
| 1973 src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255; | 2108 int back_alpha = *dest_alpha_scan; |
| 1974 } else { | 2109 FX_BYTE dest_alpha = |
| 1975 src_alpha = *src_alpha_scan++; | 2110 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 1976 } | 2111 *dest_alpha_scan++ = dest_alpha; |
| 1977 if (src_alpha == 255) { | 2112 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 1978 *dest_scan++ = src_b; | 2113 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 1979 *dest_scan++ = src_g; | 2114 dest_scan++; |
| 1980 *dest_scan++ = src_r; | 2115 } |
| 1981 dest_scan += dest_gap; | 2116 } |
| 1982 continue; | 2117 } |
| 1983 } | 2118 inline void _CompositeRow_1bppPal2Gray(FX_LPBYTE dest_scan, |
| 1984 if (src_alpha == 0) { | 2119 FX_LPCBYTE src_scan, |
| 1985 dest_scan += DestBpp; | 2120 int src_left, |
| 1986 continue; | 2121 FX_LPCBYTE pPalette, |
| 1987 } | 2122 int pixel_count, |
| 1988 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, src_alpha); | 2123 int blend_type, |
| 1989 dest_scan ++; | 2124 FX_LPCBYTE clip_scan) { |
| 1990 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, src_alpha); | 2125 int reset_gray = pPalette[0]; |
| 1991 dest_scan ++; | 2126 int set_gray = pPalette[1]; |
| 1992 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, src_alpha); | 2127 if (blend_type) { |
| 1993 dest_scan ++; | 2128 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1994 dest_scan += dest_gap; | 2129 int blended_color; |
| 1995 } | 2130 for (int col = 0; col < pixel_count; col++) { |
| 1996 } else { | 2131 FX_BYTE gray = |
| 1997 FX_ARGB argb = 0; | 2132 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) |
| 1998 for (int col = 0; col < pixel_count; col ++) { | 2133 ? set_gray |
| 1999 argb = pPalette[*src_scan]; | 2134 : reset_gray; |
| 2000 int src_r = FXARGB_R(argb); | 2135 if (bNonseparableBlend) { |
| 2001 int src_g = FXARGB_G(argb); | 2136 blended_color = |
| 2002 int src_b = FXARGB_B(argb); | 2137 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 2003 if (clip_scan && clip_scan[col] < 255) { | 2138 } |
| 2004 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, clip_scan[col]
); | 2139 gray = bNonseparableBlend ? blended_color |
| 2005 dest_scan ++; | 2140 : _BLEND(blend_type, *dest_scan, gray); |
| 2006 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, clip_scan[col]
); | 2141 if (clip_scan && clip_scan[col] < 255) { |
| 2007 dest_scan ++; | 2142 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); |
| 2008 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, clip_scan[col]
); | 2143 } else { |
| 2009 dest_scan ++; | 2144 *dest_scan = gray; |
| 2010 } else { | 2145 } |
| 2011 *dest_scan++ = src_b; | 2146 dest_scan++; |
| 2012 *dest_scan++ = src_g; | 2147 } |
| 2013 *dest_scan++ = src_r; | 2148 return; |
| 2014 } | 2149 } |
| 2015 if (DestBpp == 4) { | 2150 for (int col = 0; col < pixel_count; col++) { |
| 2016 dest_scan++; | 2151 FX_BYTE gray = |
| 2017 } | 2152 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) |
| 2018 src_scan ++; | 2153 ? set_gray |
| 2019 } | 2154 : reset_gray; |
| 2020 } | 2155 if (clip_scan && clip_scan[col] < 255) { |
| 2021 } | 2156 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); |
| 2022 inline void _CompositeRow_1bppRgb2Rgb_NoBlend(FX_LPBYTE dest_scan, FX_LPCBYTE sr
c_scan, int src_left, | 2157 } else { |
| 2023 FX_DWORD* pPalette, int pixel_count, int DestBpp, FX_LPCBYTE clip_scan) | 2158 *dest_scan = gray; |
| 2024 { | 2159 } |
| 2025 int reset_r, reset_g, reset_b; | 2160 dest_scan++; |
| 2026 int set_r, set_g, set_b; | 2161 } |
| 2162 } |
| 2163 inline void _CompositeRow_1bppPal2Graya(FX_LPBYTE dest_scan, |
| 2164 FX_LPCBYTE src_scan, |
| 2165 int src_left, |
| 2166 FX_LPCBYTE pPalette, |
| 2167 int pixel_count, |
| 2168 int blend_type, |
| 2169 FX_LPCBYTE clip_scan, |
| 2170 FX_LPBYTE dest_alpha_scan) { |
| 2171 int reset_gray = pPalette[0]; |
| 2172 int set_gray = pPalette[1]; |
| 2173 if (blend_type) { |
| 2174 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 2175 int blended_color; |
| 2176 for (int col = 0; col < pixel_count; col++) { |
| 2177 FX_BYTE gray = |
| 2178 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) |
| 2179 ? set_gray |
| 2180 : reset_gray; |
| 2181 if (clip_scan == NULL || clip_scan[col] == 255) { |
| 2182 *dest_scan++ = gray; |
| 2183 *dest_alpha_scan++ = 255; |
| 2184 continue; |
| 2185 } |
| 2186 int src_alpha = clip_scan[col]; |
| 2187 if (src_alpha == 0) { |
| 2188 dest_scan++; |
| 2189 dest_alpha_scan++; |
| 2190 continue; |
| 2191 } |
| 2192 int back_alpha = *dest_alpha_scan; |
| 2193 FX_BYTE dest_alpha = |
| 2194 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2195 *dest_alpha_scan++ = dest_alpha; |
| 2196 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2197 if (bNonseparableBlend) { |
| 2198 blended_color = |
| 2199 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 2200 } |
| 2201 gray = bNonseparableBlend ? blended_color |
| 2202 : _BLEND(blend_type, *dest_scan, gray); |
| 2203 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 2204 dest_scan++; |
| 2205 } |
| 2206 return; |
| 2207 } |
| 2208 for (int col = 0; col < pixel_count; col++) { |
| 2209 FX_BYTE gray = |
| 2210 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) |
| 2211 ? set_gray |
| 2212 : reset_gray; |
| 2213 if (clip_scan == NULL || clip_scan[col] == 255) { |
| 2214 *dest_scan++ = gray; |
| 2215 *dest_alpha_scan++ = 255; |
| 2216 continue; |
| 2217 } |
| 2218 int src_alpha = clip_scan[col]; |
| 2219 if (src_alpha == 0) { |
| 2220 dest_scan++; |
| 2221 dest_alpha_scan++; |
| 2222 continue; |
| 2223 } |
| 2224 int back_alpha = *dest_alpha_scan; |
| 2225 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2226 *dest_alpha_scan++ = dest_alpha; |
| 2227 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2228 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 2229 dest_scan++; |
| 2230 } |
| 2231 } |
| 2232 inline void _CompositeRow_8bppRgb2Rgb_NoBlend(FX_LPBYTE dest_scan, |
| 2233 FX_LPCBYTE src_scan, |
| 2234 FX_DWORD* pPalette, |
| 2235 int pixel_count, |
| 2236 int DestBpp, |
| 2237 FX_LPCBYTE clip_scan, |
| 2238 FX_LPCBYTE src_alpha_scan) { |
| 2239 if (src_alpha_scan) { |
| 2240 int dest_gap = DestBpp - 3; |
| 2241 FX_ARGB argb = 0; |
| 2242 for (int col = 0; col < pixel_count; col++) { |
| 2243 argb = pPalette[*src_scan]; |
| 2244 int src_r = FXARGB_R(argb); |
| 2245 int src_g = FXARGB_G(argb); |
| 2246 int src_b = FXARGB_B(argb); |
| 2247 src_scan++; |
| 2248 FX_BYTE src_alpha = 0; |
| 2249 if (clip_scan) { |
| 2250 src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255; |
| 2251 } else { |
| 2252 src_alpha = *src_alpha_scan++; |
| 2253 } |
| 2254 if (src_alpha == 255) { |
| 2255 *dest_scan++ = src_b; |
| 2256 *dest_scan++ = src_g; |
| 2257 *dest_scan++ = src_r; |
| 2258 dest_scan += dest_gap; |
| 2259 continue; |
| 2260 } |
| 2261 if (src_alpha == 0) { |
| 2262 dest_scan += DestBpp; |
| 2263 continue; |
| 2264 } |
| 2265 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, src_alpha); |
| 2266 dest_scan++; |
| 2267 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, src_alpha); |
| 2268 dest_scan++; |
| 2269 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, src_alpha); |
| 2270 dest_scan++; |
| 2271 dest_scan += dest_gap; |
| 2272 } |
| 2273 } else { |
| 2274 FX_ARGB argb = 0; |
| 2275 for (int col = 0; col < pixel_count; col++) { |
| 2276 argb = pPalette[*src_scan]; |
| 2277 int src_r = FXARGB_R(argb); |
| 2278 int src_g = FXARGB_G(argb); |
| 2279 int src_b = FXARGB_B(argb); |
| 2280 if (clip_scan && clip_scan[col] < 255) { |
| 2281 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, clip_scan[col]); |
| 2282 dest_scan++; |
| 2283 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, clip_scan[col]); |
| 2284 dest_scan++; |
| 2285 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, clip_scan[col]); |
| 2286 dest_scan++; |
| 2287 } else { |
| 2288 *dest_scan++ = src_b; |
| 2289 *dest_scan++ = src_g; |
| 2290 *dest_scan++ = src_r; |
| 2291 } |
| 2292 if (DestBpp == 4) { |
| 2293 dest_scan++; |
| 2294 } |
| 2295 src_scan++; |
| 2296 } |
| 2297 } |
| 2298 } |
| 2299 inline void _CompositeRow_1bppRgb2Rgb_NoBlend(FX_LPBYTE dest_scan, |
| 2300 FX_LPCBYTE src_scan, |
| 2301 int src_left, |
| 2302 FX_DWORD* pPalette, |
| 2303 int pixel_count, |
| 2304 int DestBpp, |
| 2305 FX_LPCBYTE clip_scan) { |
| 2306 int reset_r, reset_g, reset_b; |
| 2307 int set_r, set_g, set_b; |
| 2308 reset_r = FXARGB_R(pPalette[0]); |
| 2309 reset_g = FXARGB_G(pPalette[0]); |
| 2310 reset_b = FXARGB_B(pPalette[0]); |
| 2311 set_r = FXARGB_R(pPalette[1]); |
| 2312 set_g = FXARGB_G(pPalette[1]); |
| 2313 set_b = FXARGB_B(pPalette[1]); |
| 2314 for (int col = 0; col < pixel_count; col++) { |
| 2315 int src_r, src_g, src_b; |
| 2316 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) { |
| 2317 src_r = set_r; |
| 2318 src_g = set_g; |
| 2319 src_b = set_b; |
| 2320 } else { |
| 2321 src_r = reset_r; |
| 2322 src_g = reset_g; |
| 2323 src_b = reset_b; |
| 2324 } |
| 2325 if (clip_scan && clip_scan[col] < 255) { |
| 2326 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, clip_scan[col]); |
| 2327 dest_scan++; |
| 2328 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, clip_scan[col]); |
| 2329 dest_scan++; |
| 2330 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, clip_scan[col]); |
| 2331 dest_scan++; |
| 2332 } else { |
| 2333 *dest_scan++ = src_b; |
| 2334 *dest_scan++ = src_g; |
| 2335 *dest_scan++ = src_r; |
| 2336 } |
| 2337 if (DestBpp == 4) { |
| 2338 dest_scan++; |
| 2339 } |
| 2340 } |
| 2341 } |
| 2342 inline void _CompositeRow_8bppRgb2Argb_NoBlend(FX_LPBYTE dest_scan, |
| 2343 FX_LPCBYTE src_scan, |
| 2344 int width, |
| 2345 FX_DWORD* pPalette, |
| 2346 FX_LPCBYTE clip_scan, |
| 2347 FX_LPCBYTE src_alpha_scan) { |
| 2348 if (src_alpha_scan) { |
| 2349 for (int col = 0; col < width; col++) { |
| 2350 FX_ARGB argb = pPalette[*src_scan]; |
| 2351 src_scan++; |
| 2352 int src_r = FXARGB_R(argb); |
| 2353 int src_g = FXARGB_G(argb); |
| 2354 int src_b = FXARGB_B(argb); |
| 2355 FX_BYTE back_alpha = dest_scan[3]; |
| 2356 if (back_alpha == 0) { |
| 2357 if (clip_scan) { |
| 2358 int src_alpha = clip_scan[col] * (*src_alpha_scan) / 255; |
| 2359 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_alpha, src_r, src_g, src_b)); |
| 2360 } else { |
| 2361 FXARGB_SETDIB(dest_scan, |
| 2362 FXARGB_MAKE(*src_alpha_scan, src_r, src_g, src_b)); |
| 2363 } |
| 2364 dest_scan += 4; |
| 2365 src_alpha_scan++; |
| 2366 continue; |
| 2367 } |
| 2368 FX_BYTE src_alpha; |
| 2369 if (clip_scan == NULL) { |
| 2370 src_alpha = *src_alpha_scan++; |
| 2371 } else { |
| 2372 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255; |
| 2373 } |
| 2374 if (src_alpha == 0) { |
| 2375 dest_scan += 4; |
| 2376 continue; |
| 2377 } |
| 2378 FX_BYTE dest_alpha = |
| 2379 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2380 dest_scan[3] = dest_alpha; |
| 2381 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2382 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); |
| 2383 dest_scan++; |
| 2384 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); |
| 2385 dest_scan++; |
| 2386 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
| 2387 dest_scan++; |
| 2388 dest_scan++; |
| 2389 } |
| 2390 } else |
| 2391 for (int col = 0; col < width; col++) { |
| 2392 FX_ARGB argb = pPalette[*src_scan]; |
| 2393 int src_r = FXARGB_R(argb); |
| 2394 int src_g = FXARGB_G(argb); |
| 2395 int src_b = FXARGB_B(argb); |
| 2396 if (clip_scan == NULL || clip_scan[col] == 255) { |
| 2397 *dest_scan++ = src_b; |
| 2398 *dest_scan++ = src_g; |
| 2399 *dest_scan++ = src_r; |
| 2400 *dest_scan++ = 255; |
| 2401 src_scan++; |
| 2402 continue; |
| 2403 } |
| 2404 int src_alpha = clip_scan[col]; |
| 2405 if (src_alpha == 0) { |
| 2406 dest_scan += 4; |
| 2407 src_scan++; |
| 2408 continue; |
| 2409 } |
| 2410 int back_alpha = dest_scan[3]; |
| 2411 FX_BYTE dest_alpha = |
| 2412 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2413 dest_scan[3] = dest_alpha; |
| 2414 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2415 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); |
| 2416 dest_scan++; |
| 2417 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); |
| 2418 dest_scan++; |
| 2419 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
| 2420 dest_scan++; |
| 2421 dest_scan++; |
| 2422 src_scan++; |
| 2423 } |
| 2424 } |
| 2425 void _CompositeRow_8bppRgb2Rgba_NoBlend(FX_LPBYTE dest_scan, |
| 2426 FX_LPCBYTE src_scan, |
| 2427 int width, |
| 2428 FX_DWORD* pPalette, |
| 2429 FX_LPCBYTE clip_scan, |
| 2430 FX_LPBYTE dest_alpha_scan, |
| 2431 FX_LPCBYTE src_alpha_scan) { |
| 2432 if (src_alpha_scan) { |
| 2433 for (int col = 0; col < width; col++) { |
| 2434 FX_ARGB argb = pPalette[*src_scan]; |
| 2435 src_scan++; |
| 2436 int src_r = FXARGB_R(argb); |
| 2437 int src_g = FXARGB_G(argb); |
| 2438 int src_b = FXARGB_B(argb); |
| 2439 FX_BYTE back_alpha = *dest_alpha_scan; |
| 2440 if (back_alpha == 0) { |
| 2441 if (clip_scan) { |
| 2442 int src_alpha = clip_scan[col] * (*src_alpha_scan) / 255; |
| 2443 *dest_alpha_scan++ = src_alpha; |
| 2444 } else { |
| 2445 *dest_alpha_scan++ = *src_alpha_scan; |
| 2446 } |
| 2447 *dest_scan++ = src_b; |
| 2448 *dest_scan++ = src_g; |
| 2449 *dest_scan++ = src_r; |
| 2450 src_alpha_scan++; |
| 2451 continue; |
| 2452 } |
| 2453 FX_BYTE src_alpha; |
| 2454 if (clip_scan == NULL) { |
| 2455 src_alpha = *src_alpha_scan++; |
| 2456 } else { |
| 2457 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255; |
| 2458 } |
| 2459 if (src_alpha == 0) { |
| 2460 dest_scan += 3; |
| 2461 dest_alpha_scan++; |
| 2462 continue; |
| 2463 } |
| 2464 FX_BYTE dest_alpha = |
| 2465 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2466 *dest_alpha_scan++ = dest_alpha; |
| 2467 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2468 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); |
| 2469 dest_scan++; |
| 2470 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); |
| 2471 dest_scan++; |
| 2472 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
| 2473 dest_scan++; |
| 2474 } |
| 2475 } else |
| 2476 for (int col = 0; col < width; col++) { |
| 2477 FX_ARGB argb = pPalette[*src_scan]; |
| 2478 int src_r = FXARGB_R(argb); |
| 2479 int src_g = FXARGB_G(argb); |
| 2480 int src_b = FXARGB_B(argb); |
| 2481 if (clip_scan == NULL || clip_scan[col] == 255) { |
| 2482 *dest_scan++ = src_b; |
| 2483 *dest_scan++ = src_g; |
| 2484 *dest_scan++ = src_r; |
| 2485 *dest_alpha_scan++ = 255; |
| 2486 src_scan++; |
| 2487 continue; |
| 2488 } |
| 2489 int src_alpha = clip_scan[col]; |
| 2490 if (src_alpha == 0) { |
| 2491 dest_scan += 3; |
| 2492 dest_alpha_scan++; |
| 2493 src_scan++; |
| 2494 continue; |
| 2495 } |
| 2496 int back_alpha = *dest_alpha_scan; |
| 2497 FX_BYTE dest_alpha = |
| 2498 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2499 *dest_alpha_scan++ = dest_alpha; |
| 2500 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2501 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); |
| 2502 dest_scan++; |
| 2503 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); |
| 2504 dest_scan++; |
| 2505 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
| 2506 dest_scan++; |
| 2507 src_scan++; |
| 2508 } |
| 2509 } |
| 2510 inline void _CompositeRow_1bppRgb2Argb_NoBlend(FX_LPBYTE dest_scan, |
| 2511 FX_LPCBYTE src_scan, |
| 2512 int src_left, |
| 2513 int width, |
| 2514 FX_DWORD* pPalette, |
| 2515 FX_LPCBYTE clip_scan) { |
| 2516 int reset_r, reset_g, reset_b; |
| 2517 int set_r, set_g, set_b; |
| 2518 reset_r = FXARGB_R(pPalette[0]); |
| 2519 reset_g = FXARGB_G(pPalette[0]); |
| 2520 reset_b = FXARGB_B(pPalette[0]); |
| 2521 set_r = FXARGB_R(pPalette[1]); |
| 2522 set_g = FXARGB_G(pPalette[1]); |
| 2523 set_b = FXARGB_B(pPalette[1]); |
| 2524 for (int col = 0; col < width; col++) { |
| 2525 int src_r, src_g, src_b; |
| 2526 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) { |
| 2527 src_r = set_r; |
| 2528 src_g = set_g; |
| 2529 src_b = set_b; |
| 2530 } else { |
| 2531 src_r = reset_r; |
| 2532 src_g = reset_g; |
| 2533 src_b = reset_b; |
| 2534 } |
| 2535 if (clip_scan == NULL || clip_scan[col] == 255) { |
| 2536 *dest_scan++ = src_b; |
| 2537 *dest_scan++ = src_g; |
| 2538 *dest_scan++ = src_r; |
| 2539 *dest_scan++ = 255; |
| 2540 continue; |
| 2541 } |
| 2542 int src_alpha = clip_scan[col]; |
| 2543 if (src_alpha == 0) { |
| 2544 dest_scan += 4; |
| 2545 continue; |
| 2546 } |
| 2547 int back_alpha = dest_scan[3]; |
| 2548 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2549 dest_scan[3] = dest_alpha; |
| 2550 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2551 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); |
| 2552 dest_scan++; |
| 2553 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); |
| 2554 dest_scan++; |
| 2555 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
| 2556 dest_scan++; |
| 2557 dest_scan++; |
| 2558 } |
| 2559 } |
| 2560 void _CompositeRow_1bppRgb2Rgba_NoBlend(FX_LPBYTE dest_scan, |
| 2561 FX_LPCBYTE src_scan, |
| 2562 int src_left, |
| 2563 int width, |
| 2564 FX_DWORD* pPalette, |
| 2565 FX_LPCBYTE clip_scan, |
| 2566 FX_LPBYTE dest_alpha_scan) { |
| 2567 int reset_r, reset_g, reset_b; |
| 2568 int set_r, set_g, set_b; |
| 2569 reset_r = FXARGB_R(pPalette[0]); |
| 2570 reset_g = FXARGB_G(pPalette[0]); |
| 2571 reset_b = FXARGB_B(pPalette[0]); |
| 2572 set_r = FXARGB_R(pPalette[1]); |
| 2573 set_g = FXARGB_G(pPalette[1]); |
| 2574 set_b = FXARGB_B(pPalette[1]); |
| 2575 for (int col = 0; col < width; col++) { |
| 2576 int src_r, src_g, src_b; |
| 2577 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) { |
| 2578 src_r = set_r; |
| 2579 src_g = set_g; |
| 2580 src_b = set_b; |
| 2581 } else { |
| 2582 src_r = reset_r; |
| 2583 src_g = reset_g; |
| 2584 src_b = reset_b; |
| 2585 } |
| 2586 if (clip_scan == NULL || clip_scan[col] == 255) { |
| 2587 *dest_scan++ = src_b; |
| 2588 *dest_scan++ = src_g; |
| 2589 *dest_scan++ = src_r; |
| 2590 *dest_alpha_scan++ = 255; |
| 2591 continue; |
| 2592 } |
| 2593 int src_alpha = clip_scan[col]; |
| 2594 if (src_alpha == 0) { |
| 2595 dest_scan += 3; |
| 2596 dest_alpha_scan++; |
| 2597 continue; |
| 2598 } |
| 2599 int back_alpha = *dest_alpha_scan; |
| 2600 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2601 *dest_alpha_scan++ = dest_alpha; |
| 2602 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2603 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); |
| 2604 dest_scan++; |
| 2605 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); |
| 2606 dest_scan++; |
| 2607 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
| 2608 dest_scan++; |
| 2609 } |
| 2610 } |
| 2611 void _CompositeRow_ByteMask2Argb(FX_LPBYTE dest_scan, |
| 2612 FX_LPCBYTE src_scan, |
| 2613 int mask_alpha, |
| 2614 int src_r, |
| 2615 int src_g, |
| 2616 int src_b, |
| 2617 int pixel_count, |
| 2618 int blend_type, |
| 2619 FX_LPCBYTE clip_scan) { |
| 2620 for (int col = 0; col < pixel_count; col++) { |
| 2621 int src_alpha; |
| 2622 if (clip_scan) { |
| 2623 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; |
| 2624 } else { |
| 2625 src_alpha = mask_alpha * src_scan[col] / 255; |
| 2626 } |
| 2627 FX_BYTE back_alpha = dest_scan[3]; |
| 2628 if (back_alpha == 0) { |
| 2629 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_alpha, src_r, src_g, src_b)); |
| 2630 dest_scan += 4; |
| 2631 continue; |
| 2632 } |
| 2633 if (src_alpha == 0) { |
| 2634 dest_scan += 4; |
| 2635 continue; |
| 2636 } |
| 2637 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2638 dest_scan[3] = dest_alpha; |
| 2639 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2640 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { |
| 2641 int blended_colors[3]; |
| 2642 FX_BYTE src_scan[3]; |
| 2643 src_scan[0] = src_b; |
| 2644 src_scan[1] = src_g; |
| 2645 src_scan[2] = src_r; |
| 2646 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 2647 *dest_scan = |
| 2648 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_ratio); |
| 2649 dest_scan++; |
| 2650 *dest_scan = |
| 2651 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], alpha_ratio); |
| 2652 dest_scan++; |
| 2653 *dest_scan = |
| 2654 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_ratio); |
| 2655 } else if (blend_type) { |
| 2656 int blended = _BLEND(blend_type, *dest_scan, src_b); |
| 2657 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); |
| 2658 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 2659 dest_scan++; |
| 2660 blended = _BLEND(blend_type, *dest_scan, src_g); |
| 2661 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); |
| 2662 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 2663 dest_scan++; |
| 2664 blended = _BLEND(blend_type, *dest_scan, src_r); |
| 2665 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); |
| 2666 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 2667 } else { |
| 2668 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); |
| 2669 dest_scan++; |
| 2670 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); |
| 2671 dest_scan++; |
| 2672 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
| 2673 } |
| 2674 dest_scan += 2; |
| 2675 } |
| 2676 } |
| 2677 void _CompositeRow_ByteMask2Rgba(FX_LPBYTE dest_scan, |
| 2678 FX_LPCBYTE src_scan, |
| 2679 int mask_alpha, |
| 2680 int src_r, |
| 2681 int src_g, |
| 2682 int src_b, |
| 2683 int pixel_count, |
| 2684 int blend_type, |
| 2685 FX_LPCBYTE clip_scan, |
| 2686 FX_LPBYTE dest_alpha_scan) { |
| 2687 for (int col = 0; col < pixel_count; col++) { |
| 2688 int src_alpha; |
| 2689 if (clip_scan) { |
| 2690 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; |
| 2691 } else { |
| 2692 src_alpha = mask_alpha * src_scan[col] / 255; |
| 2693 } |
| 2694 FX_BYTE back_alpha = *dest_alpha_scan; |
| 2695 if (back_alpha == 0) { |
| 2696 *dest_scan++ = src_b; |
| 2697 *dest_scan++ = src_g; |
| 2698 *dest_scan++ = src_r; |
| 2699 *dest_alpha_scan++ = src_alpha; |
| 2700 continue; |
| 2701 } |
| 2702 if (src_alpha == 0) { |
| 2703 dest_scan += 3; |
| 2704 dest_alpha_scan++; |
| 2705 continue; |
| 2706 } |
| 2707 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2708 *dest_alpha_scan++ = dest_alpha; |
| 2709 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2710 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { |
| 2711 int blended_colors[3]; |
| 2712 FX_BYTE src_scan[3]; |
| 2713 src_scan[0] = src_b; |
| 2714 src_scan[1] = src_g; |
| 2715 src_scan[2] = src_r; |
| 2716 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 2717 *dest_scan = |
| 2718 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_ratio); |
| 2719 dest_scan++; |
| 2720 *dest_scan = |
| 2721 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], alpha_ratio); |
| 2722 dest_scan++; |
| 2723 *dest_scan = |
| 2724 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_ratio); |
| 2725 dest_scan++; |
| 2726 } else if (blend_type) { |
| 2727 int blended = _BLEND(blend_type, *dest_scan, src_b); |
| 2728 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); |
| 2729 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 2730 dest_scan++; |
| 2731 blended = _BLEND(blend_type, *dest_scan, src_g); |
| 2732 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); |
| 2733 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 2734 dest_scan++; |
| 2735 blended = _BLEND(blend_type, *dest_scan, src_r); |
| 2736 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); |
| 2737 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 2738 dest_scan++; |
| 2739 } else { |
| 2740 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); |
| 2741 dest_scan++; |
| 2742 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); |
| 2743 dest_scan++; |
| 2744 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
| 2745 dest_scan++; |
| 2746 } |
| 2747 } |
| 2748 } |
| 2749 void _CompositeRow_ByteMask2Rgb(FX_LPBYTE dest_scan, |
| 2750 FX_LPCBYTE src_scan, |
| 2751 int mask_alpha, |
| 2752 int src_r, |
| 2753 int src_g, |
| 2754 int src_b, |
| 2755 int pixel_count, |
| 2756 int blend_type, |
| 2757 int Bpp, |
| 2758 FX_LPCBYTE clip_scan) { |
| 2759 for (int col = 0; col < pixel_count; col++) { |
| 2760 int src_alpha; |
| 2761 if (clip_scan) { |
| 2762 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; |
| 2763 } else { |
| 2764 src_alpha = mask_alpha * src_scan[col] / 255; |
| 2765 } |
| 2766 if (src_alpha == 0) { |
| 2767 dest_scan += Bpp; |
| 2768 continue; |
| 2769 } |
| 2770 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { |
| 2771 int blended_colors[3]; |
| 2772 FX_BYTE src_scan[3]; |
| 2773 src_scan[0] = src_b; |
| 2774 src_scan[1] = src_g; |
| 2775 src_scan[2] = src_r; |
| 2776 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 2777 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], src_alpha); |
| 2778 dest_scan++; |
| 2779 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], src_alpha); |
| 2780 dest_scan++; |
| 2781 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], src_alpha); |
| 2782 } else if (blend_type) { |
| 2783 int blended = _BLEND(blend_type, *dest_scan, src_b); |
| 2784 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); |
| 2785 dest_scan++; |
| 2786 blended = _BLEND(blend_type, *dest_scan, src_g); |
| 2787 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); |
| 2788 dest_scan++; |
| 2789 blended = _BLEND(blend_type, *dest_scan, src_r); |
| 2790 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); |
| 2791 } else { |
| 2792 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, src_alpha); |
| 2793 dest_scan++; |
| 2794 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, src_alpha); |
| 2795 dest_scan++; |
| 2796 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, src_alpha); |
| 2797 } |
| 2798 dest_scan += Bpp - 2; |
| 2799 } |
| 2800 } |
| 2801 void _CompositeRow_ByteMask2Mask(FX_LPBYTE dest_scan, |
| 2802 FX_LPCBYTE src_scan, |
| 2803 int mask_alpha, |
| 2804 int pixel_count, |
| 2805 FX_LPCBYTE clip_scan) { |
| 2806 for (int col = 0; col < pixel_count; col++) { |
| 2807 int src_alpha; |
| 2808 if (clip_scan) { |
| 2809 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; |
| 2810 } else { |
| 2811 src_alpha = mask_alpha * src_scan[col] / 255; |
| 2812 } |
| 2813 FX_BYTE back_alpha = *dest_scan; |
| 2814 if (!back_alpha) { |
| 2815 *dest_scan = src_alpha; |
| 2816 } else if (src_alpha) { |
| 2817 *dest_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2818 } |
| 2819 dest_scan++; |
| 2820 } |
| 2821 } |
| 2822 void _CompositeRow_ByteMask2Gray(FX_LPBYTE dest_scan, |
| 2823 FX_LPCBYTE src_scan, |
| 2824 int mask_alpha, |
| 2825 int src_gray, |
| 2826 int pixel_count, |
| 2827 FX_LPCBYTE clip_scan) { |
| 2828 for (int col = 0; col < pixel_count; col++) { |
| 2829 int src_alpha; |
| 2830 if (clip_scan) { |
| 2831 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; |
| 2832 } else { |
| 2833 src_alpha = mask_alpha * src_scan[col] / 255; |
| 2834 } |
| 2835 if (src_alpha) { |
| 2836 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_gray, src_alpha); |
| 2837 } |
| 2838 dest_scan++; |
| 2839 } |
| 2840 } |
| 2841 void _CompositeRow_ByteMask2Graya(FX_LPBYTE dest_scan, |
| 2842 FX_LPCBYTE src_scan, |
| 2843 int mask_alpha, |
| 2844 int src_gray, |
| 2845 int pixel_count, |
| 2846 FX_LPCBYTE clip_scan, |
| 2847 FX_LPBYTE dest_alpha_scan) { |
| 2848 for (int col = 0; col < pixel_count; col++) { |
| 2849 int src_alpha; |
| 2850 if (clip_scan) { |
| 2851 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; |
| 2852 } else { |
| 2853 src_alpha = mask_alpha * src_scan[col] / 255; |
| 2854 } |
| 2855 FX_BYTE back_alpha = *dest_alpha_scan; |
| 2856 if (back_alpha == 0) { |
| 2857 *dest_scan++ = src_gray; |
| 2858 *dest_alpha_scan++ = src_alpha; |
| 2859 continue; |
| 2860 } |
| 2861 if (src_alpha == 0) { |
| 2862 dest_scan++; |
| 2863 dest_alpha_scan++; |
| 2864 continue; |
| 2865 } |
| 2866 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2867 *dest_alpha_scan++ = dest_alpha; |
| 2868 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2869 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_gray, alpha_ratio); |
| 2870 dest_scan++; |
| 2871 } |
| 2872 } |
| 2873 void _CompositeRow_BitMask2Argb(FX_LPBYTE dest_scan, |
| 2874 FX_LPCBYTE src_scan, |
| 2875 int mask_alpha, |
| 2876 int src_r, |
| 2877 int src_g, |
| 2878 int src_b, |
| 2879 int src_left, |
| 2880 int pixel_count, |
| 2881 int blend_type, |
| 2882 FX_LPCBYTE clip_scan) { |
| 2883 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && |
| 2884 mask_alpha == 255) { |
| 2885 FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b); |
| 2886 for (int col = 0; col < pixel_count; col++) { |
| 2887 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { |
| 2888 FXARGB_SETDIB(dest_scan, argb); |
| 2889 } |
| 2890 dest_scan += 4; |
| 2891 } |
| 2892 return; |
| 2893 } |
| 2894 for (int col = 0; col < pixel_count; col++) { |
| 2895 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8)))) { |
| 2896 dest_scan += 4; |
| 2897 continue; |
| 2898 } |
| 2899 int src_alpha; |
| 2900 if (clip_scan) { |
| 2901 src_alpha = mask_alpha * clip_scan[col] / 255; |
| 2902 } else { |
| 2903 src_alpha = mask_alpha; |
| 2904 } |
| 2905 FX_BYTE back_alpha = dest_scan[3]; |
| 2906 if (back_alpha == 0) { |
| 2907 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_alpha, src_r, src_g, src_b)); |
| 2908 dest_scan += 4; |
| 2909 continue; |
| 2910 } |
| 2911 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2912 dest_scan[3] = dest_alpha; |
| 2913 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2914 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { |
| 2915 int blended_colors[3]; |
| 2916 FX_BYTE src_scan[3]; |
| 2917 src_scan[0] = src_b; |
| 2918 src_scan[1] = src_g; |
| 2919 src_scan[2] = src_r; |
| 2920 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 2921 *dest_scan = |
| 2922 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_ratio); |
| 2923 dest_scan++; |
| 2924 *dest_scan = |
| 2925 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], alpha_ratio); |
| 2926 dest_scan++; |
| 2927 *dest_scan = |
| 2928 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_ratio); |
| 2929 } else if (blend_type) { |
| 2930 int blended = _BLEND(blend_type, *dest_scan, src_b); |
| 2931 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); |
| 2932 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 2933 dest_scan++; |
| 2934 blended = _BLEND(blend_type, *dest_scan, src_g); |
| 2935 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); |
| 2936 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 2937 dest_scan++; |
| 2938 blended = _BLEND(blend_type, *dest_scan, src_r); |
| 2939 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); |
| 2940 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 2941 } else { |
| 2942 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); |
| 2943 dest_scan++; |
| 2944 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); |
| 2945 dest_scan++; |
| 2946 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
| 2947 } |
| 2948 dest_scan += 2; |
| 2949 } |
| 2950 } |
| 2951 void _CompositeRow_BitMask2Rgba(FX_LPBYTE dest_scan, |
| 2952 FX_LPCBYTE src_scan, |
| 2953 int mask_alpha, |
| 2954 int src_r, |
| 2955 int src_g, |
| 2956 int src_b, |
| 2957 int src_left, |
| 2958 int pixel_count, |
| 2959 int blend_type, |
| 2960 FX_LPCBYTE clip_scan, |
| 2961 FX_LPBYTE dest_alpha_scan) { |
| 2962 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && |
| 2963 mask_alpha == 255) { |
| 2964 for (int col = 0; col < pixel_count; col++) { |
| 2965 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { |
| 2966 dest_scan[0] = src_b; |
| 2967 dest_scan[1] = src_g; |
| 2968 dest_scan[2] = src_r; |
| 2969 *dest_alpha_scan = mask_alpha; |
| 2970 } |
| 2971 dest_scan += 3; |
| 2972 dest_alpha_scan++; |
| 2973 } |
| 2974 return; |
| 2975 } |
| 2976 for (int col = 0; col < pixel_count; col++) { |
| 2977 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8)))) { |
| 2978 dest_scan += 3; |
| 2979 dest_alpha_scan++; |
| 2980 continue; |
| 2981 } |
| 2982 int src_alpha; |
| 2983 if (clip_scan) { |
| 2984 src_alpha = mask_alpha * clip_scan[col] / 255; |
| 2985 } else { |
| 2986 src_alpha = mask_alpha; |
| 2987 } |
| 2988 FX_BYTE back_alpha = dest_scan[3]; |
| 2989 if (back_alpha == 0) { |
| 2990 *dest_scan++ = src_b; |
| 2991 *dest_scan++ = src_g; |
| 2992 *dest_scan++ = src_r; |
| 2993 *dest_alpha_scan++ = mask_alpha; |
| 2994 continue; |
| 2995 } |
| 2996 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2997 *dest_alpha_scan++ = dest_alpha; |
| 2998 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2999 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { |
| 3000 int blended_colors[3]; |
| 3001 FX_BYTE src_scan[3]; |
| 3002 src_scan[0] = src_b; |
| 3003 src_scan[1] = src_g; |
| 3004 src_scan[2] = src_r; |
| 3005 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 3006 *dest_scan = |
| 3007 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_ratio); |
| 3008 dest_scan++; |
| 3009 *dest_scan = |
| 3010 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], alpha_ratio); |
| 3011 dest_scan++; |
| 3012 *dest_scan = |
| 3013 FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_ratio); |
| 3014 dest_scan++; |
| 3015 } else if (blend_type) { |
| 3016 int blended = _BLEND(blend_type, *dest_scan, src_b); |
| 3017 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); |
| 3018 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 3019 dest_scan++; |
| 3020 blended = _BLEND(blend_type, *dest_scan, src_g); |
| 3021 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); |
| 3022 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 3023 dest_scan++; |
| 3024 blended = _BLEND(blend_type, *dest_scan, src_r); |
| 3025 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); |
| 3026 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); |
| 3027 dest_scan++; |
| 3028 } else { |
| 3029 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); |
| 3030 dest_scan++; |
| 3031 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); |
| 3032 dest_scan++; |
| 3033 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
| 3034 dest_scan++; |
| 3035 } |
| 3036 } |
| 3037 } |
| 3038 void _CompositeRow_BitMask2Rgb(FX_LPBYTE dest_scan, |
| 3039 FX_LPCBYTE src_scan, |
| 3040 int mask_alpha, |
| 3041 int src_r, |
| 3042 int src_g, |
| 3043 int src_b, |
| 3044 int src_left, |
| 3045 int pixel_count, |
| 3046 int blend_type, |
| 3047 int Bpp, |
| 3048 FX_LPCBYTE clip_scan) { |
| 3049 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && |
| 3050 mask_alpha == 255) { |
| 3051 for (int col = 0; col < pixel_count; col++) { |
| 3052 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { |
| 3053 dest_scan[2] = src_r; |
| 3054 dest_scan[1] = src_g; |
| 3055 dest_scan[0] = src_b; |
| 3056 } |
| 3057 dest_scan += Bpp; |
| 3058 } |
| 3059 return; |
| 3060 } |
| 3061 for (int col = 0; col < pixel_count; col++) { |
| 3062 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8)))) { |
| 3063 dest_scan += Bpp; |
| 3064 continue; |
| 3065 } |
| 3066 int src_alpha; |
| 3067 if (clip_scan) { |
| 3068 src_alpha = mask_alpha * clip_scan[col] / 255; |
| 3069 } else { |
| 3070 src_alpha = mask_alpha; |
| 3071 } |
| 3072 if (src_alpha == 0) { |
| 3073 dest_scan += Bpp; |
| 3074 continue; |
| 3075 } |
| 3076 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { |
| 3077 int blended_colors[3]; |
| 3078 FX_BYTE src_scan[3]; |
| 3079 src_scan[0] = src_b; |
| 3080 src_scan[1] = src_g; |
| 3081 src_scan[2] = src_r; |
| 3082 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); |
| 3083 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], src_alpha); |
| 3084 dest_scan++; |
| 3085 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], src_alpha); |
| 3086 dest_scan++; |
| 3087 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], src_alpha); |
| 3088 } else if (blend_type) { |
| 3089 int blended = _BLEND(blend_type, *dest_scan, src_b); |
| 3090 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); |
| 3091 dest_scan++; |
| 3092 blended = _BLEND(blend_type, *dest_scan, src_g); |
| 3093 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); |
| 3094 dest_scan++; |
| 3095 blended = _BLEND(blend_type, *dest_scan, src_r); |
| 3096 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); |
| 3097 } else { |
| 3098 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, src_alpha); |
| 3099 dest_scan++; |
| 3100 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, src_alpha); |
| 3101 dest_scan++; |
| 3102 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, src_alpha); |
| 3103 } |
| 3104 dest_scan += Bpp - 2; |
| 3105 } |
| 3106 } |
| 3107 void _CompositeRow_BitMask2Mask(FX_LPBYTE dest_scan, |
| 3108 FX_LPCBYTE src_scan, |
| 3109 int mask_alpha, |
| 3110 int src_left, |
| 3111 int pixel_count, |
| 3112 FX_LPCBYTE clip_scan) { |
| 3113 for (int col = 0; col < pixel_count; col++) { |
| 3114 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8)))) { |
| 3115 dest_scan++; |
| 3116 continue; |
| 3117 } |
| 3118 int src_alpha; |
| 3119 if (clip_scan) { |
| 3120 src_alpha = mask_alpha * clip_scan[col] / 255; |
| 3121 } else { |
| 3122 src_alpha = mask_alpha; |
| 3123 } |
| 3124 FX_BYTE back_alpha = *dest_scan; |
| 3125 if (!back_alpha) { |
| 3126 *dest_scan = src_alpha; |
| 3127 } else if (src_alpha) { |
| 3128 *dest_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 3129 } |
| 3130 dest_scan++; |
| 3131 } |
| 3132 } |
| 3133 void _CompositeRow_BitMask2Gray(FX_LPBYTE dest_scan, |
| 3134 FX_LPCBYTE src_scan, |
| 3135 int mask_alpha, |
| 3136 int src_gray, |
| 3137 int src_left, |
| 3138 int pixel_count, |
| 3139 FX_LPCBYTE clip_scan) { |
| 3140 for (int col = 0; col < pixel_count; col++) { |
| 3141 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8)))) { |
| 3142 dest_scan++; |
| 3143 continue; |
| 3144 } |
| 3145 int src_alpha; |
| 3146 if (clip_scan) { |
| 3147 src_alpha = mask_alpha * clip_scan[col] / 255; |
| 3148 } else { |
| 3149 src_alpha = mask_alpha; |
| 3150 } |
| 3151 if (src_alpha) { |
| 3152 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_gray, src_alpha); |
| 3153 } |
| 3154 dest_scan++; |
| 3155 } |
| 3156 } |
| 3157 void _CompositeRow_BitMask2Graya(FX_LPBYTE dest_scan, |
| 3158 FX_LPCBYTE src_scan, |
| 3159 int mask_alpha, |
| 3160 int src_gray, |
| 3161 int src_left, |
| 3162 int pixel_count, |
| 3163 FX_LPCBYTE clip_scan, |
| 3164 FX_LPBYTE dest_alpha_scan) { |
| 3165 for (int col = 0; col < pixel_count; col++) { |
| 3166 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8)))) { |
| 3167 dest_scan++; |
| 3168 dest_alpha_scan++; |
| 3169 continue; |
| 3170 } |
| 3171 int src_alpha; |
| 3172 if (clip_scan) { |
| 3173 src_alpha = mask_alpha * clip_scan[col] / 255; |
| 3174 } else { |
| 3175 src_alpha = mask_alpha; |
| 3176 } |
| 3177 FX_BYTE back_alpha = *dest_alpha_scan; |
| 3178 if (back_alpha == 0) { |
| 3179 *dest_scan++ = src_gray; |
| 3180 *dest_alpha_scan++ = src_alpha; |
| 3181 continue; |
| 3182 } |
| 3183 if (src_alpha == 0) { |
| 3184 dest_scan++; |
| 3185 dest_alpha_scan++; |
| 3186 continue; |
| 3187 } |
| 3188 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 3189 *dest_alpha_scan++ = dest_alpha; |
| 3190 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 3191 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_gray, alpha_ratio); |
| 3192 dest_scan++; |
| 3193 } |
| 3194 } |
| 3195 void _CompositeRow_Argb2Argb_RgbByteOrder(FX_LPBYTE dest_scan, |
| 3196 FX_LPCBYTE src_scan, |
| 3197 int pixel_count, |
| 3198 int blend_type, |
| 3199 FX_LPCBYTE clip_scan) { |
| 3200 int blended_colors[3]; |
| 3201 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 3202 for (int col = 0; col < pixel_count; col++) { |
| 3203 FX_BYTE back_alpha = dest_scan[3]; |
| 3204 if (back_alpha == 0) { |
| 3205 if (clip_scan) { |
| 3206 int src_alpha = clip_scan[col] * src_scan[3] / 255; |
| 3207 dest_scan[3] = src_alpha; |
| 3208 dest_scan[0] = src_scan[2]; |
| 3209 dest_scan[1] = src_scan[1]; |
| 3210 dest_scan[2] = src_scan[0]; |
| 3211 } else { |
| 3212 FXARGB_RGBORDERCOPY(dest_scan, src_scan); |
| 3213 } |
| 3214 dest_scan += 4; |
| 3215 src_scan += 4; |
| 3216 continue; |
| 3217 } |
| 3218 FX_BYTE src_alpha; |
| 3219 if (clip_scan == NULL) { |
| 3220 src_alpha = src_scan[3]; |
| 3221 } else { |
| 3222 src_alpha = clip_scan[col] * src_scan[3] / 255; |
| 3223 } |
| 3224 if (src_alpha == 0) { |
| 3225 dest_scan += 4; |
| 3226 src_scan += 4; |
| 3227 continue; |
| 3228 } |
| 3229 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 3230 dest_scan[3] = dest_alpha; |
| 3231 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 3232 if (bNonseparableBlend) { |
| 3233 FX_BYTE dest_scan_o[3]; |
| 3234 dest_scan_o[0] = dest_scan[2]; |
| 3235 dest_scan_o[1] = dest_scan[1]; |
| 3236 dest_scan_o[2] = dest_scan[0]; |
| 3237 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); |
| 3238 } |
| 3239 for (int color = 0; color < 3; color++) { |
| 3240 int index = 2 - color; |
| 3241 if (blend_type) { |
| 3242 int blended = bNonseparableBlend |
| 3243 ? blended_colors[color] |
| 3244 : _BLEND(blend_type, dest_scan[index], *src_scan); |
| 3245 blended = FXDIB_ALPHA_MERGE(*src_scan, blended, back_alpha); |
| 3246 dest_scan[index] = |
| 3247 FXDIB_ALPHA_MERGE(dest_scan[index], blended, alpha_ratio); |
| 3248 } else { |
| 3249 dest_scan[index] = |
| 3250 FXDIB_ALPHA_MERGE(dest_scan[index], *src_scan, alpha_ratio); |
| 3251 } |
| 3252 src_scan++; |
| 3253 } |
| 3254 dest_scan += 4; |
| 3255 src_scan++; |
| 3256 } |
| 3257 } |
| 3258 void _CompositeRow_Rgb2Argb_Blend_NoClip_RgbByteOrder(FX_LPBYTE dest_scan, |
| 3259 FX_LPCBYTE src_scan, |
| 3260 int width, |
| 3261 int blend_type, |
| 3262 int src_Bpp) { |
| 3263 int blended_colors[3]; |
| 3264 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 3265 int src_gap = src_Bpp - 3; |
| 3266 for (int col = 0; col < width; col++) { |
| 3267 FX_BYTE back_alpha = dest_scan[3]; |
| 3268 if (back_alpha == 0) { |
| 3269 if (src_Bpp == 4) { |
| 3270 FXARGB_SETRGBORDERDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan)); |
| 3271 } else { |
| 3272 FXARGB_SETRGBORDERDIB( |
| 3273 dest_scan, |
| 3274 FXARGB_MAKE(0xff, src_scan[2], src_scan[1], src_scan[0])); |
| 3275 } |
| 3276 dest_scan += 4; |
| 3277 src_scan += src_Bpp; |
| 3278 continue; |
| 3279 } |
| 3280 dest_scan[3] = 0xff; |
| 3281 if (bNonseparableBlend) { |
| 3282 FX_BYTE dest_scan_o[3]; |
| 3283 dest_scan_o[0] = dest_scan[2]; |
| 3284 dest_scan_o[1] = dest_scan[1]; |
| 3285 dest_scan_o[2] = dest_scan[0]; |
| 3286 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); |
| 3287 } |
| 3288 for (int color = 0; color < 3; color++) { |
| 3289 int index = 2 - color; |
| 3290 int src_color = FX_GAMMA(*src_scan); |
| 3291 int blended = bNonseparableBlend |
| 3292 ? blended_colors[color] |
| 3293 : _BLEND(blend_type, dest_scan[index], src_color); |
| 3294 dest_scan[index] = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); |
| 3295 src_scan++; |
| 3296 } |
| 3297 dest_scan += 4; |
| 3298 src_scan += src_gap; |
| 3299 } |
| 3300 } |
| 3301 inline void _CompositeRow_Argb2Rgb_Blend_RgbByteOrder(FX_LPBYTE dest_scan, |
| 3302 FX_LPCBYTE src_scan, |
| 3303 int width, |
| 3304 int blend_type, |
| 3305 int dest_Bpp, |
| 3306 FX_LPCBYTE clip_scan) { |
| 3307 int blended_colors[3]; |
| 3308 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 3309 for (int col = 0; col < width; col++) { |
| 3310 FX_BYTE src_alpha; |
| 3311 if (clip_scan) { |
| 3312 src_alpha = src_scan[3] * (*clip_scan++) / 255; |
| 3313 } else { |
| 3314 src_alpha = src_scan[3]; |
| 3315 } |
| 3316 if (src_alpha == 0) { |
| 3317 dest_scan += dest_Bpp; |
| 3318 src_scan += 4; |
| 3319 continue; |
| 3320 } |
| 3321 if (bNonseparableBlend) { |
| 3322 FX_BYTE dest_scan_o[3]; |
| 3323 dest_scan_o[0] = dest_scan[2]; |
| 3324 dest_scan_o[1] = dest_scan[1]; |
| 3325 dest_scan_o[2] = dest_scan[0]; |
| 3326 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); |
| 3327 } |
| 3328 for (int color = 0; color < 3; color++) { |
| 3329 int index = 2 - color; |
| 3330 int back_color = FX_GAMMA(dest_scan[index]); |
| 3331 int blended = bNonseparableBlend |
| 3332 ? blended_colors[color] |
| 3333 : _BLEND(blend_type, back_color, *src_scan); |
| 3334 dest_scan[index] = |
| 3335 FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(back_color, blended, src_alpha)); |
| 3336 src_scan++; |
| 3337 } |
| 3338 dest_scan += dest_Bpp; |
| 3339 src_scan++; |
| 3340 } |
| 3341 } |
| 3342 inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip_RgbByteOrder( |
| 3343 FX_LPBYTE dest_scan, |
| 3344 FX_LPCBYTE src_scan, |
| 3345 int width, |
| 3346 int src_Bpp) { |
| 3347 for (int col = 0; col < width; col++) { |
| 3348 if (src_Bpp == 4) { |
| 3349 FXARGB_SETRGBORDERDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan)); |
| 3350 } else { |
| 3351 FXARGB_SETRGBORDERDIB( |
| 3352 dest_scan, FXARGB_MAKE(0xff, src_scan[2], src_scan[1], src_scan[0])); |
| 3353 } |
| 3354 dest_scan += 4; |
| 3355 src_scan += src_Bpp; |
| 3356 } |
| 3357 } |
| 3358 inline void _CompositeRow_Rgb2Rgb_Blend_NoClip_RgbByteOrder(FX_LPBYTE dest_scan, |
| 3359 FX_LPCBYTE src_scan, |
| 3360 int width, |
| 3361 int blend_type, |
| 3362 int dest_Bpp, |
| 3363 int src_Bpp) { |
| 3364 int blended_colors[3]; |
| 3365 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 3366 int src_gap = src_Bpp - 3; |
| 3367 for (int col = 0; col < width; col++) { |
| 3368 if (bNonseparableBlend) { |
| 3369 FX_BYTE dest_scan_o[3]; |
| 3370 dest_scan_o[0] = dest_scan[2]; |
| 3371 dest_scan_o[1] = dest_scan[1]; |
| 3372 dest_scan_o[2] = dest_scan[0]; |
| 3373 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); |
| 3374 } |
| 3375 for (int color = 0; color < 3; color++) { |
| 3376 int index = 2 - color; |
| 3377 int back_color = FX_GAMMA(dest_scan[index]); |
| 3378 int src_color = FX_GAMMA(*src_scan); |
| 3379 int blended = bNonseparableBlend |
| 3380 ? blended_colors[color] |
| 3381 : _BLEND(blend_type, back_color, src_color); |
| 3382 dest_scan[index] = FX_GAMMA_INVERSE(blended); |
| 3383 src_scan++; |
| 3384 } |
| 3385 dest_scan += dest_Bpp; |
| 3386 src_scan += src_gap; |
| 3387 } |
| 3388 } |
| 3389 inline void _CompositeRow_Argb2Rgb_NoBlend_RgbByteOrder(FX_LPBYTE dest_scan, |
| 3390 FX_LPCBYTE src_scan, |
| 3391 int width, |
| 3392 int dest_Bpp, |
| 3393 FX_LPCBYTE clip_scan) { |
| 3394 for (int col = 0; col < width; col++) { |
| 3395 FX_BYTE src_alpha; |
| 3396 if (clip_scan) { |
| 3397 src_alpha = src_scan[3] * (*clip_scan++) / 255; |
| 3398 } else { |
| 3399 src_alpha = src_scan[3]; |
| 3400 } |
| 3401 if (src_alpha == 255) { |
| 3402 dest_scan[2] = FX_GAMMA_INVERSE(*src_scan++); |
| 3403 dest_scan[1] = FX_GAMMA_INVERSE(*src_scan++); |
| 3404 dest_scan[0] = FX_GAMMA_INVERSE(*src_scan++); |
| 3405 dest_scan += dest_Bpp; |
| 3406 src_scan++; |
| 3407 continue; |
| 3408 } |
| 3409 if (src_alpha == 0) { |
| 3410 dest_scan += dest_Bpp; |
| 3411 src_scan += 4; |
| 3412 continue; |
| 3413 } |
| 3414 for (int color = 0; color < 3; color++) { |
| 3415 int index = 2 - color; |
| 3416 dest_scan[index] = FX_GAMMA_INVERSE( |
| 3417 FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan[index]), *src_scan, src_alpha)); |
| 3418 src_scan++; |
| 3419 } |
| 3420 dest_scan += dest_Bpp; |
| 3421 src_scan++; |
| 3422 } |
| 3423 } |
| 3424 inline void _CompositeRow_Rgb2Rgb_NoBlend_NoClip_RgbByteOrder( |
| 3425 FX_LPBYTE dest_scan, |
| 3426 FX_LPCBYTE src_scan, |
| 3427 int width, |
| 3428 int dest_Bpp, |
| 3429 int src_Bpp) { |
| 3430 for (int col = 0; col < width; col++) { |
| 3431 dest_scan[2] = src_scan[0]; |
| 3432 dest_scan[1] = src_scan[1]; |
| 3433 dest_scan[0] = src_scan[2]; |
| 3434 dest_scan += dest_Bpp; |
| 3435 src_scan += src_Bpp; |
| 3436 } |
| 3437 } |
| 3438 inline void _CompositeRow_Rgb2Argb_Blend_Clip_RgbByteOrder( |
| 3439 FX_LPBYTE dest_scan, |
| 3440 FX_LPCBYTE src_scan, |
| 3441 int width, |
| 3442 int blend_type, |
| 3443 int src_Bpp, |
| 3444 FX_LPCBYTE clip_scan) { |
| 3445 int blended_colors[3]; |
| 3446 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 3447 int src_gap = src_Bpp - 3; |
| 3448 for (int col = 0; col < width; col++) { |
| 3449 int src_alpha = *clip_scan++; |
| 3450 FX_BYTE back_alpha = dest_scan[3]; |
| 3451 if (back_alpha == 0) { |
| 3452 dest_scan[2] = FX_GAMMA(*src_scan++); |
| 3453 dest_scan[1] = FX_GAMMA(*src_scan++); |
| 3454 dest_scan[0] = FX_GAMMA(*src_scan++); |
| 3455 src_scan += src_gap; |
| 3456 dest_scan += 4; |
| 3457 continue; |
| 3458 } |
| 3459 if (src_alpha == 0) { |
| 3460 dest_scan += 4; |
| 3461 src_scan += src_Bpp; |
| 3462 continue; |
| 3463 } |
| 3464 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 3465 dest_scan[3] = dest_alpha; |
| 3466 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 3467 if (bNonseparableBlend) { |
| 3468 FX_BYTE dest_scan_o[3]; |
| 3469 dest_scan_o[0] = dest_scan[2]; |
| 3470 dest_scan_o[1] = dest_scan[1]; |
| 3471 dest_scan_o[2] = dest_scan[0]; |
| 3472 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); |
| 3473 } |
| 3474 for (int color = 0; color < 3; color++) { |
| 3475 int index = 2 - color; |
| 3476 int src_color = FX_GAMMA(*src_scan); |
| 3477 int blended = bNonseparableBlend |
| 3478 ? blended_colors[color] |
| 3479 : _BLEND(blend_type, dest_scan[index], src_color); |
| 3480 blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); |
| 3481 dest_scan[index] = |
| 3482 FXDIB_ALPHA_MERGE(dest_scan[index], blended, alpha_ratio); |
| 3483 src_scan++; |
| 3484 } |
| 3485 dest_scan += 4; |
| 3486 src_scan += src_gap; |
| 3487 } |
| 3488 } |
| 3489 inline void _CompositeRow_Rgb2Rgb_Blend_Clip_RgbByteOrder( |
| 3490 FX_LPBYTE dest_scan, |
| 3491 FX_LPCBYTE src_scan, |
| 3492 int width, |
| 3493 int blend_type, |
| 3494 int dest_Bpp, |
| 3495 int src_Bpp, |
| 3496 FX_LPCBYTE clip_scan) { |
| 3497 int blended_colors[3]; |
| 3498 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 3499 int src_gap = src_Bpp - 3; |
| 3500 for (int col = 0; col < width; col++) { |
| 3501 FX_BYTE src_alpha = *clip_scan++; |
| 3502 if (src_alpha == 0) { |
| 3503 dest_scan += dest_Bpp; |
| 3504 src_scan += src_Bpp; |
| 3505 continue; |
| 3506 } |
| 3507 if (bNonseparableBlend) { |
| 3508 FX_BYTE dest_scan_o[3]; |
| 3509 dest_scan_o[0] = dest_scan[2]; |
| 3510 dest_scan_o[1] = dest_scan[1]; |
| 3511 dest_scan_o[2] = dest_scan[0]; |
| 3512 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); |
| 3513 } |
| 3514 for (int color = 0; color < 3; color++) { |
| 3515 int index = 2 - color; |
| 3516 int src_color = FX_GAMMA(*src_scan); |
| 3517 int back_color = FX_GAMMA(dest_scan[index]); |
| 3518 int blended = bNonseparableBlend |
| 3519 ? blended_colors[color] |
| 3520 : _BLEND(blend_type, back_color, src_color); |
| 3521 dest_scan[index] = |
| 3522 FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(back_color, blended, src_alpha)); |
| 3523 src_scan++; |
| 3524 } |
| 3525 dest_scan += dest_Bpp; |
| 3526 src_scan += src_gap; |
| 3527 } |
| 3528 } |
| 3529 inline void _CompositeRow_Rgb2Argb_NoBlend_Clip_RgbByteOrder( |
| 3530 FX_LPBYTE dest_scan, |
| 3531 FX_LPCBYTE src_scan, |
| 3532 int width, |
| 3533 int src_Bpp, |
| 3534 FX_LPCBYTE clip_scan) { |
| 3535 int src_gap = src_Bpp - 3; |
| 3536 for (int col = 0; col < width; col++) { |
| 3537 int src_alpha = clip_scan[col]; |
| 3538 if (src_alpha == 255) { |
| 3539 dest_scan[2] = FX_GAMMA(*src_scan++); |
| 3540 dest_scan[1] = FX_GAMMA(*src_scan++); |
| 3541 dest_scan[0] = FX_GAMMA(*src_scan++); |
| 3542 dest_scan[3] = 255; |
| 3543 dest_scan += 4; |
| 3544 src_scan += src_gap; |
| 3545 continue; |
| 3546 } |
| 3547 if (src_alpha == 0) { |
| 3548 dest_scan += 4; |
| 3549 src_scan += src_Bpp; |
| 3550 continue; |
| 3551 } |
| 3552 int back_alpha = dest_scan[3]; |
| 3553 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 3554 dest_scan[3] = dest_alpha; |
| 3555 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 3556 for (int color = 0; color < 3; color++) { |
| 3557 int index = 2 - color; |
| 3558 dest_scan[index] = |
| 3559 FXDIB_ALPHA_MERGE(dest_scan[index], FX_GAMMA(*src_scan), alpha_ratio); |
| 3560 src_scan++; |
| 3561 } |
| 3562 dest_scan += 4; |
| 3563 src_scan += src_gap; |
| 3564 } |
| 3565 } |
| 3566 inline void _CompositeRow_Rgb2Rgb_NoBlend_Clip_RgbByteOrder( |
| 3567 FX_LPBYTE dest_scan, |
| 3568 FX_LPCBYTE src_scan, |
| 3569 int width, |
| 3570 int dest_Bpp, |
| 3571 int src_Bpp, |
| 3572 FX_LPCBYTE clip_scan) { |
| 3573 for (int col = 0; col < width; col++) { |
| 3574 int src_alpha = clip_scan[col]; |
| 3575 if (src_alpha == 255) { |
| 3576 dest_scan[2] = src_scan[0]; |
| 3577 dest_scan[1] = src_scan[1]; |
| 3578 dest_scan[0] = src_scan[2]; |
| 3579 } else if (src_alpha) { |
| 3580 dest_scan[2] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE( |
| 3581 FX_GAMMA(dest_scan[2]), FX_GAMMA(*src_scan), src_alpha)); |
| 3582 src_scan++; |
| 3583 dest_scan[1] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE( |
| 3584 FX_GAMMA(dest_scan[1]), FX_GAMMA(*src_scan), src_alpha)); |
| 3585 src_scan++; |
| 3586 dest_scan[0] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE( |
| 3587 FX_GAMMA(dest_scan[0]), FX_GAMMA(*src_scan), src_alpha)); |
| 3588 dest_scan += dest_Bpp; |
| 3589 src_scan += src_Bpp - 2; |
| 3590 continue; |
| 3591 } |
| 3592 dest_scan += dest_Bpp; |
| 3593 src_scan += src_Bpp; |
| 3594 } |
| 3595 } |
| 3596 inline void _CompositeRow_8bppRgb2Rgb_NoBlend_RgbByteOrder( |
| 3597 FX_LPBYTE dest_scan, |
| 3598 FX_LPCBYTE src_scan, |
| 3599 FX_ARGB* pPalette, |
| 3600 int pixel_count, |
| 3601 int DestBpp, |
| 3602 FX_LPCBYTE clip_scan) { |
| 3603 for (int col = 0; col < pixel_count; col++) { |
| 3604 FX_ARGB argb = pPalette ? pPalette[*src_scan] : (*src_scan) * 0x010101; |
| 3605 int src_r = FXARGB_R(argb); |
| 3606 int src_g = FXARGB_G(argb); |
| 3607 int src_b = FXARGB_B(argb); |
| 3608 if (clip_scan && clip_scan[col] < 255) { |
| 3609 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], src_b, clip_scan[col]); |
| 3610 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], src_g, clip_scan[col]); |
| 3611 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], src_r, clip_scan[col]); |
| 3612 } else { |
| 3613 dest_scan[2] = src_b; |
| 3614 dest_scan[1] = src_g; |
| 3615 dest_scan[0] = src_r; |
| 3616 } |
| 3617 dest_scan += DestBpp; |
| 3618 src_scan++; |
| 3619 } |
| 3620 } |
| 3621 inline void _CompositeRow_1bppRgb2Rgb_NoBlend_RgbByteOrder( |
| 3622 FX_LPBYTE dest_scan, |
| 3623 FX_LPCBYTE src_scan, |
| 3624 int src_left, |
| 3625 FX_ARGB* pPalette, |
| 3626 int pixel_count, |
| 3627 int DestBpp, |
| 3628 FX_LPCBYTE clip_scan) { |
| 3629 int reset_r, reset_g, reset_b; |
| 3630 int set_r, set_g, set_b; |
| 3631 if (pPalette) { |
| 2027 reset_r = FXARGB_R(pPalette[0]); | 3632 reset_r = FXARGB_R(pPalette[0]); |
| 2028 reset_g = FXARGB_G(pPalette[0]); | 3633 reset_g = FXARGB_G(pPalette[0]); |
| 2029 reset_b = FXARGB_B(pPalette[0]); | 3634 reset_b = FXARGB_B(pPalette[0]); |
| 2030 set_r = FXARGB_R(pPalette[1]); | 3635 set_r = FXARGB_R(pPalette[1]); |
| 2031 set_g = FXARGB_G(pPalette[1]); | 3636 set_g = FXARGB_G(pPalette[1]); |
| 2032 set_b = FXARGB_B(pPalette[1]); | 3637 set_b = FXARGB_B(pPalette[1]); |
| 2033 for (int col = 0; col < pixel_count; col ++) { | 3638 } else { |
| 2034 int src_r, src_g, src_b; | 3639 reset_r = reset_g = reset_b = 0; |
| 2035 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
{ | 3640 set_r = set_g = set_b = 255; |
| 2036 src_r = set_r; | 3641 } |
| 2037 src_g = set_g; | 3642 for (int col = 0; col < pixel_count; col++) { |
| 2038 src_b = set_b; | 3643 int src_r, src_g, src_b; |
| 2039 } else { | 3644 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) { |
| 2040 src_r = reset_r; | 3645 src_r = set_r; |
| 2041 src_g = reset_g; | 3646 src_g = set_g; |
| 2042 src_b = reset_b; | 3647 src_b = set_b; |
| 2043 } | 3648 } else { |
| 2044 if (clip_scan && clip_scan[col] < 255) { | 3649 src_r = reset_r; |
| 2045 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, clip_scan[col]); | 3650 src_g = reset_g; |
| 2046 dest_scan ++; | 3651 src_b = reset_b; |
| 2047 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, clip_scan[col]); | 3652 } |
| 2048 dest_scan ++; | 3653 if (clip_scan && clip_scan[col] < 255) { |
| 2049 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, clip_scan[col]); | 3654 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], src_b, clip_scan[col]); |
| 2050 dest_scan ++; | 3655 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], src_g, clip_scan[col]); |
| 2051 } else { | 3656 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], src_r, clip_scan[col]); |
| 2052 *dest_scan++ = src_b; | 3657 } else { |
| 2053 *dest_scan++ = src_g; | 3658 dest_scan[2] = src_b; |
| 2054 *dest_scan++ = src_r; | 3659 dest_scan[1] = src_g; |
| 2055 } | 3660 dest_scan[0] = src_r; |
| 2056 if (DestBpp == 4) { | 3661 } |
| 2057 dest_scan++; | 3662 dest_scan += DestBpp; |
| 2058 } | 3663 } |
| 2059 } | 3664 } |
| 2060 } | 3665 inline void _CompositeRow_8bppRgb2Argb_NoBlend_RgbByteOrder( |
| 2061 inline void _CompositeRow_8bppRgb2Argb_NoBlend(FX_LPBYTE dest_scan, FX_LPCBYTE s
rc_scan, int width, | 3666 FX_LPBYTE dest_scan, |
| 2062 FX_DWORD* pPalette, FX_LPCBYTE clip_scan, | 3667 FX_LPCBYTE src_scan, |
| 2063 FX_LPCBYTE src_alpha_scan) | 3668 int width, |
| 2064 { | 3669 FX_ARGB* pPalette, |
| 2065 if (src_alpha_scan) { | 3670 FX_LPCBYTE clip_scan) { |
| 2066 for (int col = 0; col < width; col ++) { | 3671 for (int col = 0; col < width; col++) { |
| 2067 FX_ARGB argb = pPalette[*src_scan]; | 3672 int src_r, src_g, src_b; |
| 2068 src_scan ++; | 3673 if (pPalette) { |
| 2069 int src_r = FXARGB_R(argb); | 3674 FX_ARGB argb = pPalette[*src_scan]; |
| 2070 int src_g = FXARGB_G(argb); | 3675 src_r = FXARGB_R(argb); |
| 2071 int src_b = FXARGB_B(argb); | 3676 src_g = FXARGB_G(argb); |
| 2072 FX_BYTE back_alpha = dest_scan[3]; | 3677 src_b = FXARGB_B(argb); |
| 2073 if (back_alpha == 0) { | 3678 } else { |
| 2074 if (clip_scan) { | 3679 src_r = src_g = src_b = *src_scan; |
| 2075 int src_alpha = clip_scan[col] * (*src_alpha_scan) / 255; | 3680 } |
| 2076 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_alpha, src_r, src_g
, src_b)); | 3681 if (clip_scan == NULL || clip_scan[col] == 255) { |
| 2077 } else { | 3682 dest_scan[2] = FX_GAMMA(src_b); |
| 2078 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(*src_alpha_scan, src_r,
src_g, src_b)); | 3683 dest_scan[1] = FX_GAMMA(src_g); |
| 2079 } | 3684 dest_scan[0] = FX_GAMMA(src_r); |
| 2080 dest_scan += 4; | 3685 dest_scan[3] = 255; |
| 2081 src_alpha_scan ++; | 3686 src_scan++; |
| 2082 continue; | 3687 dest_scan += 4; |
| 2083 } | 3688 continue; |
| 2084 FX_BYTE src_alpha; | 3689 } |
| 2085 if (clip_scan == NULL) { | 3690 int src_alpha = clip_scan[col]; |
| 2086 src_alpha = *src_alpha_scan ++; | 3691 if (src_alpha == 0) { |
| 2087 } else { | 3692 dest_scan += 4; |
| 2088 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255; | 3693 src_scan++; |
| 2089 } | 3694 continue; |
| 2090 if (src_alpha == 0) { | 3695 } |
| 2091 dest_scan += 4; | 3696 int back_alpha = dest_scan[3]; |
| 2092 continue; | 3697 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2093 } | 3698 dest_scan[3] = dest_alpha; |
| 2094 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | 3699 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2095 dest_scan[3] = dest_alpha; | 3700 dest_scan[2] = |
| 2096 int alpha_ratio = src_alpha * 255 / dest_alpha; | 3701 FXDIB_ALPHA_MERGE(dest_scan[2], FX_GAMMA(src_b), alpha_ratio); |
| 2097 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); | 3702 dest_scan[1] = |
| 2098 dest_scan ++; | 3703 FXDIB_ALPHA_MERGE(dest_scan[1], FX_GAMMA(src_g), alpha_ratio); |
| 2099 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); | 3704 dest_scan[0] = |
| 2100 dest_scan ++; | 3705 FXDIB_ALPHA_MERGE(dest_scan[0], FX_GAMMA(src_r), alpha_ratio); |
| 2101 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | 3706 dest_scan += 4; |
| 2102 dest_scan ++; | 3707 src_scan++; |
| 2103 dest_scan ++; | 3708 } |
| 2104 } | 3709 } |
| 2105 } else | 3710 inline void _CompositeRow_1bppRgb2Argb_NoBlend_RgbByteOrder( |
| 2106 for (int col = 0; col < width; col ++) { | 3711 FX_LPBYTE dest_scan, |
| 2107 FX_ARGB argb = pPalette[*src_scan]; | 3712 FX_LPCBYTE src_scan, |
| 2108 int src_r = FXARGB_R(argb); | 3713 int src_left, |
| 2109 int src_g = FXARGB_G(argb); | 3714 int width, |
| 2110 int src_b = FXARGB_B(argb); | 3715 FX_ARGB* pPalette, |
| 2111 if (clip_scan == NULL || clip_scan[col] == 255) { | 3716 FX_LPCBYTE clip_scan) { |
| 2112 *dest_scan++ = src_b; | 3717 int reset_r, reset_g, reset_b; |
| 2113 *dest_scan++ = src_g; | 3718 int set_r, set_g, set_b; |
| 2114 *dest_scan++ = src_r; | 3719 if (pPalette) { |
| 2115 *dest_scan++ = 255; | |
| 2116 src_scan ++; | |
| 2117 continue; | |
| 2118 } | |
| 2119 int src_alpha = clip_scan[col]; | |
| 2120 if (src_alpha == 0) { | |
| 2121 dest_scan += 4; | |
| 2122 src_scan ++; | |
| 2123 continue; | |
| 2124 } | |
| 2125 int back_alpha = dest_scan[3]; | |
| 2126 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | |
| 2127 dest_scan[3] = dest_alpha; | |
| 2128 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 2129 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); | |
| 2130 dest_scan ++; | |
| 2131 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); | |
| 2132 dest_scan ++; | |
| 2133 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | |
| 2134 dest_scan ++; | |
| 2135 dest_scan ++; | |
| 2136 src_scan ++; | |
| 2137 } | |
| 2138 } | |
| 2139 void _CompositeRow_8bppRgb2Rgba_NoBlend(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan
, int width, | |
| 2140 FX_DWORD* pPalette, FX_LPCBYTE clip_scan
, | |
| 2141 FX_LPBYTE dest_alpha_scan, FX_LPCBYTE sr
c_alpha_scan) | |
| 2142 { | |
| 2143 if (src_alpha_scan) { | |
| 2144 for (int col = 0; col < width; col ++) { | |
| 2145 FX_ARGB argb = pPalette[*src_scan]; | |
| 2146 src_scan ++; | |
| 2147 int src_r = FXARGB_R(argb); | |
| 2148 int src_g = FXARGB_G(argb); | |
| 2149 int src_b = FXARGB_B(argb); | |
| 2150 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 2151 if (back_alpha == 0) { | |
| 2152 if (clip_scan) { | |
| 2153 int src_alpha = clip_scan[col] * (*src_alpha_scan) / 255; | |
| 2154 *dest_alpha_scan ++ = src_alpha; | |
| 2155 } else { | |
| 2156 *dest_alpha_scan ++ = *src_alpha_scan; | |
| 2157 } | |
| 2158 *dest_scan ++ = src_b; | |
| 2159 *dest_scan ++ = src_g; | |
| 2160 *dest_scan ++ = src_r; | |
| 2161 src_alpha_scan ++; | |
| 2162 continue; | |
| 2163 } | |
| 2164 FX_BYTE src_alpha; | |
| 2165 if (clip_scan == NULL) { | |
| 2166 src_alpha = *src_alpha_scan++; | |
| 2167 } else { | |
| 2168 src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255; | |
| 2169 } | |
| 2170 if (src_alpha == 0) { | |
| 2171 dest_scan += 3; | |
| 2172 dest_alpha_scan ++; | |
| 2173 continue; | |
| 2174 } | |
| 2175 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | |
| 2176 *dest_alpha_scan ++ = dest_alpha; | |
| 2177 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 2178 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); | |
| 2179 dest_scan ++; | |
| 2180 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); | |
| 2181 dest_scan ++; | |
| 2182 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | |
| 2183 dest_scan ++; | |
| 2184 } | |
| 2185 } else | |
| 2186 for (int col = 0; col < width; col ++) { | |
| 2187 FX_ARGB argb = pPalette[*src_scan]; | |
| 2188 int src_r = FXARGB_R(argb); | |
| 2189 int src_g = FXARGB_G(argb); | |
| 2190 int src_b = FXARGB_B(argb); | |
| 2191 if (clip_scan == NULL || clip_scan[col] == 255) { | |
| 2192 *dest_scan++ = src_b; | |
| 2193 *dest_scan++ = src_g; | |
| 2194 *dest_scan++ = src_r; | |
| 2195 *dest_alpha_scan++ = 255; | |
| 2196 src_scan ++; | |
| 2197 continue; | |
| 2198 } | |
| 2199 int src_alpha = clip_scan[col]; | |
| 2200 if (src_alpha == 0) { | |
| 2201 dest_scan += 3; | |
| 2202 dest_alpha_scan ++; | |
| 2203 src_scan ++; | |
| 2204 continue; | |
| 2205 } | |
| 2206 int back_alpha = *dest_alpha_scan; | |
| 2207 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha
/ 255; | |
| 2208 *dest_alpha_scan ++ = dest_alpha; | |
| 2209 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 2210 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); | |
| 2211 dest_scan ++; | |
| 2212 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); | |
| 2213 dest_scan ++; | |
| 2214 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | |
| 2215 dest_scan ++; | |
| 2216 src_scan ++; | |
| 2217 } | |
| 2218 } | |
| 2219 inline void _CompositeRow_1bppRgb2Argb_NoBlend(FX_LPBYTE dest_scan, FX_LPCBYTE s
rc_scan, int src_left, int width, | |
| 2220 FX_DWORD* pPalette, FX_LPCBYTE clip_scan) | |
| 2221 { | |
| 2222 int reset_r, reset_g, reset_b; | |
| 2223 int set_r, set_g, set_b; | |
| 2224 reset_r = FXARGB_R(pPalette[0]); | 3720 reset_r = FXARGB_R(pPalette[0]); |
| 2225 reset_g = FXARGB_G(pPalette[0]); | 3721 reset_g = FXARGB_G(pPalette[0]); |
| 2226 reset_b = FXARGB_B(pPalette[0]); | 3722 reset_b = FXARGB_B(pPalette[0]); |
| 2227 set_r = FXARGB_R(pPalette[1]); | 3723 set_r = FXARGB_R(pPalette[1]); |
| 2228 set_g = FXARGB_G(pPalette[1]); | 3724 set_g = FXARGB_G(pPalette[1]); |
| 2229 set_b = FXARGB_B(pPalette[1]); | 3725 set_b = FXARGB_B(pPalette[1]); |
| 2230 for (int col = 0; col < width; col ++) { | 3726 } else { |
| 2231 int src_r, src_g, src_b; | 3727 reset_r = reset_g = reset_b = 0; |
| 2232 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
{ | 3728 set_r = set_g = set_b = 255; |
| 2233 src_r = set_r; | 3729 } |
| 2234 src_g = set_g; | 3730 for (int col = 0; col < width; col++) { |
| 2235 src_b = set_b; | 3731 int src_r, src_g, src_b; |
| 3732 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) { |
| 3733 src_r = set_r; |
| 3734 src_g = set_g; |
| 3735 src_b = set_b; |
| 3736 } else { |
| 3737 src_r = reset_r; |
| 3738 src_g = reset_g; |
| 3739 src_b = reset_b; |
| 3740 } |
| 3741 if (clip_scan == NULL || clip_scan[col] == 255) { |
| 3742 dest_scan[2] = FX_GAMMA(src_b); |
| 3743 dest_scan[1] = FX_GAMMA(src_g); |
| 3744 dest_scan[0] = FX_GAMMA(src_r); |
| 3745 dest_scan[3] = 255; |
| 3746 dest_scan += 4; |
| 3747 continue; |
| 3748 } |
| 3749 int src_alpha = clip_scan[col]; |
| 3750 if (src_alpha == 0) { |
| 3751 dest_scan += 4; |
| 3752 continue; |
| 3753 } |
| 3754 int back_alpha = dest_scan[3]; |
| 3755 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 3756 dest_scan[3] = dest_alpha; |
| 3757 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 3758 dest_scan[2] = |
| 3759 FXDIB_ALPHA_MERGE(dest_scan[2], FX_GAMMA(src_b), alpha_ratio); |
| 3760 dest_scan[1] = |
| 3761 FXDIB_ALPHA_MERGE(dest_scan[1], FX_GAMMA(src_g), alpha_ratio); |
| 3762 dest_scan[0] = |
| 3763 FXDIB_ALPHA_MERGE(dest_scan[0], FX_GAMMA(src_r), alpha_ratio); |
| 3764 dest_scan += 4; |
| 3765 } |
| 3766 } |
| 3767 void _CompositeRow_ByteMask2Argb_RgbByteOrder(FX_LPBYTE dest_scan, |
| 3768 FX_LPCBYTE src_scan, |
| 3769 int mask_alpha, |
| 3770 int src_r, |
| 3771 int src_g, |
| 3772 int src_b, |
| 3773 int pixel_count, |
| 3774 int blend_type, |
| 3775 FX_LPCBYTE clip_scan) { |
| 3776 for (int col = 0; col < pixel_count; col++) { |
| 3777 int src_alpha; |
| 3778 if (clip_scan) { |
| 3779 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; |
| 3780 } else { |
| 3781 src_alpha = mask_alpha * src_scan[col] / 255; |
| 3782 } |
| 3783 FX_BYTE back_alpha = dest_scan[3]; |
| 3784 if (back_alpha == 0) { |
| 3785 FXARGB_SETRGBORDERDIB(dest_scan, |
| 3786 FXARGB_MAKE(src_alpha, src_r, src_g, src_b)); |
| 3787 dest_scan += 4; |
| 3788 continue; |
| 3789 } |
| 3790 if (src_alpha == 0) { |
| 3791 dest_scan += 4; |
| 3792 continue; |
| 3793 } |
| 3794 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 3795 dest_scan[3] = dest_alpha; |
| 3796 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 3797 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { |
| 3798 int blended_colors[3]; |
| 3799 FX_BYTE src_scan[3]; |
| 3800 FX_BYTE dest_scan_o[3]; |
| 3801 src_scan[0] = src_b; |
| 3802 src_scan[1] = src_g; |
| 3803 src_scan[2] = src_r; |
| 3804 dest_scan_o[0] = dest_scan[2]; |
| 3805 dest_scan_o[1] = dest_scan[1]; |
| 3806 dest_scan_o[2] = dest_scan[0]; |
| 3807 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); |
| 3808 dest_scan[2] = |
| 3809 FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], alpha_ratio); |
| 3810 dest_scan[1] = |
| 3811 FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], alpha_ratio); |
| 3812 dest_scan[0] = |
| 3813 FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], alpha_ratio); |
| 3814 } else if (blend_type) { |
| 3815 int blended = _BLEND(blend_type, dest_scan[2], src_b); |
| 3816 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); |
| 3817 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended, alpha_ratio); |
| 3818 blended = _BLEND(blend_type, dest_scan[1], src_g); |
| 3819 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); |
| 3820 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], blended, alpha_ratio); |
| 3821 blended = _BLEND(blend_type, dest_scan[0], src_r); |
| 3822 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); |
| 3823 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended, alpha_ratio); |
| 3824 } else { |
| 3825 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], src_b, alpha_ratio); |
| 3826 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], src_g, alpha_ratio); |
| 3827 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], src_r, alpha_ratio); |
| 3828 } |
| 3829 dest_scan += 4; |
| 3830 } |
| 3831 } |
| 3832 void _CompositeRow_ByteMask2Rgb_RgbByteOrder(FX_LPBYTE dest_scan, |
| 3833 FX_LPCBYTE src_scan, |
| 3834 int mask_alpha, |
| 3835 int src_r, |
| 3836 int src_g, |
| 3837 int src_b, |
| 3838 int pixel_count, |
| 3839 int blend_type, |
| 3840 int Bpp, |
| 3841 FX_LPCBYTE clip_scan) { |
| 3842 for (int col = 0; col < pixel_count; col++) { |
| 3843 int src_alpha; |
| 3844 if (clip_scan) { |
| 3845 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; |
| 3846 } else { |
| 3847 src_alpha = mask_alpha * src_scan[col] / 255; |
| 3848 } |
| 3849 if (src_alpha == 0) { |
| 3850 dest_scan += Bpp; |
| 3851 continue; |
| 3852 } |
| 3853 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { |
| 3854 int blended_colors[3]; |
| 3855 FX_BYTE src_scan[3]; |
| 3856 FX_BYTE dest_scan_o[3]; |
| 3857 src_scan[0] = src_b; |
| 3858 src_scan[1] = src_g; |
| 3859 src_scan[2] = src_r; |
| 3860 dest_scan_o[0] = dest_scan[2]; |
| 3861 dest_scan_o[1] = dest_scan[1]; |
| 3862 dest_scan_o[2] = dest_scan[0]; |
| 3863 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); |
| 3864 dest_scan[2] = |
| 3865 FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], src_alpha); |
| 3866 dest_scan[1] = |
| 3867 FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], src_alpha); |
| 3868 dest_scan[0] = |
| 3869 FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], src_alpha); |
| 3870 } else if (blend_type) { |
| 3871 int blended = _BLEND(blend_type, dest_scan[2], src_b); |
| 3872 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended, src_alpha); |
| 3873 blended = _BLEND(blend_type, dest_scan[1], src_g); |
| 3874 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], blended, src_alpha); |
| 3875 blended = _BLEND(blend_type, dest_scan[0], src_r); |
| 3876 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended, src_alpha); |
| 3877 } else { |
| 3878 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], src_b, src_alpha); |
| 3879 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], src_g, src_alpha); |
| 3880 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], src_r, src_alpha); |
| 3881 } |
| 3882 dest_scan += Bpp; |
| 3883 } |
| 3884 } |
| 3885 void _CompositeRow_BitMask2Argb_RgbByteOrder(FX_LPBYTE dest_scan, |
| 3886 FX_LPCBYTE src_scan, |
| 3887 int mask_alpha, |
| 3888 int src_r, |
| 3889 int src_g, |
| 3890 int src_b, |
| 3891 int src_left, |
| 3892 int pixel_count, |
| 3893 int blend_type, |
| 3894 FX_LPCBYTE clip_scan) { |
| 3895 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && |
| 3896 mask_alpha == 255) { |
| 3897 FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b); |
| 3898 for (int col = 0; col < pixel_count; col++) { |
| 3899 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { |
| 3900 FXARGB_SETRGBORDERDIB(dest_scan, argb); |
| 3901 } |
| 3902 dest_scan += 4; |
| 3903 } |
| 3904 return; |
| 3905 } |
| 3906 for (int col = 0; col < pixel_count; col++) { |
| 3907 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8)))) { |
| 3908 dest_scan += 4; |
| 3909 continue; |
| 3910 } |
| 3911 int src_alpha; |
| 3912 if (clip_scan) { |
| 3913 src_alpha = mask_alpha * clip_scan[col] / 255; |
| 3914 } else { |
| 3915 src_alpha = mask_alpha; |
| 3916 } |
| 3917 FX_BYTE back_alpha = dest_scan[3]; |
| 3918 if (back_alpha == 0) { |
| 3919 FXARGB_SETRGBORDERDIB(dest_scan, |
| 3920 FXARGB_MAKE(src_alpha, src_r, src_g, src_b)); |
| 3921 dest_scan += 4; |
| 3922 continue; |
| 3923 } |
| 3924 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 3925 dest_scan[3] = dest_alpha; |
| 3926 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 3927 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { |
| 3928 int blended_colors[3]; |
| 3929 FX_BYTE src_scan[3]; |
| 3930 FX_BYTE dest_scan_o[3]; |
| 3931 src_scan[0] = src_b; |
| 3932 src_scan[1] = src_g; |
| 3933 src_scan[2] = src_r; |
| 3934 dest_scan_o[0] = dest_scan[2]; |
| 3935 dest_scan_o[1] = dest_scan[1]; |
| 3936 dest_scan_o[2] = dest_scan[0]; |
| 3937 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); |
| 3938 dest_scan[2] = |
| 3939 FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], alpha_ratio); |
| 3940 dest_scan[1] = |
| 3941 FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], alpha_ratio); |
| 3942 dest_scan[0] = |
| 3943 FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], alpha_ratio); |
| 3944 } else if (blend_type) { |
| 3945 int blended = _BLEND(blend_type, dest_scan[2], src_b); |
| 3946 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); |
| 3947 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended, alpha_ratio); |
| 3948 blended = _BLEND(blend_type, dest_scan[1], src_g); |
| 3949 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); |
| 3950 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], blended, alpha_ratio); |
| 3951 blended = _BLEND(blend_type, dest_scan[0], src_r); |
| 3952 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); |
| 3953 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended, alpha_ratio); |
| 3954 } else { |
| 3955 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], src_b, alpha_ratio); |
| 3956 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], src_g, alpha_ratio); |
| 3957 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], src_r, alpha_ratio); |
| 3958 } |
| 3959 dest_scan += 4; |
| 3960 } |
| 3961 } |
| 3962 void _CompositeRow_BitMask2Rgb_RgbByteOrder(FX_LPBYTE dest_scan, |
| 3963 FX_LPCBYTE src_scan, |
| 3964 int mask_alpha, |
| 3965 int src_r, |
| 3966 int src_g, |
| 3967 int src_b, |
| 3968 int src_left, |
| 3969 int pixel_count, |
| 3970 int blend_type, |
| 3971 int Bpp, |
| 3972 FX_LPCBYTE clip_scan) { |
| 3973 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && |
| 3974 mask_alpha == 255) { |
| 3975 for (int col = 0; col < pixel_count; col++) { |
| 3976 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { |
| 3977 dest_scan[2] = src_b; |
| 3978 dest_scan[1] = src_g; |
| 3979 dest_scan[0] = src_r; |
| 3980 } |
| 3981 dest_scan += Bpp; |
| 3982 } |
| 3983 return; |
| 3984 } |
| 3985 for (int col = 0; col < pixel_count; col++) { |
| 3986 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8)))) { |
| 3987 dest_scan += Bpp; |
| 3988 continue; |
| 3989 } |
| 3990 int src_alpha; |
| 3991 if (clip_scan) { |
| 3992 src_alpha = mask_alpha * clip_scan[col] / 255; |
| 3993 } else { |
| 3994 src_alpha = mask_alpha; |
| 3995 } |
| 3996 if (src_alpha == 0) { |
| 3997 dest_scan += Bpp; |
| 3998 continue; |
| 3999 } |
| 4000 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { |
| 4001 int blended_colors[3]; |
| 4002 FX_BYTE src_scan[3]; |
| 4003 FX_BYTE dest_scan_o[3]; |
| 4004 src_scan[0] = src_b; |
| 4005 src_scan[1] = src_g; |
| 4006 src_scan[2] = src_r; |
| 4007 dest_scan_o[0] = dest_scan[2]; |
| 4008 dest_scan_o[1] = dest_scan[1]; |
| 4009 dest_scan_o[2] = dest_scan[0]; |
| 4010 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); |
| 4011 dest_scan[2] = |
| 4012 FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], src_alpha); |
| 4013 dest_scan[1] = |
| 4014 FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], src_alpha); |
| 4015 dest_scan[0] = |
| 4016 FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], src_alpha); |
| 4017 } else if (blend_type) { |
| 4018 int back_color = FX_GAMMA(dest_scan[2]); |
| 4019 int blended = _BLEND(blend_type, back_color, src_b); |
| 4020 dest_scan[2] = |
| 4021 FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(back_color, blended, src_alpha)); |
| 4022 back_color = FX_GAMMA(dest_scan[1]); |
| 4023 blended = _BLEND(blend_type, back_color, src_g); |
| 4024 dest_scan[1] = |
| 4025 FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(back_color, blended, src_alpha)); |
| 4026 back_color = FX_GAMMA(dest_scan[0]); |
| 4027 blended = _BLEND(blend_type, back_color, src_r); |
| 4028 dest_scan[0] = |
| 4029 FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(back_color, blended, src_alpha)); |
| 4030 } else { |
| 4031 dest_scan[2] = FX_GAMMA_INVERSE( |
| 4032 FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan[2]), src_b, src_alpha)); |
| 4033 dest_scan[1] = FX_GAMMA_INVERSE( |
| 4034 FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan[1]), src_g, src_alpha)); |
| 4035 dest_scan[0] = FX_GAMMA_INVERSE( |
| 4036 FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan[0]), src_r, src_alpha)); |
| 4037 } |
| 4038 dest_scan += Bpp; |
| 4039 } |
| 4040 } |
| 4041 inline FX_BOOL _ScanlineCompositor_InitSourceMask(FXDIB_Format dest_format, |
| 4042 int alpha_flag, |
| 4043 FX_DWORD mask_color, |
| 4044 int& mask_alpha, |
| 4045 int& mask_red, |
| 4046 int& mask_green, |
| 4047 int& mask_blue, |
| 4048 int& mask_black, |
| 4049 void* icc_module, |
| 4050 void* pIccTransform) { |
| 4051 ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module; |
| 4052 if (alpha_flag >> 8) { |
| 4053 mask_alpha = alpha_flag & 0xff; |
| 4054 mask_red = FXSYS_GetCValue(mask_color); |
| 4055 mask_green = FXSYS_GetMValue(mask_color); |
| 4056 mask_blue = FXSYS_GetYValue(mask_color); |
| 4057 mask_black = FXSYS_GetKValue(mask_color); |
| 4058 } else { |
| 4059 mask_alpha = FXARGB_A(mask_color); |
| 4060 mask_red = FXARGB_R(mask_color); |
| 4061 mask_green = FXARGB_G(mask_color); |
| 4062 mask_blue = FXARGB_B(mask_color); |
| 4063 } |
| 4064 if (dest_format == FXDIB_8bppMask) { |
| 4065 return TRUE; |
| 4066 } |
| 4067 if ((dest_format & 0xff) == 8) { |
| 4068 if (pIccTransform) { |
| 4069 mask_color = (alpha_flag >> 8) ? FXCMYK_TODIB(mask_color) |
| 4070 : FXARGB_TODIB(mask_color); |
| 4071 FX_LPBYTE gray_p = (FX_LPBYTE)&mask_color; |
| 4072 pIccModule->TranslateScanline(pIccTransform, gray_p, gray_p, 1); |
| 4073 mask_red = dest_format & 0x0400 ? FX_CCOLOR(gray_p[0]) : gray_p[0]; |
| 4074 } else { |
| 4075 if (alpha_flag >> 8) { |
| 4076 FX_BYTE r, g, b; |
| 4077 AdobeCMYK_to_sRGB1( |
| 4078 mask_red, mask_green, mask_blue, mask_black, r, g, b); |
| 4079 mask_red = FXRGB2GRAY(r, g, b); |
| 4080 } else { |
| 4081 mask_red = FXRGB2GRAY(mask_red, mask_green, mask_blue); |
| 4082 } |
| 4083 if (dest_format & 0x0400) { |
| 4084 mask_red = FX_CCOLOR(mask_red); |
| 4085 } |
| 4086 } |
| 4087 } else { |
| 4088 FX_LPBYTE mask_color_p = (FX_LPBYTE)&mask_color; |
| 4089 mask_color = |
| 4090 (alpha_flag >> 8) ? FXCMYK_TODIB(mask_color) : FXARGB_TODIB(mask_color); |
| 4091 if (pIccTransform) { |
| 4092 pIccModule->TranslateScanline( |
| 4093 pIccTransform, mask_color_p, mask_color_p, 1); |
| 4094 mask_red = mask_color_p[2]; |
| 4095 mask_green = mask_color_p[1]; |
| 4096 mask_blue = mask_color_p[0]; |
| 4097 } else if (alpha_flag >> 8) { |
| 4098 AdobeCMYK_to_sRGB1(mask_color_p[0], |
| 4099 mask_color_p[1], |
| 4100 mask_color_p[2], |
| 4101 mask_color_p[3], |
| 4102 mask_color_p[2], |
| 4103 mask_color_p[1], |
| 4104 mask_color_p[0]); |
| 4105 mask_red = mask_color_p[2]; |
| 4106 mask_green = mask_color_p[1]; |
| 4107 mask_blue = mask_color_p[0]; |
| 4108 } |
| 4109 } |
| 4110 return TRUE; |
| 4111 } |
| 4112 inline void _ScanlineCompositor_InitSourcePalette(FXDIB_Format src_format, |
| 4113 FXDIB_Format dest_format, |
| 4114 FX_DWORD*& pDestPalette, |
| 4115 FX_DWORD* pSrcPalette, |
| 4116 void* icc_module, |
| 4117 void* pIccTransform) { |
| 4118 ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module; |
| 4119 FX_BOOL isSrcCmyk = src_format & 0x0400 ? TRUE : FALSE; |
| 4120 FX_BOOL isDstCmyk = dest_format & 0x0400 ? TRUE : FALSE; |
| 4121 pDestPalette = NULL; |
| 4122 if (pIccTransform) { |
| 4123 if (pSrcPalette) { |
| 4124 if ((dest_format & 0xff) == 8) { |
| 4125 int pal_count = 1 << (src_format & 0xff); |
| 4126 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count); |
| 4127 if (!gray_pal) { |
| 4128 return; |
| 4129 } |
| 4130 pDestPalette = (FX_DWORD*)gray_pal; |
| 4131 for (int i = 0; i < pal_count; i++) { |
| 4132 FX_DWORD color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) |
| 4133 : FXARGB_TODIB(pSrcPalette[i]); |
| 4134 pIccModule->TranslateScanline( |
| 4135 pIccTransform, gray_pal, (FX_LPCBYTE)&color, 1); |
| 4136 gray_pal++; |
| 4137 } |
| 4138 } else { |
| 4139 int palsize = 1 << (src_format & 0xff); |
| 4140 pDestPalette = FX_Alloc(FX_DWORD, palsize); |
| 4141 if (!pDestPalette) { |
| 4142 return; |
| 4143 } |
| 4144 for (int i = 0; i < palsize; i++) { |
| 4145 FX_DWORD color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) |
| 4146 : FXARGB_TODIB(pSrcPalette[i]); |
| 4147 pIccModule->TranslateScanline( |
| 4148 pIccTransform, (FX_LPBYTE)&color, (FX_LPCBYTE)&color, 1); |
| 4149 pDestPalette[i] = |
| 4150 isDstCmyk ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); |
| 4151 } |
| 4152 } |
| 4153 } else { |
| 4154 int pal_count = 1 << (src_format & 0xff); |
| 4155 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count); |
| 4156 if (!gray_pal) { |
| 4157 return; |
| 4158 } |
| 4159 if (pal_count == 2) { |
| 4160 gray_pal[0] = 0; |
| 4161 gray_pal[1] = 255; |
| 4162 } else { |
| 4163 for (int i = 0; i < pal_count; i++) { |
| 4164 gray_pal[i] = i; |
| 4165 } |
| 4166 } |
| 4167 if ((dest_format & 0xff) == 8) { |
| 4168 pIccModule->TranslateScanline( |
| 4169 pIccTransform, gray_pal, gray_pal, pal_count); |
| 4170 pDestPalette = (FX_DWORD*)gray_pal; |
| 4171 } else { |
| 4172 pDestPalette = FX_Alloc(FX_DWORD, pal_count); |
| 4173 if (!pDestPalette) { |
| 4174 FX_Free(gray_pal); |
| 4175 return; |
| 4176 } |
| 4177 for (int i = 0; i < pal_count; i++) { |
| 4178 pIccModule->TranslateScanline( |
| 4179 pIccTransform, (FX_LPBYTE)&pDestPalette[i], &gray_pal[i], 1); |
| 4180 pDestPalette[i] = isDstCmyk ? FXCMYK_TODIB(pDestPalette[i]) |
| 4181 : FXARGB_TODIB(pDestPalette[i]); |
| 4182 } |
| 4183 FX_Free(gray_pal); |
| 4184 } |
| 4185 } |
| 4186 } else { |
| 4187 if (pSrcPalette) { |
| 4188 if ((dest_format & 0xff) == 8) { |
| 4189 int pal_count = 1 << (src_format & 0xff); |
| 4190 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count); |
| 4191 if (!gray_pal) { |
| 4192 return; |
| 4193 } |
| 4194 pDestPalette = (FX_DWORD*)gray_pal; |
| 4195 if (isSrcCmyk) { |
| 4196 for (int i = 0; i < pal_count; i++) { |
| 4197 FX_CMYK cmyk = pSrcPalette[i]; |
| 4198 FX_BYTE r, g, b; |
| 4199 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), |
| 4200 FXSYS_GetMValue(cmyk), |
| 4201 FXSYS_GetYValue(cmyk), |
| 4202 FXSYS_GetKValue(cmyk), |
| 4203 r, |
| 4204 g, |
| 4205 b); |
| 4206 *gray_pal++ = FXRGB2GRAY(r, g, b); |
| 4207 } |
| 4208 } else |
| 4209 for (int i = 0; i < pal_count; i++) { |
| 4210 FX_ARGB argb = pSrcPalette[i]; |
| 4211 *gray_pal++ = |
| 4212 FXRGB2GRAY(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb)); |
| 4213 } |
| 4214 } else { |
| 4215 int palsize = 1 << (src_format & 0xff); |
| 4216 pDestPalette = FX_Alloc(FX_DWORD, palsize); |
| 4217 if (!pDestPalette) { |
| 4218 return; |
| 4219 } |
| 4220 if (isDstCmyk == isSrcCmyk) { |
| 4221 FXSYS_memcpy32(pDestPalette, pSrcPalette, palsize * sizeof(FX_DWORD)); |
| 2236 } else { | 4222 } else { |
| 2237 src_r = reset_r; | 4223 for (int i = 0; i < palsize; i++) { |
| 2238 src_g = reset_g; | 4224 FX_CMYK cmyk = pSrcPalette[i]; |
| 2239 src_b = reset_b; | 4225 FX_BYTE r, g, b; |
| 2240 } | 4226 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), |
| 2241 if (clip_scan == NULL || clip_scan[col] == 255) { | 4227 FXSYS_GetMValue(cmyk), |
| 2242 *dest_scan++ = src_b; | 4228 FXSYS_GetYValue(cmyk), |
| 2243 *dest_scan++ = src_g; | 4229 FXSYS_GetKValue(cmyk), |
| 2244 *dest_scan++ = src_r; | 4230 r, |
| 4231 g, |
| 4232 b); |
| 4233 pDestPalette[i] = FXARGB_MAKE(0xff, r, g, b); |
| 4234 } |
| 4235 } |
| 4236 } |
| 4237 } else { |
| 4238 if ((dest_format & 0xff) == 8) { |
| 4239 int pal_count = 1 << (src_format & 0xff); |
| 4240 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count); |
| 4241 if (!gray_pal) { |
| 4242 return; |
| 4243 } |
| 4244 if (pal_count == 2) { |
| 4245 gray_pal[0] = 0; |
| 4246 gray_pal[1] = 255; |
| 4247 } else { |
| 4248 for (int i = 0; i < pal_count; i++) { |
| 4249 gray_pal[i] = i; |
| 4250 } |
| 4251 } |
| 4252 pDestPalette = (FX_DWORD*)gray_pal; |
| 4253 } else { |
| 4254 int palsize = 1 << (src_format & 0xff); |
| 4255 pDestPalette = FX_Alloc(FX_DWORD, palsize); |
| 4256 if (!pDestPalette) { |
| 4257 return; |
| 4258 } |
| 4259 if (palsize == 2) { |
| 4260 pDestPalette[0] = isSrcCmyk ? 255 : 0xff000000; |
| 4261 pDestPalette[1] = isSrcCmyk ? 0 : 0xffffffff; |
| 4262 } else { |
| 4263 for (int i = 0; i < palsize; i++) { |
| 4264 pDestPalette[i] = isSrcCmyk ? FX_CCOLOR(i) : (i * 0x10101); |
| 4265 } |
| 4266 } |
| 4267 if (isSrcCmyk != isDstCmyk) { |
| 4268 for (int i = 0; i < palsize; i++) { |
| 4269 FX_CMYK cmyk = pDestPalette[i]; |
| 4270 FX_BYTE r, g, b; |
| 4271 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), |
| 4272 FXSYS_GetMValue(cmyk), |
| 4273 FXSYS_GetYValue(cmyk), |
| 4274 FXSYS_GetKValue(cmyk), |
| 4275 r, |
| 4276 g, |
| 4277 b); |
| 4278 pDestPalette[i] = FXARGB_MAKE(0xff, r, g, b); |
| 4279 } |
| 4280 } |
| 4281 } |
| 4282 } |
| 4283 } |
| 4284 } |
| 4285 CFX_ScanlineCompositor::CFX_ScanlineCompositor() { |
| 4286 m_pSrcPalette = NULL; |
| 4287 m_pCacheScanline = NULL; |
| 4288 m_CacheSize = 0; |
| 4289 m_bRgbByteOrder = FALSE; |
| 4290 m_BlendType = FXDIB_BLEND_NORMAL; |
| 4291 } |
| 4292 CFX_ScanlineCompositor::~CFX_ScanlineCompositor() { |
| 4293 if (m_pSrcPalette) { |
| 4294 FX_Free(m_pSrcPalette); |
| 4295 } |
| 4296 if (m_pCacheScanline) { |
| 4297 FX_Free(m_pCacheScanline); |
| 4298 } |
| 4299 } |
| 4300 FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format, |
| 4301 FXDIB_Format src_format, |
| 4302 FX_INT32 width, |
| 4303 FX_DWORD* pSrcPalette, |
| 4304 FX_DWORD mask_color, |
| 4305 int blend_type, |
| 4306 FX_BOOL bClip, |
| 4307 FX_BOOL bRgbByteOrder, |
| 4308 int alpha_flag, |
| 4309 void* pIccTransform) { |
| 4310 m_SrcFormat = src_format; |
| 4311 m_DestFormat = dest_format; |
| 4312 m_BlendType = blend_type; |
| 4313 m_bRgbByteOrder = bRgbByteOrder; |
| 4314 ICodec_IccModule* pIccModule = NULL; |
| 4315 if (CFX_GEModule::Get()->GetCodecModule()) { |
| 4316 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 4317 } |
| 4318 if (pIccModule == NULL) { |
| 4319 pIccTransform = NULL; |
| 4320 } |
| 4321 m_pIccTransform = pIccTransform; |
| 4322 if ((dest_format & 0xff) == 1) { |
| 4323 return FALSE; |
| 4324 } |
| 4325 if (m_SrcFormat == FXDIB_1bppMask || m_SrcFormat == FXDIB_8bppMask) { |
| 4326 return _ScanlineCompositor_InitSourceMask(dest_format, |
| 4327 alpha_flag, |
| 4328 mask_color, |
| 4329 m_MaskAlpha, |
| 4330 m_MaskRed, |
| 4331 m_MaskGreen, |
| 4332 m_MaskBlue, |
| 4333 m_MaskBlack, |
| 4334 pIccModule, |
| 4335 pIccTransform); |
| 4336 } |
| 4337 if (pIccTransform == NULL && (~src_format & 0x0400) && |
| 4338 (dest_format & 0x0400)) { |
| 4339 return FALSE; |
| 4340 } |
| 4341 if ((m_SrcFormat & 0xff) <= 8) { |
| 4342 if (dest_format == FXDIB_8bppMask) { |
| 4343 return TRUE; |
| 4344 } |
| 4345 _ScanlineCompositor_InitSourcePalette(src_format, |
| 4346 dest_format, |
| 4347 m_pSrcPalette, |
| 4348 pSrcPalette, |
| 4349 pIccModule, |
| 4350 pIccTransform); |
| 4351 m_Transparency = |
| 4352 (dest_format == FXDIB_Argb ? 1 : 0) + (dest_format & 0x0200 ? 2 : 0) + |
| 4353 (dest_format & 0x0400 ? 4 : 0) + ((src_format & 0xff) == 1 ? 8 : 0); |
| 4354 return TRUE; |
| 4355 } |
| 4356 m_Transparency = (src_format & 0x0200 ? 0 : 1) + |
| 4357 (dest_format & 0x0200 ? 0 : 2) + |
| 4358 (blend_type == FXDIB_BLEND_NORMAL ? 4 : 0) + |
| 4359 (bClip ? 8 : 0) + (src_format & 0x0400 ? 16 : 0) + |
| 4360 (dest_format & 0x0400 ? 32 : 0) + (pIccTransform ? 64 : 0); |
| 4361 return TRUE; |
| 4362 } |
| 4363 void CFX_ScanlineCompositor::CompositeRgbBitmapLine(FX_LPBYTE dest_scan, |
| 4364 FX_LPCBYTE src_scan, |
| 4365 int width, |
| 4366 FX_LPCBYTE clip_scan, |
| 4367 FX_LPCBYTE src_extra_alpha, |
| 4368 FX_LPBYTE dst_extra_alpha) { |
| 4369 int src_Bpp = (m_SrcFormat & 0xff) >> 3; |
| 4370 int dest_Bpp = (m_DestFormat & 0xff) >> 3; |
| 4371 if (m_bRgbByteOrder) { |
| 4372 switch (m_Transparency) { |
| 4373 case 0: |
| 4374 case 4: |
| 4375 case 8: |
| 4376 case 12: |
| 4377 _CompositeRow_Argb2Argb_RgbByteOrder( |
| 4378 dest_scan, src_scan, width, m_BlendType, clip_scan); |
| 4379 break; |
| 4380 case 1: |
| 4381 _CompositeRow_Rgb2Argb_Blend_NoClip_RgbByteOrder( |
| 4382 dest_scan, src_scan, width, m_BlendType, src_Bpp); |
| 4383 break; |
| 4384 case 2: |
| 4385 case 10: |
| 4386 _CompositeRow_Argb2Rgb_Blend_RgbByteOrder( |
| 4387 dest_scan, src_scan, width, m_BlendType, dest_Bpp, clip_scan); |
| 4388 break; |
| 4389 case 3: |
| 4390 _CompositeRow_Rgb2Rgb_Blend_NoClip_RgbByteOrder( |
| 4391 dest_scan, src_scan, width, m_BlendType, dest_Bpp, src_Bpp); |
| 4392 break; |
| 4393 case 5: |
| 4394 _CompositeRow_Rgb2Argb_NoBlend_NoClip_RgbByteOrder( |
| 4395 dest_scan, src_scan, width, src_Bpp); |
| 4396 break; |
| 4397 case 6: |
| 4398 case 14: |
| 4399 _CompositeRow_Argb2Rgb_NoBlend_RgbByteOrder( |
| 4400 dest_scan, src_scan, width, dest_Bpp, clip_scan); |
| 4401 break; |
| 4402 case 7: |
| 4403 _CompositeRow_Rgb2Rgb_NoBlend_NoClip_RgbByteOrder( |
| 4404 dest_scan, src_scan, width, dest_Bpp, src_Bpp); |
| 4405 break; |
| 4406 case 9: |
| 4407 _CompositeRow_Rgb2Argb_Blend_Clip_RgbByteOrder( |
| 4408 dest_scan, src_scan, width, m_BlendType, src_Bpp, clip_scan); |
| 4409 break; |
| 4410 case 11: |
| 4411 _CompositeRow_Rgb2Rgb_Blend_Clip_RgbByteOrder(dest_scan, |
| 4412 src_scan, |
| 4413 width, |
| 4414 m_BlendType, |
| 4415 dest_Bpp, |
| 4416 src_Bpp, |
| 4417 clip_scan); |
| 4418 break; |
| 4419 case 13: |
| 4420 _CompositeRow_Rgb2Argb_NoBlend_Clip_RgbByteOrder( |
| 4421 dest_scan, src_scan, width, src_Bpp, clip_scan); |
| 4422 break; |
| 4423 case 15: |
| 4424 _CompositeRow_Rgb2Rgb_NoBlend_Clip_RgbByteOrder( |
| 4425 dest_scan, src_scan, width, dest_Bpp, src_Bpp, clip_scan); |
| 4426 break; |
| 4427 } |
| 4428 return; |
| 4429 } |
| 4430 if (m_DestFormat == FXDIB_8bppMask) { |
| 4431 if (m_SrcFormat & 0x0200) { |
| 4432 if (m_SrcFormat == FXDIB_Argb) { |
| 4433 _CompositeRow_Argb2Mask(dest_scan, src_scan, width, clip_scan); |
| 4434 } else { |
| 4435 _CompositeRow_Rgba2Mask(dest_scan, src_extra_alpha, width, clip_scan); |
| 4436 } |
| 4437 } else { |
| 4438 _CompositeRow_Rgb2Mask(dest_scan, src_scan, width, clip_scan); |
| 4439 } |
| 4440 } else if ((m_DestFormat & 0xff) == 8) { |
| 4441 if (m_DestFormat & 0x0400) { |
| 4442 for (int i = 0; i < width; i++) { |
| 4443 *dest_scan = ~*dest_scan; |
| 4444 dest_scan++; |
| 4445 } |
| 4446 } |
| 4447 if (m_SrcFormat & 0x0200) { |
| 4448 if (m_DestFormat & 0x0200) { |
| 4449 _CompositeRow_Argb2Graya(dest_scan, |
| 4450 src_scan, |
| 4451 width, |
| 4452 m_BlendType, |
| 4453 clip_scan, |
| 4454 src_extra_alpha, |
| 4455 dst_extra_alpha, |
| 4456 m_pIccTransform); |
| 4457 } else { |
| 4458 _CompositeRow_Argb2Gray(dest_scan, |
| 4459 src_scan, |
| 4460 width, |
| 4461 m_BlendType, |
| 4462 clip_scan, |
| 4463 src_extra_alpha, |
| 4464 m_pIccTransform); |
| 4465 } |
| 4466 } else { |
| 4467 if (m_DestFormat & 0x0200) { |
| 4468 _CompositeRow_Rgb2Graya(dest_scan, |
| 4469 src_scan, |
| 4470 src_Bpp, |
| 4471 width, |
| 4472 m_BlendType, |
| 4473 clip_scan, |
| 4474 dst_extra_alpha, |
| 4475 m_pIccTransform); |
| 4476 } else { |
| 4477 _CompositeRow_Rgb2Gray(dest_scan, |
| 4478 src_scan, |
| 4479 src_Bpp, |
| 4480 width, |
| 4481 m_BlendType, |
| 4482 clip_scan, |
| 4483 m_pIccTransform); |
| 4484 } |
| 4485 } |
| 4486 if (m_DestFormat & 0x0400) { |
| 4487 for (int i = 0; i < width; i++) { |
| 4488 *dest_scan = ~*dest_scan; |
| 4489 dest_scan++; |
| 4490 } |
| 4491 } |
| 4492 } else { |
| 4493 int dest_Size = width * dest_Bpp + 4; |
| 4494 if (dest_Size > m_CacheSize) { |
| 4495 m_pCacheScanline = FX_Realloc(FX_BYTE, m_pCacheScanline, dest_Size); |
| 4496 if (!m_pCacheScanline) { |
| 4497 return; |
| 4498 } |
| 4499 m_CacheSize = dest_Size; |
| 4500 } |
| 4501 switch (m_Transparency) { |
| 4502 case 0: |
| 4503 case 4: |
| 4504 case 8: |
| 4505 case 4 + 8: { |
| 4506 _CompositeRow_Argb2Argb(dest_scan, |
| 4507 src_scan, |
| 4508 width, |
| 4509 m_BlendType, |
| 4510 clip_scan, |
| 4511 dst_extra_alpha, |
| 4512 src_extra_alpha); |
| 4513 } break; |
| 4514 case 64: |
| 4515 case 4 + 64: |
| 4516 case 8 + 64: |
| 4517 case 4 + 8 + 64: { |
| 4518 _CompositeRow_Argb2Argb_Transform(dest_scan, |
| 4519 src_scan, |
| 4520 width, |
| 4521 m_BlendType, |
| 4522 clip_scan, |
| 4523 dst_extra_alpha, |
| 4524 src_extra_alpha, |
| 4525 m_pCacheScanline, |
| 4526 m_pIccTransform); |
| 4527 } break; |
| 4528 case 1: |
| 4529 _CompositeRow_Rgb2Argb_Blend_NoClip( |
| 4530 dest_scan, src_scan, width, m_BlendType, src_Bpp, dst_extra_alpha); |
| 4531 break; |
| 4532 case 1 + 64: |
| 4533 _CompositeRow_Rgb2Argb_Blend_NoClip_Transform(dest_scan, |
| 4534 src_scan, |
| 4535 width, |
| 4536 m_BlendType, |
| 4537 src_Bpp, |
| 4538 dst_extra_alpha, |
| 4539 m_pCacheScanline, |
| 4540 m_pIccTransform); |
| 4541 break; |
| 4542 case 1 + 8: |
| 4543 _CompositeRow_Rgb2Argb_Blend_Clip(dest_scan, |
| 4544 src_scan, |
| 4545 width, |
| 4546 m_BlendType, |
| 4547 src_Bpp, |
| 4548 clip_scan, |
| 4549 dst_extra_alpha); |
| 4550 break; |
| 4551 case 1 + 8 + 64: |
| 4552 _CompositeRow_Rgb2Argb_Blend_Clip_Transform(dest_scan, |
| 4553 src_scan, |
| 4554 width, |
| 4555 m_BlendType, |
| 4556 src_Bpp, |
| 4557 clip_scan, |
| 4558 dst_extra_alpha, |
| 4559 m_pCacheScanline, |
| 4560 m_pIccTransform); |
| 4561 break; |
| 4562 case 1 + 4: |
| 4563 _CompositeRow_Rgb2Argb_NoBlend_NoClip( |
| 4564 dest_scan, src_scan, width, src_Bpp, dst_extra_alpha); |
| 4565 break; |
| 4566 case 1 + 4 + 64: |
| 4567 _CompositeRow_Rgb2Argb_NoBlend_NoClip_Transform(dest_scan, |
| 4568 src_scan, |
| 4569 width, |
| 4570 src_Bpp, |
| 4571 dst_extra_alpha, |
| 4572 m_pCacheScanline, |
| 4573 m_pIccTransform); |
| 4574 break; |
| 4575 case 1 + 4 + 8: |
| 4576 _CompositeRow_Rgb2Argb_NoBlend_Clip( |
| 4577 dest_scan, src_scan, width, src_Bpp, clip_scan, dst_extra_alpha); |
| 4578 break; |
| 4579 case 1 + 4 + 8 + 64: |
| 4580 _CompositeRow_Rgb2Argb_NoBlend_Clip_Transform(dest_scan, |
| 4581 src_scan, |
| 4582 width, |
| 4583 src_Bpp, |
| 4584 clip_scan, |
| 4585 dst_extra_alpha, |
| 4586 m_pCacheScanline, |
| 4587 m_pIccTransform); |
| 4588 break; |
| 4589 case 2: |
| 4590 case 2 + 8: |
| 4591 _CompositeRow_Argb2Rgb_Blend(dest_scan, |
| 4592 src_scan, |
| 4593 width, |
| 4594 m_BlendType, |
| 4595 dest_Bpp, |
| 4596 clip_scan, |
| 4597 src_extra_alpha); |
| 4598 break; |
| 4599 case 2 + 64: |
| 4600 case 2 + 8 + 64: |
| 4601 _CompositeRow_Argb2Rgb_Blend_Transform(dest_scan, |
| 4602 src_scan, |
| 4603 width, |
| 4604 m_BlendType, |
| 4605 dest_Bpp, |
| 4606 clip_scan, |
| 4607 src_extra_alpha, |
| 4608 m_pCacheScanline, |
| 4609 m_pIccTransform); |
| 4610 break; |
| 4611 case 2 + 4: |
| 4612 case 2 + 4 + 8: |
| 4613 _CompositeRow_Argb2Rgb_NoBlend( |
| 4614 dest_scan, src_scan, width, dest_Bpp, clip_scan, src_extra_alpha); |
| 4615 break; |
| 4616 case 2 + 4 + 64: |
| 4617 case 2 + 4 + 8 + 64: |
| 4618 _CompositeRow_Argb2Rgb_NoBlend_Transform(dest_scan, |
| 4619 src_scan, |
| 4620 width, |
| 4621 dest_Bpp, |
| 4622 clip_scan, |
| 4623 src_extra_alpha, |
| 4624 m_pCacheScanline, |
| 4625 m_pIccTransform); |
| 4626 break; |
| 4627 case 1 + 2: |
| 4628 _CompositeRow_Rgb2Rgb_Blend_NoClip( |
| 4629 dest_scan, src_scan, width, m_BlendType, dest_Bpp, src_Bpp); |
| 4630 break; |
| 4631 case 1 + 2 + 64: |
| 4632 _CompositeRow_Rgb2Rgb_Blend_NoClip_Transform(dest_scan, |
| 4633 src_scan, |
| 4634 width, |
| 4635 m_BlendType, |
| 4636 dest_Bpp, |
| 4637 src_Bpp, |
| 4638 m_pCacheScanline, |
| 4639 m_pIccTransform); |
| 4640 break; |
| 4641 case 1 + 2 + 8: |
| 4642 _CompositeRow_Rgb2Rgb_Blend_Clip(dest_scan, |
| 4643 src_scan, |
| 4644 width, |
| 4645 m_BlendType, |
| 4646 dest_Bpp, |
| 4647 src_Bpp, |
| 4648 clip_scan); |
| 4649 break; |
| 4650 case 1 + 2 + 8 + 64: |
| 4651 _CompositeRow_Rgb2Rgb_Blend_Clip_Transform(dest_scan, |
| 4652 src_scan, |
| 4653 width, |
| 4654 m_BlendType, |
| 4655 dest_Bpp, |
| 4656 src_Bpp, |
| 4657 clip_scan, |
| 4658 m_pCacheScanline, |
| 4659 m_pIccTransform); |
| 4660 break; |
| 4661 case 1 + 2 + 4: |
| 4662 _CompositeRow_Rgb2Rgb_NoBlend_NoClip( |
| 4663 dest_scan, src_scan, width, dest_Bpp, src_Bpp); |
| 4664 break; |
| 4665 case 1 + 2 + 4 + 64: |
| 4666 _CompositeRow_Rgb2Rgb_NoBlend_NoClip_Transform(dest_scan, |
| 4667 src_scan, |
| 4668 width, |
| 4669 dest_Bpp, |
| 4670 src_Bpp, |
| 4671 m_pCacheScanline, |
| 4672 m_pIccTransform); |
| 4673 break; |
| 4674 case 1 + 2 + 4 + 8: |
| 4675 _CompositeRow_Rgb2Rgb_NoBlend_Clip( |
| 4676 dest_scan, src_scan, width, dest_Bpp, src_Bpp, clip_scan); |
| 4677 break; |
| 4678 case 1 + 2 + 4 + 8 + 64: |
| 4679 _CompositeRow_Rgb2Rgb_NoBlend_Clip_Transform(dest_scan, |
| 4680 src_scan, |
| 4681 width, |
| 4682 dest_Bpp, |
| 4683 src_Bpp, |
| 4684 clip_scan, |
| 4685 m_pCacheScanline, |
| 4686 m_pIccTransform); |
| 4687 break; |
| 4688 } |
| 4689 } |
| 4690 } |
| 4691 void CFX_ScanlineCompositor::CompositePalBitmapLine(FX_LPBYTE dest_scan, |
| 4692 FX_LPCBYTE src_scan, |
| 4693 int src_left, |
| 4694 int width, |
| 4695 FX_LPCBYTE clip_scan, |
| 4696 FX_LPCBYTE src_extra_alpha, |
| 4697 FX_LPBYTE dst_extra_alpha) { |
| 4698 if (m_bRgbByteOrder) { |
| 4699 if (m_SrcFormat == FXDIB_1bppRgb) { |
| 4700 if (m_DestFormat == FXDIB_8bppRgb) { |
| 4701 return; |
| 4702 } else if (m_DestFormat == FXDIB_Argb) { |
| 4703 _CompositeRow_1bppRgb2Argb_NoBlend_RgbByteOrder( |
| 4704 dest_scan, src_scan, src_left, width, m_pSrcPalette, clip_scan); |
| 4705 } else { |
| 4706 _CompositeRow_1bppRgb2Rgb_NoBlend_RgbByteOrder( |
| 4707 dest_scan, |
| 4708 src_scan, |
| 4709 src_left, |
| 4710 m_pSrcPalette, |
| 4711 width, |
| 4712 (m_DestFormat & 0xff) >> 3, |
| 4713 clip_scan); |
| 4714 } |
| 4715 } else { |
| 4716 if (m_DestFormat == FXDIB_8bppRgb) { |
| 4717 return; |
| 4718 } else if (m_DestFormat == FXDIB_Argb) { |
| 4719 _CompositeRow_8bppRgb2Argb_NoBlend_RgbByteOrder( |
| 4720 dest_scan, src_scan, width, m_pSrcPalette, clip_scan); |
| 4721 } else { |
| 4722 _CompositeRow_8bppRgb2Rgb_NoBlend_RgbByteOrder( |
| 4723 dest_scan, |
| 4724 src_scan, |
| 4725 m_pSrcPalette, |
| 4726 width, |
| 4727 (m_DestFormat & 0xff) >> 3, |
| 4728 clip_scan); |
| 4729 } |
| 4730 } |
| 4731 return; |
| 4732 } |
| 4733 if (m_DestFormat == FXDIB_8bppMask) { |
| 4734 _CompositeRow_Rgb2Mask(dest_scan, src_scan, width, clip_scan); |
| 4735 return; |
| 4736 } else if ((m_DestFormat & 0xff) == 8) { |
| 4737 if (m_Transparency & 8) { |
| 4738 if (m_DestFormat & 0x0200) { |
| 4739 _CompositeRow_1bppPal2Graya(dest_scan, |
| 4740 src_scan, |
| 4741 src_left, |
| 4742 (FX_LPCBYTE)m_pSrcPalette, |
| 4743 width, |
| 4744 m_BlendType, |
| 4745 clip_scan, |
| 4746 dst_extra_alpha); |
| 4747 } else { |
| 4748 _CompositeRow_1bppPal2Gray(dest_scan, |
| 4749 src_scan, |
| 4750 src_left, |
| 4751 (FX_LPCBYTE)m_pSrcPalette, |
| 4752 width, |
| 4753 m_BlendType, |
| 4754 clip_scan); |
| 4755 } |
| 4756 } else { |
| 4757 if (m_DestFormat & 0x0200) |
| 4758 _CompositeRow_8bppPal2Graya(dest_scan, |
| 4759 src_scan, |
| 4760 (FX_LPCBYTE)m_pSrcPalette, |
| 4761 width, |
| 4762 m_BlendType, |
| 4763 clip_scan, |
| 4764 dst_extra_alpha, |
| 4765 src_extra_alpha); |
| 4766 else |
| 4767 _CompositeRow_8bppPal2Gray(dest_scan, |
| 4768 src_scan, |
| 4769 (FX_LPCBYTE)m_pSrcPalette, |
| 4770 width, |
| 4771 m_BlendType, |
| 4772 clip_scan, |
| 4773 src_extra_alpha); |
| 4774 } |
| 4775 } else { |
| 4776 switch (m_Transparency) { |
| 4777 case 1 + 2: |
| 4778 _CompositeRow_8bppRgb2Argb_NoBlend(dest_scan, |
| 4779 src_scan, |
| 4780 width, |
| 4781 m_pSrcPalette, |
| 4782 clip_scan, |
| 4783 src_extra_alpha); |
| 4784 break; |
| 4785 case 1 + 2 + 8: |
| 4786 _CompositeRow_1bppRgb2Argb_NoBlend( |
| 4787 dest_scan, src_scan, src_left, width, m_pSrcPalette, clip_scan); |
| 4788 break; |
| 4789 case 0: |
| 4790 _CompositeRow_8bppRgb2Rgb_NoBlend(dest_scan, |
| 4791 src_scan, |
| 4792 m_pSrcPalette, |
| 4793 width, |
| 4794 (m_DestFormat & 0xff) >> 3, |
| 4795 clip_scan, |
| 4796 src_extra_alpha); |
| 4797 break; |
| 4798 case 0 + 8: |
| 4799 _CompositeRow_1bppRgb2Rgb_NoBlend(dest_scan, |
| 4800 src_scan, |
| 4801 src_left, |
| 4802 m_pSrcPalette, |
| 4803 width, |
| 4804 (m_DestFormat & 0xff) >> 3, |
| 4805 clip_scan); |
| 4806 break; |
| 4807 case 0 + 2: |
| 4808 _CompositeRow_8bppRgb2Rgb_NoBlend(dest_scan, |
| 4809 src_scan, |
| 4810 m_pSrcPalette, |
| 4811 width, |
| 4812 (m_DestFormat & 0xff) >> 3, |
| 4813 clip_scan, |
| 4814 src_extra_alpha); |
| 4815 break; |
| 4816 case 0 + 2 + 8: |
| 4817 _CompositeRow_1bppRgb2Rgba_NoBlend(dest_scan, |
| 4818 src_scan, |
| 4819 src_left, |
| 4820 width, |
| 4821 m_pSrcPalette, |
| 4822 clip_scan, |
| 4823 dst_extra_alpha); |
| 4824 break; |
| 4825 break; |
| 4826 } |
| 4827 } |
| 4828 } |
| 4829 void CFX_ScanlineCompositor::CompositeByteMaskLine(FX_LPBYTE dest_scan, |
| 4830 FX_LPCBYTE src_scan, |
| 4831 int width, |
| 4832 FX_LPCBYTE clip_scan, |
| 4833 FX_LPBYTE dst_extra_alpha) { |
| 4834 if (m_DestFormat == FXDIB_8bppMask) { |
| 4835 _CompositeRow_ByteMask2Mask( |
| 4836 dest_scan, src_scan, m_MaskAlpha, width, clip_scan); |
| 4837 } else if ((m_DestFormat & 0xff) == 8) { |
| 4838 if (m_DestFormat & 0x0200) { |
| 4839 _CompositeRow_ByteMask2Graya(dest_scan, |
| 4840 src_scan, |
| 4841 m_MaskAlpha, |
| 4842 m_MaskRed, |
| 4843 width, |
| 4844 clip_scan, |
| 4845 dst_extra_alpha); |
| 4846 } else { |
| 4847 _CompositeRow_ByteMask2Gray( |
| 4848 dest_scan, src_scan, m_MaskAlpha, m_MaskRed, width, clip_scan); |
| 4849 } |
| 4850 } else if (m_bRgbByteOrder) { |
| 4851 if (m_DestFormat == FXDIB_Argb) |
| 4852 _CompositeRow_ByteMask2Argb_RgbByteOrder(dest_scan, |
| 4853 src_scan, |
| 4854 m_MaskAlpha, |
| 4855 m_MaskRed, |
| 4856 m_MaskGreen, |
| 4857 m_MaskBlue, |
| 4858 width, |
| 4859 m_BlendType, |
| 4860 clip_scan); |
| 4861 else |
| 4862 _CompositeRow_ByteMask2Rgb_RgbByteOrder(dest_scan, |
| 4863 src_scan, |
| 4864 m_MaskAlpha, |
| 4865 m_MaskRed, |
| 4866 m_MaskGreen, |
| 4867 m_MaskBlue, |
| 4868 width, |
| 4869 m_BlendType, |
| 4870 (m_DestFormat & 0xff) >> 3, |
| 4871 clip_scan); |
| 4872 return; |
| 4873 } else if (m_DestFormat == FXDIB_Argb) |
| 4874 _CompositeRow_ByteMask2Argb(dest_scan, |
| 4875 src_scan, |
| 4876 m_MaskAlpha, |
| 4877 m_MaskRed, |
| 4878 m_MaskGreen, |
| 4879 m_MaskBlue, |
| 4880 width, |
| 4881 m_BlendType, |
| 4882 clip_scan); |
| 4883 else if (m_DestFormat == FXDIB_Rgb || m_DestFormat == FXDIB_Rgb32) |
| 4884 _CompositeRow_ByteMask2Rgb(dest_scan, |
| 4885 src_scan, |
| 4886 m_MaskAlpha, |
| 4887 m_MaskRed, |
| 4888 m_MaskGreen, |
| 4889 m_MaskBlue, |
| 4890 width, |
| 4891 m_BlendType, |
| 4892 (m_DestFormat & 0xff) >> 3, |
| 4893 clip_scan); |
| 4894 else if (m_DestFormat == FXDIB_Rgba) |
| 4895 _CompositeRow_ByteMask2Rgba(dest_scan, |
| 4896 src_scan, |
| 4897 m_MaskAlpha, |
| 4898 m_MaskRed, |
| 4899 m_MaskGreen, |
| 4900 m_MaskBlue, |
| 4901 width, |
| 4902 m_BlendType, |
| 4903 clip_scan, |
| 4904 dst_extra_alpha); |
| 4905 } |
| 4906 void CFX_ScanlineCompositor::CompositeBitMaskLine(FX_LPBYTE dest_scan, |
| 4907 FX_LPCBYTE src_scan, |
| 4908 int src_left, |
| 4909 int width, |
| 4910 FX_LPCBYTE clip_scan, |
| 4911 FX_LPBYTE dst_extra_alpha) { |
| 4912 if (m_DestFormat == FXDIB_8bppMask) { |
| 4913 _CompositeRow_BitMask2Mask( |
| 4914 dest_scan, src_scan, m_MaskAlpha, src_left, width, clip_scan); |
| 4915 } else if ((m_DestFormat & 0xff) == 8) { |
| 4916 if (m_DestFormat & 0x0200) |
| 4917 _CompositeRow_BitMask2Graya(dest_scan, |
| 4918 src_scan, |
| 4919 m_MaskAlpha, |
| 4920 m_MaskRed, |
| 4921 src_left, |
| 4922 width, |
| 4923 clip_scan, |
| 4924 dst_extra_alpha); |
| 4925 else { |
| 4926 _CompositeRow_BitMask2Gray(dest_scan, |
| 4927 src_scan, |
| 4928 m_MaskAlpha, |
| 4929 m_MaskRed, |
| 4930 src_left, |
| 4931 width, |
| 4932 clip_scan); |
| 4933 } |
| 4934 } else if (m_bRgbByteOrder) { |
| 4935 if (m_DestFormat == FXDIB_Argb) |
| 4936 _CompositeRow_BitMask2Argb_RgbByteOrder(dest_scan, |
| 4937 src_scan, |
| 4938 m_MaskAlpha, |
| 4939 m_MaskRed, |
| 4940 m_MaskGreen, |
| 4941 m_MaskBlue, |
| 4942 src_left, |
| 4943 width, |
| 4944 m_BlendType, |
| 4945 clip_scan); |
| 4946 else |
| 4947 _CompositeRow_BitMask2Rgb_RgbByteOrder(dest_scan, |
| 4948 src_scan, |
| 4949 m_MaskAlpha, |
| 4950 m_MaskRed, |
| 4951 m_MaskGreen, |
| 4952 m_MaskBlue, |
| 4953 src_left, |
| 4954 width, |
| 4955 m_BlendType, |
| 4956 (m_DestFormat & 0xff) >> 3, |
| 4957 clip_scan); |
| 4958 return; |
| 4959 } else if (m_DestFormat == FXDIB_Argb) |
| 4960 _CompositeRow_BitMask2Argb(dest_scan, |
| 4961 src_scan, |
| 4962 m_MaskAlpha, |
| 4963 m_MaskRed, |
| 4964 m_MaskGreen, |
| 4965 m_MaskBlue, |
| 4966 src_left, |
| 4967 width, |
| 4968 m_BlendType, |
| 4969 clip_scan); |
| 4970 else if (m_DestFormat == FXDIB_Rgb || m_DestFormat == FXDIB_Rgb32) |
| 4971 _CompositeRow_BitMask2Rgb(dest_scan, |
| 4972 src_scan, |
| 4973 m_MaskAlpha, |
| 4974 m_MaskRed, |
| 4975 m_MaskGreen, |
| 4976 m_MaskBlue, |
| 4977 src_left, |
| 4978 width, |
| 4979 m_BlendType, |
| 4980 (m_DestFormat & 0xff) >> 3, |
| 4981 clip_scan); |
| 4982 } |
| 4983 FX_BOOL CFX_DIBitmap::CompositeBitmap(int dest_left, |
| 4984 int dest_top, |
| 4985 int width, |
| 4986 int height, |
| 4987 const CFX_DIBSource* pSrcBitmap, |
| 4988 int src_left, |
| 4989 int src_top, |
| 4990 int blend_type, |
| 4991 const CFX_ClipRgn* pClipRgn, |
| 4992 FX_BOOL bRgbByteOrder, |
| 4993 void* pIccTransform) { |
| 4994 if (m_pBuffer == NULL) { |
| 4995 return FALSE; |
| 4996 } |
| 4997 ASSERT(!pSrcBitmap->IsAlphaMask()); |
| 4998 ASSERT(m_bpp >= 8); |
| 4999 if (pSrcBitmap->IsAlphaMask() || m_bpp < 8) { |
| 5000 return FALSE; |
| 5001 } |
| 5002 GetOverlapRect(dest_left, |
| 5003 dest_top, |
| 5004 width, |
| 5005 height, |
| 5006 pSrcBitmap->GetWidth(), |
| 5007 pSrcBitmap->GetHeight(), |
| 5008 src_left, |
| 5009 src_top, |
| 5010 pClipRgn); |
| 5011 if (width == 0 || height == 0) { |
| 5012 return TRUE; |
| 5013 } |
| 5014 const CFX_DIBitmap* pClipMask = NULL; |
| 5015 FX_RECT clip_box; |
| 5016 if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { |
| 5017 ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF); |
| 5018 pClipMask = pClipRgn->GetMask(); |
| 5019 clip_box = pClipRgn->GetBox(); |
| 5020 } |
| 5021 CFX_ScanlineCompositor compositor; |
| 5022 if (!compositor.Init(GetFormat(), |
| 5023 pSrcBitmap->GetFormat(), |
| 5024 width, |
| 5025 pSrcBitmap->GetPalette(), |
| 5026 0, |
| 5027 blend_type, |
| 5028 pClipMask != NULL, |
| 5029 bRgbByteOrder, |
| 5030 0, |
| 5031 pIccTransform)) { |
| 5032 return FALSE; |
| 5033 } |
| 5034 int dest_Bpp = m_bpp / 8; |
| 5035 int src_Bpp = pSrcBitmap->GetBPP() / 8; |
| 5036 FX_BOOL bRgb = FALSE; |
| 5037 FX_BOOL bCmyk = FALSE; |
| 5038 if (src_Bpp > 1) { |
| 5039 if (pSrcBitmap->IsCmykImage()) { |
| 5040 bCmyk = TRUE; |
| 5041 } else { |
| 5042 bRgb = TRUE; |
| 5043 } |
| 5044 } |
| 5045 CFX_DIBitmap* pSrcAlphaMask = pSrcBitmap->m_pAlphaMask; |
| 5046 for (int row = 0; row < height; row++) { |
| 5047 FX_LPBYTE dest_scan = |
| 5048 m_pBuffer + (dest_top + row) * m_Pitch + dest_left * dest_Bpp; |
| 5049 FX_LPCBYTE src_scan = |
| 5050 pSrcBitmap->GetScanline(src_top + row) + src_left * src_Bpp; |
| 5051 FX_LPCBYTE src_scan_extra_alpha = |
| 5052 pSrcAlphaMask ? pSrcAlphaMask->GetScanline(src_top + row) + src_left |
| 5053 : NULL; |
| 5054 FX_LPBYTE dst_scan_extra_alpha = |
| 5055 m_pAlphaMask |
| 5056 ? (FX_LPBYTE)m_pAlphaMask->GetScanline(dest_top + row) + dest_left |
| 5057 : NULL; |
| 5058 FX_LPCBYTE clip_scan = NULL; |
| 5059 if (pClipMask) { |
| 5060 clip_scan = pClipMask->m_pBuffer + |
| 5061 (dest_top + row - clip_box.top) * pClipMask->m_Pitch + |
| 5062 (dest_left - clip_box.left); |
| 5063 } |
| 5064 if (bRgb) { |
| 5065 compositor.CompositeRgbBitmapLine(dest_scan, |
| 5066 src_scan, |
| 5067 width, |
| 5068 clip_scan, |
| 5069 src_scan_extra_alpha, |
| 5070 dst_scan_extra_alpha); |
| 5071 } else { |
| 5072 compositor.CompositePalBitmapLine(dest_scan, |
| 5073 src_scan, |
| 5074 src_left, |
| 5075 width, |
| 5076 clip_scan, |
| 5077 src_scan_extra_alpha, |
| 5078 dst_scan_extra_alpha); |
| 5079 } |
| 5080 } |
| 5081 return TRUE; |
| 5082 } |
| 5083 FX_BOOL CFX_DIBitmap::CompositeMask(int dest_left, |
| 5084 int dest_top, |
| 5085 int width, |
| 5086 int height, |
| 5087 const CFX_DIBSource* pMask, |
| 5088 FX_DWORD color, |
| 5089 int src_left, |
| 5090 int src_top, |
| 5091 int blend_type, |
| 5092 const CFX_ClipRgn* pClipRgn, |
| 5093 FX_BOOL bRgbByteOrder, |
| 5094 int alpha_flag, |
| 5095 void* pIccTransform) { |
| 5096 if (m_pBuffer == NULL) { |
| 5097 return FALSE; |
| 5098 } |
| 5099 ASSERT(pMask->IsAlphaMask()); |
| 5100 ASSERT(m_bpp >= 8); |
| 5101 if (!pMask->IsAlphaMask() || m_bpp < 8) { |
| 5102 return FALSE; |
| 5103 } |
| 5104 GetOverlapRect(dest_left, |
| 5105 dest_top, |
| 5106 width, |
| 5107 height, |
| 5108 pMask->GetWidth(), |
| 5109 pMask->GetHeight(), |
| 5110 src_left, |
| 5111 src_top, |
| 5112 pClipRgn); |
| 5113 if (width == 0 || height == 0) { |
| 5114 return TRUE; |
| 5115 } |
| 5116 int src_alpha = |
| 5117 (FX_BYTE)(alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color); |
| 5118 if (src_alpha == 0) { |
| 5119 return TRUE; |
| 5120 } |
| 5121 const CFX_DIBitmap* pClipMask = NULL; |
| 5122 FX_RECT clip_box; |
| 5123 if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { |
| 5124 ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF); |
| 5125 pClipMask = pClipRgn->GetMask(); |
| 5126 clip_box = pClipRgn->GetBox(); |
| 5127 } |
| 5128 int src_bpp = pMask->GetBPP(); |
| 5129 int Bpp = GetBPP() / 8; |
| 5130 CFX_ScanlineCompositor compositor; |
| 5131 if (!compositor.Init(GetFormat(), |
| 5132 pMask->GetFormat(), |
| 5133 width, |
| 5134 NULL, |
| 5135 color, |
| 5136 blend_type, |
| 5137 pClipMask != NULL, |
| 5138 bRgbByteOrder, |
| 5139 alpha_flag, |
| 5140 pIccTransform)) { |
| 5141 return FALSE; |
| 5142 } |
| 5143 for (int row = 0; row < height; row++) { |
| 5144 FX_LPBYTE dest_scan = |
| 5145 m_pBuffer + (dest_top + row) * m_Pitch + dest_left * Bpp; |
| 5146 FX_LPCBYTE src_scan = pMask->GetScanline(src_top + row); |
| 5147 FX_LPBYTE dst_scan_extra_alpha = |
| 5148 m_pAlphaMask |
| 5149 ? (FX_LPBYTE)m_pAlphaMask->GetScanline(dest_top + row) + dest_left |
| 5150 : NULL; |
| 5151 FX_LPCBYTE clip_scan = NULL; |
| 5152 if (pClipMask) { |
| 5153 clip_scan = pClipMask->m_pBuffer + |
| 5154 (dest_top + row - clip_box.top) * pClipMask->m_Pitch + |
| 5155 (dest_left - clip_box.left); |
| 5156 } |
| 5157 if (src_bpp == 1) { |
| 5158 compositor.CompositeBitMaskLine(dest_scan, |
| 5159 src_scan, |
| 5160 src_left, |
| 5161 width, |
| 5162 clip_scan, |
| 5163 dst_scan_extra_alpha); |
| 5164 } else { |
| 5165 compositor.CompositeByteMaskLine(dest_scan, |
| 5166 src_scan + src_left, |
| 5167 width, |
| 5168 clip_scan, |
| 5169 dst_scan_extra_alpha); |
| 5170 } |
| 5171 } |
| 5172 return TRUE; |
| 5173 } |
| 5174 FX_BOOL CFX_DIBitmap::CompositeRect(int left, |
| 5175 int top, |
| 5176 int width, |
| 5177 int height, |
| 5178 FX_DWORD color, |
| 5179 int alpha_flag, |
| 5180 void* pIccTransform) { |
| 5181 if (m_pBuffer == NULL) { |
| 5182 return FALSE; |
| 5183 } |
| 5184 int src_alpha = (alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color); |
| 5185 if (src_alpha == 0) { |
| 5186 return TRUE; |
| 5187 } |
| 5188 FX_RECT rect(left, top, left + width, top + height); |
| 5189 rect.Intersect(0, 0, m_Width, m_Height); |
| 5190 if (rect.IsEmpty()) { |
| 5191 return TRUE; |
| 5192 } |
| 5193 width = rect.Width(); |
| 5194 FX_DWORD dst_color; |
| 5195 if (alpha_flag >> 8) { |
| 5196 dst_color = FXCMYK_TODIB(color); |
| 5197 } else { |
| 5198 dst_color = FXARGB_TODIB(color); |
| 5199 } |
| 5200 FX_LPBYTE color_p = (FX_LPBYTE)&dst_color; |
| 5201 if (m_bpp == 8) { |
| 5202 FX_BYTE gray = 255; |
| 5203 if (!IsAlphaMask()) { |
| 5204 if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && |
| 5205 CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { |
| 5206 ICodec_IccModule* pIccModule = |
| 5207 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 5208 pIccModule->TranslateScanline(pIccTransform, &gray, color_p, 1); |
| 5209 } else { |
| 5210 if (alpha_flag >> 8) { |
| 5211 FX_BYTE r, g, b; |
| 5212 AdobeCMYK_to_sRGB1( |
| 5213 color_p[0], color_p[1], color_p[2], color_p[3], r, g, b); |
| 5214 gray = FXRGB2GRAY(r, g, b); |
| 5215 } else { |
| 5216 gray = (FX_BYTE)FXRGB2GRAY((int)color_p[2], color_p[1], color_p[0]); |
| 5217 } |
| 5218 } |
| 5219 if (IsCmykImage()) { |
| 5220 gray = ~gray; |
| 5221 } |
| 5222 } |
| 5223 for (int row = rect.top; row < rect.bottom; row++) { |
| 5224 FX_LPBYTE dest_scan = m_pBuffer + row * m_Pitch + rect.left; |
| 5225 if (src_alpha == 255) { |
| 5226 FXSYS_memset8(dest_scan, gray, width); |
| 5227 } else |
| 5228 for (int col = 0; col < width; col++) { |
| 5229 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 5230 dest_scan++; |
| 5231 } |
| 5232 } |
| 5233 return TRUE; |
| 5234 } else if (m_bpp == 1) { |
| 5235 ASSERT(!IsCmykImage() && (FX_BYTE)(alpha_flag >> 8) == 0); |
| 5236 int left_shift = rect.left % 8; |
| 5237 int right_shift = rect.right % 8; |
| 5238 int width = rect.right / 8 - rect.left / 8; |
| 5239 int index = 0; |
| 5240 if (m_pPalette == NULL) { |
| 5241 index = ((FX_BYTE)color == 0xff) ? 1 : 0; |
| 5242 } else { |
| 5243 for (int i = 0; i < 2; i++) |
| 5244 if (m_pPalette[i] == color) { |
| 5245 index = i; |
| 5246 } |
| 5247 } |
| 5248 for (int row = rect.top; row < rect.bottom; row++) { |
| 5249 FX_BYTE* dest_scan_top = (FX_BYTE*)GetScanline(row) + rect.left / 8; |
| 5250 FX_BYTE* dest_scan_top_r = (FX_BYTE*)GetScanline(row) + rect.right / 8; |
| 5251 FX_BYTE left_flag = *dest_scan_top & (255 << (8 - left_shift)); |
| 5252 FX_BYTE right_flag = *dest_scan_top_r & (255 >> right_shift); |
| 5253 if (width) { |
| 5254 FXSYS_memset8(dest_scan_top + 1, index ? 255 : 0, width - 1); |
| 5255 if (!index) { |
| 5256 *dest_scan_top &= left_flag; |
| 5257 *dest_scan_top_r &= right_flag; |
| 5258 } else { |
| 5259 *dest_scan_top |= ~left_flag; |
| 5260 *dest_scan_top_r |= ~right_flag; |
| 5261 } |
| 5262 } else { |
| 5263 if (!index) { |
| 5264 *dest_scan_top &= left_flag | right_flag; |
| 5265 } else { |
| 5266 *dest_scan_top |= ~(left_flag | right_flag); |
| 5267 } |
| 5268 } |
| 5269 } |
| 5270 return TRUE; |
| 5271 } |
| 5272 ASSERT(m_bpp >= 24); |
| 5273 if (m_bpp < 24) { |
| 5274 return FALSE; |
| 5275 } |
| 5276 if (pIccTransform && CFX_GEModule::Get()->GetCodecModule()) { |
| 5277 ICodec_IccModule* pIccModule = |
| 5278 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 5279 pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1); |
| 5280 } else { |
| 5281 if (alpha_flag >> 8 && !IsCmykImage()) |
| 5282 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), |
| 5283 FXSYS_GetMValue(color), |
| 5284 FXSYS_GetYValue(color), |
| 5285 FXSYS_GetKValue(color), |
| 5286 color_p[2], |
| 5287 color_p[1], |
| 5288 color_p[0]); |
| 5289 else if (!(alpha_flag >> 8) && IsCmykImage()) { |
| 5290 return FALSE; |
| 5291 } |
| 5292 } |
| 5293 if (!IsCmykImage()) { |
| 5294 color_p[3] = (FX_BYTE)src_alpha; |
| 5295 } |
| 5296 int Bpp = m_bpp / 8; |
| 5297 FX_BOOL bAlpha = HasAlpha(); |
| 5298 FX_BOOL bArgb = GetFormat() == FXDIB_Argb ? TRUE : FALSE; |
| 5299 if (src_alpha == 255) { |
| 5300 for (int row = rect.top; row < rect.bottom; row++) { |
| 5301 FX_LPBYTE dest_scan = m_pBuffer + row * m_Pitch + rect.left * Bpp; |
| 5302 FX_LPBYTE dest_scan_alpha = |
| 5303 m_pAlphaMask ? (FX_LPBYTE)m_pAlphaMask->GetScanline(row) + rect.left |
| 5304 : NULL; |
| 5305 if (dest_scan_alpha) { |
| 5306 FXSYS_memset8(dest_scan_alpha, 0xff, width); |
| 5307 } |
| 5308 if (Bpp == 4) { |
| 5309 FX_DWORD* scan = (FX_DWORD*)dest_scan; |
| 5310 for (int col = 0; col < width; col++) { |
| 5311 *scan++ = dst_color; |
| 5312 } |
| 5313 } else { |
| 5314 for (int col = 0; col < width; col++) { |
| 5315 *dest_scan++ = color_p[0]; |
| 5316 *dest_scan++ = color_p[1]; |
| 5317 *dest_scan++ = color_p[2]; |
| 5318 } |
| 5319 } |
| 5320 } |
| 5321 return TRUE; |
| 5322 } |
| 5323 for (int row = rect.top; row < rect.bottom; row++) { |
| 5324 FX_LPBYTE dest_scan = m_pBuffer + row * m_Pitch + rect.left * Bpp; |
| 5325 if (bAlpha) { |
| 5326 if (bArgb) { |
| 5327 for (int col = 0; col < width; col++) { |
| 5328 FX_BYTE back_alpha = dest_scan[3]; |
| 5329 if (back_alpha == 0) { |
| 5330 FXARGB_SETDIB( |
| 5331 dest_scan, |
| 5332 FXARGB_MAKE(src_alpha, color_p[2], color_p[1], color_p[0])); |
| 5333 dest_scan += 4; |
| 5334 continue; |
| 5335 } |
| 5336 FX_BYTE dest_alpha = |
| 5337 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 5338 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 5339 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, color_p[0], alpha_ratio); |
| 5340 dest_scan++; |
| 5341 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, color_p[1], alpha_ratio); |
| 5342 dest_scan++; |
| 5343 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, color_p[2], alpha_ratio); |
| 5344 dest_scan++; |
| 5345 *dest_scan++ = dest_alpha; |
| 5346 } |
| 5347 } else { |
| 5348 FX_LPBYTE dest_scan_alpha = |
| 5349 (FX_LPBYTE)m_pAlphaMask->GetScanline(row) + rect.left; |
| 5350 for (int col = 0; col < width; col++) { |
| 5351 FX_BYTE back_alpha = *dest_scan_alpha; |
| 5352 if (back_alpha == 0) { |
| 5353 *dest_scan_alpha++ = src_alpha; |
| 5354 FXSYS_memcpy32(dest_scan, color_p, Bpp); |
| 5355 dest_scan += Bpp; |
| 5356 continue; |
| 5357 } |
| 5358 FX_BYTE dest_alpha = |
| 5359 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 5360 *dest_scan_alpha++ = dest_alpha; |
| 5361 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 5362 for (int comps = 0; comps < Bpp; comps++) { |
| 5363 *dest_scan = |
| 5364 FXDIB_ALPHA_MERGE(*dest_scan, color_p[comps], alpha_ratio); |
| 5365 dest_scan++; |
| 5366 } |
| 5367 } |
| 5368 } |
| 5369 } else { |
| 5370 for (int col = 0; col < width; col++) { |
| 5371 for (int comps = 0; comps < Bpp; comps++) { |
| 5372 if (comps == 3) { |
| 2245 *dest_scan++ = 255; | 5373 *dest_scan++ = 255; |
| 2246 continue; | 5374 continue; |
| 2247 } | 5375 } |
| 2248 int src_alpha = clip_scan[col]; | 5376 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, color_p[comps], src_alpha); |
| 2249 if (src_alpha == 0) { | 5377 dest_scan++; |
| 2250 dest_scan += 4; | 5378 } |
| 2251 continue; | 5379 } |
| 2252 } | 5380 } |
| 2253 int back_alpha = dest_scan[3]; | 5381 } |
| 2254 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | 5382 return TRUE; |
| 2255 dest_scan[3] = dest_alpha; | 5383 } |
| 2256 int alpha_ratio = src_alpha * 255 / dest_alpha; | 5384 CFX_BitmapComposer::CFX_BitmapComposer() { |
| 2257 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); | 5385 m_pScanlineV = NULL; |
| 2258 dest_scan ++; | 5386 m_pScanlineAlphaV = NULL; |
| 2259 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); | 5387 m_pClipScanV = NULL; |
| 2260 dest_scan ++; | 5388 m_pAddClipScan = NULL; |
| 2261 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | 5389 m_bRgbByteOrder = FALSE; |
| 2262 dest_scan ++; | 5390 m_BlendType = FXDIB_BLEND_NORMAL; |
| 2263 dest_scan ++; | 5391 } |
| 2264 } | 5392 CFX_BitmapComposer::~CFX_BitmapComposer() { |
| 2265 } | 5393 if (m_pScanlineV) { |
| 2266 void _CompositeRow_1bppRgb2Rgba_NoBlend(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan
, int src_left, int width, | 5394 FX_Free(m_pScanlineV); |
| 2267 FX_DWORD* pPalette, FX_LPCBYTE clip_scan
, | 5395 } |
| 2268 FX_LPBYTE dest_alpha_scan) | 5396 if (m_pScanlineAlphaV) { |
| 2269 { | 5397 FX_Free(m_pScanlineAlphaV); |
| 2270 int reset_r, reset_g, reset_b; | 5398 } |
| 2271 int set_r, set_g, set_b; | 5399 if (m_pClipScanV) { |
| 2272 reset_r = FXARGB_R(pPalette[0]); | 5400 FX_Free(m_pClipScanV); |
| 2273 reset_g = FXARGB_G(pPalette[0]); | 5401 } |
| 2274 reset_b = FXARGB_B(pPalette[0]); | 5402 if (m_pAddClipScan) { |
| 2275 set_r = FXARGB_R(pPalette[1]); | 5403 FX_Free(m_pAddClipScan); |
| 2276 set_g = FXARGB_G(pPalette[1]); | 5404 } |
| 2277 set_b = FXARGB_B(pPalette[1]); | 5405 } |
| 2278 for (int col = 0; col < width; col ++) { | 5406 void CFX_BitmapComposer::Compose(CFX_DIBitmap* pDest, |
| 2279 int src_r, src_g, src_b; | 5407 const CFX_ClipRgn* pClipRgn, |
| 2280 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
{ | 5408 int bitmap_alpha, |
| 2281 src_r = set_r; | 5409 FX_DWORD mask_color, |
| 2282 src_g = set_g; | 5410 FX_RECT& dest_rect, |
| 2283 src_b = set_b; | 5411 FX_BOOL bVertical, |
| 2284 } else { | 5412 FX_BOOL bFlipX, |
| 2285 src_r = reset_r; | 5413 FX_BOOL bFlipY, |
| 2286 src_g = reset_g; | 5414 FX_BOOL bRgbByteOrder, |
| 2287 src_b = reset_b; | 5415 int alpha_flag, |
| 2288 } | 5416 void* pIccTransform, |
| 2289 if (clip_scan == NULL || clip_scan[col] == 255) { | 5417 int blend_type) { |
| 2290 *dest_scan++ = src_b; | 5418 m_pBitmap = pDest; |
| 2291 *dest_scan++ = src_g; | 5419 m_pClipRgn = pClipRgn; |
| 2292 *dest_scan++ = src_r; | 5420 m_DestLeft = dest_rect.left; |
| 2293 *dest_alpha_scan++ = 255; | 5421 m_DestTop = dest_rect.top; |
| 2294 continue; | 5422 m_DestWidth = dest_rect.Width(); |
| 2295 } | 5423 m_DestHeight = dest_rect.Height(); |
| 2296 int src_alpha = clip_scan[col]; | 5424 m_BitmapAlpha = bitmap_alpha; |
| 2297 if (src_alpha == 0) { | 5425 m_MaskColor = mask_color; |
| 2298 dest_scan += 3; | 5426 m_pClipMask = NULL; |
| 2299 dest_alpha_scan ++; | 5427 if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { |
| 2300 continue; | 5428 m_pClipMask = pClipRgn->GetMask(); |
| 2301 } | 5429 } |
| 2302 int back_alpha = *dest_alpha_scan; | 5430 m_bVertical = bVertical; |
| 2303 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | 5431 m_bFlipX = bFlipX; |
| 2304 *dest_alpha_scan ++ = dest_alpha; | 5432 m_bFlipY = bFlipY; |
| 2305 int alpha_ratio = src_alpha * 255 / dest_alpha; | 5433 m_AlphaFlag = alpha_flag; |
| 2306 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); | 5434 m_pIccTransform = pIccTransform; |
| 2307 dest_scan ++; | 5435 m_bRgbByteOrder = bRgbByteOrder; |
| 2308 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); | 5436 m_BlendType = blend_type; |
| 2309 dest_scan ++; | 5437 } |
| 2310 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | 5438 FX_BOOL CFX_BitmapComposer::SetInfo(int width, |
| 2311 dest_scan ++; | 5439 int height, |
| 2312 } | 5440 FXDIB_Format src_format, |
| 2313 } | 5441 FX_DWORD* pSrcPalette) { |
| 2314 void _CompositeRow_ByteMask2Argb(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int m
ask_alpha, int src_r, int src_g, int src_b, int pixel_count, | 5442 m_SrcFormat = src_format; |
| 2315 int blend_type, FX_LPCBYTE clip_scan) | 5443 if (!m_Compositor.Init(m_pBitmap->GetFormat(), |
| 2316 { | 5444 src_format, |
| 2317 for (int col = 0; col < pixel_count; col ++) { | 5445 width, |
| 2318 int src_alpha; | 5446 pSrcPalette, |
| 2319 if (clip_scan) { | 5447 m_MaskColor, |
| 2320 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; | 5448 FXDIB_BLEND_NORMAL, |
| 2321 } else { | 5449 m_pClipMask != NULL || (m_BitmapAlpha < 255), |
| 2322 src_alpha = mask_alpha * src_scan[col] / 255; | 5450 m_bRgbByteOrder, |
| 2323 } | 5451 m_AlphaFlag, |
| 2324 FX_BYTE back_alpha = dest_scan[3]; | 5452 m_pIccTransform)) { |
| 2325 if (back_alpha == 0) { | 5453 return FALSE; |
| 2326 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_alpha, src_r, src_g, src_b)
); | 5454 } |
| 2327 dest_scan += 4; | 5455 if (m_bVertical) { |
| 2328 continue; | 5456 m_pScanlineV = FX_Alloc(FX_BYTE, m_pBitmap->GetBPP() / 8 * width + 4); |
| 2329 } | 5457 if (!m_pScanlineV) { |
| 2330 if (src_alpha == 0) { | 5458 return FALSE; |
| 2331 dest_scan += 4; | 5459 } |
| 2332 continue; | 5460 m_pClipScanV = FX_Alloc(FX_BYTE, m_pBitmap->GetHeight()); |
| 2333 } | 5461 if (!m_pClipScanV) { |
| 2334 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | 5462 return FALSE; |
| 2335 dest_scan[3] = dest_alpha; | 5463 } |
| 2336 int alpha_ratio = src_alpha * 255 / dest_alpha; | 5464 if (m_pBitmap->m_pAlphaMask) { |
| 2337 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { | 5465 m_pScanlineAlphaV = FX_Alloc(FX_BYTE, width + 4); |
| 2338 int blended_colors[3]; | 5466 if (!m_pScanlineAlphaV) { |
| 2339 FX_BYTE src_scan[3]; | |
| 2340 src_scan[0] = src_b; | |
| 2341 src_scan[1] = src_g; | |
| 2342 src_scan[2] = src_r; | |
| 2343 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 2344 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_
ratio); | |
| 2345 dest_scan ++; | |
| 2346 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], alpha_
ratio); | |
| 2347 dest_scan ++; | |
| 2348 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_
ratio); | |
| 2349 } else if (blend_type) { | |
| 2350 int blended = _BLEND(blend_type, *dest_scan, src_b); | |
| 2351 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); | |
| 2352 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2353 dest_scan ++; | |
| 2354 blended = _BLEND(blend_type, *dest_scan, src_g); | |
| 2355 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); | |
| 2356 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2357 dest_scan ++; | |
| 2358 blended = _BLEND(blend_type, *dest_scan, src_r); | |
| 2359 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); | |
| 2360 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2361 } else { | |
| 2362 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); | |
| 2363 dest_scan ++; | |
| 2364 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); | |
| 2365 dest_scan ++; | |
| 2366 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | |
| 2367 } | |
| 2368 dest_scan += 2; | |
| 2369 } | |
| 2370 } | |
| 2371 void _CompositeRow_ByteMask2Rgba(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int m
ask_alpha, int src_r, int src_g, int src_b, int pixel_count, | |
| 2372 int blend_type, FX_LPCBYTE clip_scan, | |
| 2373 FX_LPBYTE dest_alpha_scan) | |
| 2374 { | |
| 2375 for (int col = 0; col < pixel_count; col ++) { | |
| 2376 int src_alpha; | |
| 2377 if (clip_scan) { | |
| 2378 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; | |
| 2379 } else { | |
| 2380 src_alpha = mask_alpha * src_scan[col] / 255; | |
| 2381 } | |
| 2382 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 2383 if (back_alpha == 0) { | |
| 2384 *dest_scan ++ = src_b; | |
| 2385 *dest_scan ++ = src_g; | |
| 2386 *dest_scan ++ = src_r; | |
| 2387 *dest_alpha_scan ++ = src_alpha; | |
| 2388 continue; | |
| 2389 } | |
| 2390 if (src_alpha == 0) { | |
| 2391 dest_scan += 3; | |
| 2392 dest_alpha_scan ++; | |
| 2393 continue; | |
| 2394 } | |
| 2395 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 2396 *dest_alpha_scan ++ = dest_alpha; | |
| 2397 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 2398 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { | |
| 2399 int blended_colors[3]; | |
| 2400 FX_BYTE src_scan[3]; | |
| 2401 src_scan[0] = src_b; | |
| 2402 src_scan[1] = src_g; | |
| 2403 src_scan[2] = src_r; | |
| 2404 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 2405 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_
ratio); | |
| 2406 dest_scan ++; | |
| 2407 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], alpha_
ratio); | |
| 2408 dest_scan ++; | |
| 2409 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_
ratio); | |
| 2410 dest_scan ++; | |
| 2411 } else if (blend_type) { | |
| 2412 int blended = _BLEND(blend_type, *dest_scan, src_b); | |
| 2413 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); | |
| 2414 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2415 dest_scan ++; | |
| 2416 blended = _BLEND(blend_type, *dest_scan, src_g); | |
| 2417 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); | |
| 2418 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2419 dest_scan ++; | |
| 2420 blended = _BLEND(blend_type, *dest_scan, src_r); | |
| 2421 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); | |
| 2422 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2423 dest_scan ++; | |
| 2424 } else { | |
| 2425 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); | |
| 2426 dest_scan ++; | |
| 2427 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); | |
| 2428 dest_scan ++; | |
| 2429 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | |
| 2430 dest_scan ++; | |
| 2431 } | |
| 2432 } | |
| 2433 } | |
| 2434 void _CompositeRow_ByteMask2Rgb(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int ma
sk_alpha, int src_r, int src_g, int src_b, int pixel_count, | |
| 2435 int blend_type, int Bpp, FX_LPCBYTE clip_scan) | |
| 2436 { | |
| 2437 for (int col = 0; col < pixel_count; col ++) { | |
| 2438 int src_alpha; | |
| 2439 if (clip_scan) { | |
| 2440 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; | |
| 2441 } else { | |
| 2442 src_alpha = mask_alpha * src_scan[col] / 255; | |
| 2443 } | |
| 2444 if (src_alpha == 0) { | |
| 2445 dest_scan += Bpp; | |
| 2446 continue; | |
| 2447 } | |
| 2448 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { | |
| 2449 int blended_colors[3]; | |
| 2450 FX_BYTE src_scan[3]; | |
| 2451 src_scan[0] = src_b; | |
| 2452 src_scan[1] = src_g; | |
| 2453 src_scan[2] = src_r; | |
| 2454 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 2455 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], src_al
pha); | |
| 2456 dest_scan ++; | |
| 2457 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], src_al
pha); | |
| 2458 dest_scan ++; | |
| 2459 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], src_al
pha); | |
| 2460 } else if (blend_type) { | |
| 2461 int blended = _BLEND(blend_type, *dest_scan, src_b); | |
| 2462 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); | |
| 2463 dest_scan ++; | |
| 2464 blended = _BLEND(blend_type, *dest_scan, src_g); | |
| 2465 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); | |
| 2466 dest_scan ++; | |
| 2467 blended = _BLEND(blend_type, *dest_scan, src_r); | |
| 2468 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); | |
| 2469 } else { | |
| 2470 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, src_alpha); | |
| 2471 dest_scan ++; | |
| 2472 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, src_alpha); | |
| 2473 dest_scan ++; | |
| 2474 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, src_alpha); | |
| 2475 } | |
| 2476 dest_scan += Bpp - 2; | |
| 2477 } | |
| 2478 } | |
| 2479 void _CompositeRow_ByteMask2Mask(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int m
ask_alpha, int pixel_count, | |
| 2480 FX_LPCBYTE clip_scan) | |
| 2481 { | |
| 2482 for (int col = 0; col < pixel_count; col ++) { | |
| 2483 int src_alpha; | |
| 2484 if (clip_scan) { | |
| 2485 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; | |
| 2486 } else { | |
| 2487 src_alpha = mask_alpha * src_scan[col] / 255; | |
| 2488 } | |
| 2489 FX_BYTE back_alpha = *dest_scan; | |
| 2490 if (!back_alpha) { | |
| 2491 *dest_scan = src_alpha; | |
| 2492 } else if (src_alpha) { | |
| 2493 *dest_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; | |
| 2494 } | |
| 2495 dest_scan ++; | |
| 2496 } | |
| 2497 } | |
| 2498 void _CompositeRow_ByteMask2Gray(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int m
ask_alpha, int src_gray, | |
| 2499 int pixel_count, FX_LPCBYTE clip_scan) | |
| 2500 { | |
| 2501 for (int col = 0; col < pixel_count; col ++) { | |
| 2502 int src_alpha; | |
| 2503 if (clip_scan) { | |
| 2504 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; | |
| 2505 } else { | |
| 2506 src_alpha = mask_alpha * src_scan[col] / 255; | |
| 2507 } | |
| 2508 if (src_alpha) { | |
| 2509 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_gray, src_alpha); | |
| 2510 } | |
| 2511 dest_scan ++; | |
| 2512 } | |
| 2513 } | |
| 2514 void _CompositeRow_ByteMask2Graya(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int
mask_alpha, int src_gray, | |
| 2515 int pixel_count, FX_LPCBYTE clip_scan, | |
| 2516 FX_LPBYTE dest_alpha_scan) | |
| 2517 { | |
| 2518 for (int col = 0; col < pixel_count; col ++) { | |
| 2519 int src_alpha; | |
| 2520 if (clip_scan) { | |
| 2521 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; | |
| 2522 } else { | |
| 2523 src_alpha = mask_alpha * src_scan[col] / 255; | |
| 2524 } | |
| 2525 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 2526 if (back_alpha == 0) { | |
| 2527 *dest_scan ++ = src_gray; | |
| 2528 *dest_alpha_scan ++ = src_alpha; | |
| 2529 continue; | |
| 2530 } | |
| 2531 if (src_alpha == 0) { | |
| 2532 dest_scan ++; | |
| 2533 dest_alpha_scan ++; | |
| 2534 continue; | |
| 2535 } | |
| 2536 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 2537 *dest_alpha_scan++ = dest_alpha; | |
| 2538 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 2539 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_gray, alpha_ratio); | |
| 2540 dest_scan ++; | |
| 2541 } | |
| 2542 } | |
| 2543 void _CompositeRow_BitMask2Argb(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int ma
sk_alpha, int src_r, int src_g, int src_b, | |
| 2544 int src_left, int pixel_count, int blend_type, F
X_LPCBYTE clip_scan) | |
| 2545 { | |
| 2546 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && mask_alpha == 2
55) { | |
| 2547 FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b); | |
| 2548 for (int col = 0; col < pixel_count; col ++) { | |
| 2549 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8
))) { | |
| 2550 FXARGB_SETDIB(dest_scan, argb); | |
| 2551 } | |
| 2552 dest_scan += 4; | |
| 2553 } | |
| 2554 return; | |
| 2555 } | |
| 2556 for (int col = 0; col < pixel_count; col ++) { | |
| 2557 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))
)) { | |
| 2558 dest_scan += 4; | |
| 2559 continue; | |
| 2560 } | |
| 2561 int src_alpha; | |
| 2562 if (clip_scan) { | |
| 2563 src_alpha = mask_alpha * clip_scan[col] / 255; | |
| 2564 } else { | |
| 2565 src_alpha = mask_alpha; | |
| 2566 } | |
| 2567 FX_BYTE back_alpha = dest_scan[3]; | |
| 2568 if (back_alpha == 0) { | |
| 2569 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_alpha, src_r, src_g, src_b)
); | |
| 2570 dest_scan += 4; | |
| 2571 continue; | |
| 2572 } | |
| 2573 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 2574 dest_scan[3] = dest_alpha; | |
| 2575 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 2576 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { | |
| 2577 int blended_colors[3]; | |
| 2578 FX_BYTE src_scan[3]; | |
| 2579 src_scan[0] = src_b; | |
| 2580 src_scan[1] = src_g; | |
| 2581 src_scan[2] = src_r; | |
| 2582 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 2583 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_
ratio); | |
| 2584 dest_scan ++; | |
| 2585 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], alpha_
ratio); | |
| 2586 dest_scan ++; | |
| 2587 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_
ratio); | |
| 2588 } else if (blend_type) { | |
| 2589 int blended = _BLEND(blend_type, *dest_scan, src_b); | |
| 2590 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); | |
| 2591 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2592 dest_scan ++; | |
| 2593 blended = _BLEND(blend_type, *dest_scan, src_g); | |
| 2594 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); | |
| 2595 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2596 dest_scan ++; | |
| 2597 blended = _BLEND(blend_type, *dest_scan, src_r); | |
| 2598 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); | |
| 2599 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2600 } else { | |
| 2601 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); | |
| 2602 dest_scan ++; | |
| 2603 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); | |
| 2604 dest_scan ++; | |
| 2605 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | |
| 2606 } | |
| 2607 dest_scan += 2; | |
| 2608 } | |
| 2609 } | |
| 2610 void _CompositeRow_BitMask2Rgba(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int ma
sk_alpha, int src_r, int src_g, int src_b, | |
| 2611 int src_left, int pixel_count, int blend_type, F
X_LPCBYTE clip_scan, | |
| 2612 FX_LPBYTE dest_alpha_scan) | |
| 2613 { | |
| 2614 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && mask_alpha == 2
55) { | |
| 2615 for (int col = 0; col < pixel_count; col ++) { | |
| 2616 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8
))) { | |
| 2617 dest_scan[0] = src_b; | |
| 2618 dest_scan[1] = src_g; | |
| 2619 dest_scan[2] = src_r; | |
| 2620 *dest_alpha_scan = mask_alpha; | |
| 2621 } | |
| 2622 dest_scan += 3; | |
| 2623 dest_alpha_scan ++; | |
| 2624 } | |
| 2625 return; | |
| 2626 } | |
| 2627 for (int col = 0; col < pixel_count; col ++) { | |
| 2628 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))
)) { | |
| 2629 dest_scan += 3; | |
| 2630 dest_alpha_scan ++; | |
| 2631 continue; | |
| 2632 } | |
| 2633 int src_alpha; | |
| 2634 if (clip_scan) { | |
| 2635 src_alpha = mask_alpha * clip_scan[col] / 255; | |
| 2636 } else { | |
| 2637 src_alpha = mask_alpha; | |
| 2638 } | |
| 2639 FX_BYTE back_alpha = dest_scan[3]; | |
| 2640 if (back_alpha == 0) { | |
| 2641 *dest_scan ++ = src_b; | |
| 2642 *dest_scan ++ = src_g; | |
| 2643 *dest_scan ++ = src_r; | |
| 2644 *dest_alpha_scan ++ = mask_alpha; | |
| 2645 continue; | |
| 2646 } | |
| 2647 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 2648 *dest_alpha_scan ++ = dest_alpha; | |
| 2649 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 2650 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { | |
| 2651 int blended_colors[3]; | |
| 2652 FX_BYTE src_scan[3]; | |
| 2653 src_scan[0] = src_b; | |
| 2654 src_scan[1] = src_g; | |
| 2655 src_scan[2] = src_r; | |
| 2656 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 2657 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], alpha_
ratio); | |
| 2658 dest_scan ++; | |
| 2659 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], alpha_
ratio); | |
| 2660 dest_scan ++; | |
| 2661 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_
ratio); | |
| 2662 dest_scan ++; | |
| 2663 } else if (blend_type) { | |
| 2664 int blended = _BLEND(blend_type, *dest_scan, src_b); | |
| 2665 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); | |
| 2666 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2667 dest_scan ++; | |
| 2668 blended = _BLEND(blend_type, *dest_scan, src_g); | |
| 2669 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); | |
| 2670 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2671 dest_scan ++; | |
| 2672 blended = _BLEND(blend_type, *dest_scan, src_r); | |
| 2673 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); | |
| 2674 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); | |
| 2675 dest_scan ++; | |
| 2676 } else { | |
| 2677 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio); | |
| 2678 dest_scan ++; | |
| 2679 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio); | |
| 2680 dest_scan ++; | |
| 2681 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | |
| 2682 dest_scan ++; | |
| 2683 } | |
| 2684 } | |
| 2685 } | |
| 2686 void _CompositeRow_BitMask2Rgb(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int mas
k_alpha, int src_r, int src_g, int src_b, | |
| 2687 int src_left, int pixel_count, int blend_type, in
t Bpp, FX_LPCBYTE clip_scan) | |
| 2688 { | |
| 2689 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && mask_alpha == 2
55) { | |
| 2690 for (int col = 0; col < pixel_count; col ++) { | |
| 2691 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8
))) { | |
| 2692 dest_scan[2] = src_r; | |
| 2693 dest_scan[1] = src_g; | |
| 2694 dest_scan[0] = src_b; | |
| 2695 } | |
| 2696 dest_scan += Bpp; | |
| 2697 } | |
| 2698 return; | |
| 2699 } | |
| 2700 for (int col = 0; col < pixel_count; col ++) { | |
| 2701 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))
)) { | |
| 2702 dest_scan += Bpp; | |
| 2703 continue; | |
| 2704 } | |
| 2705 int src_alpha; | |
| 2706 if (clip_scan) { | |
| 2707 src_alpha = mask_alpha * clip_scan[col] / 255; | |
| 2708 } else { | |
| 2709 src_alpha = mask_alpha; | |
| 2710 } | |
| 2711 if (src_alpha == 0) { | |
| 2712 dest_scan += Bpp; | |
| 2713 continue; | |
| 2714 } | |
| 2715 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { | |
| 2716 int blended_colors[3]; | |
| 2717 FX_BYTE src_scan[3]; | |
| 2718 src_scan[0] = src_b; | |
| 2719 src_scan[1] = src_g; | |
| 2720 src_scan[2] = src_r; | |
| 2721 _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); | |
| 2722 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[0], src_al
pha); | |
| 2723 dest_scan ++; | |
| 2724 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], src_al
pha); | |
| 2725 dest_scan ++; | |
| 2726 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], src_al
pha); | |
| 2727 } else if (blend_type) { | |
| 2728 int blended = _BLEND(blend_type, *dest_scan, src_b); | |
| 2729 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); | |
| 2730 dest_scan++; | |
| 2731 blended = _BLEND(blend_type, *dest_scan, src_g); | |
| 2732 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); | |
| 2733 dest_scan++; | |
| 2734 blended = _BLEND(blend_type, *dest_scan, src_r); | |
| 2735 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); | |
| 2736 } else { | |
| 2737 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, src_alpha); | |
| 2738 dest_scan ++; | |
| 2739 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, src_alpha); | |
| 2740 dest_scan ++; | |
| 2741 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, src_alpha); | |
| 2742 } | |
| 2743 dest_scan += Bpp - 2; | |
| 2744 } | |
| 2745 } | |
| 2746 void _CompositeRow_BitMask2Mask(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int ma
sk_alpha, int src_left, | |
| 2747 int pixel_count, FX_LPCBYTE clip_scan) | |
| 2748 { | |
| 2749 for (int col = 0; col < pixel_count; col ++) { | |
| 2750 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))
)) { | |
| 2751 dest_scan ++; | |
| 2752 continue; | |
| 2753 } | |
| 2754 int src_alpha; | |
| 2755 if (clip_scan) { | |
| 2756 src_alpha = mask_alpha * clip_scan[col] / 255; | |
| 2757 } else { | |
| 2758 src_alpha = mask_alpha; | |
| 2759 } | |
| 2760 FX_BYTE back_alpha = *dest_scan; | |
| 2761 if (!back_alpha) { | |
| 2762 *dest_scan = src_alpha; | |
| 2763 } else if (src_alpha) { | |
| 2764 *dest_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; | |
| 2765 } | |
| 2766 dest_scan ++; | |
| 2767 } | |
| 2768 } | |
| 2769 void _CompositeRow_BitMask2Gray(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int ma
sk_alpha, int src_gray, | |
| 2770 int src_left, int pixel_count, FX_LPCBYTE clip_s
can) | |
| 2771 { | |
| 2772 for (int col = 0; col < pixel_count; col ++) { | |
| 2773 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))
)) { | |
| 2774 dest_scan ++; | |
| 2775 continue; | |
| 2776 } | |
| 2777 int src_alpha; | |
| 2778 if (clip_scan) { | |
| 2779 src_alpha = mask_alpha * clip_scan[col] / 255; | |
| 2780 } else { | |
| 2781 src_alpha = mask_alpha; | |
| 2782 } | |
| 2783 if (src_alpha) { | |
| 2784 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_gray, src_alpha); | |
| 2785 } | |
| 2786 dest_scan ++; | |
| 2787 } | |
| 2788 } | |
| 2789 void _CompositeRow_BitMask2Graya(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int m
ask_alpha, int src_gray, | |
| 2790 int src_left, int pixel_count, FX_LPCBYTE clip_
scan, | |
| 2791 FX_LPBYTE dest_alpha_scan) | |
| 2792 { | |
| 2793 for (int col = 0; col < pixel_count; col ++) { | |
| 2794 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))
)) { | |
| 2795 dest_scan ++; | |
| 2796 dest_alpha_scan ++; | |
| 2797 continue; | |
| 2798 } | |
| 2799 int src_alpha; | |
| 2800 if (clip_scan) { | |
| 2801 src_alpha = mask_alpha * clip_scan[col] / 255; | |
| 2802 } else { | |
| 2803 src_alpha = mask_alpha; | |
| 2804 } | |
| 2805 FX_BYTE back_alpha = *dest_alpha_scan; | |
| 2806 if (back_alpha == 0) { | |
| 2807 *dest_scan ++ = src_gray; | |
| 2808 *dest_alpha_scan ++ = src_alpha; | |
| 2809 continue; | |
| 2810 } | |
| 2811 if (src_alpha == 0) { | |
| 2812 dest_scan ++; | |
| 2813 dest_alpha_scan ++; | |
| 2814 continue; | |
| 2815 } | |
| 2816 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 2817 *dest_alpha_scan++ = dest_alpha; | |
| 2818 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 2819 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_gray, alpha_ratio); | |
| 2820 dest_scan ++; | |
| 2821 } | |
| 2822 } | |
| 2823 void _CompositeRow_Argb2Argb_RgbByteOrder(FX_LPBYTE dest_scan, FX_LPCBYTE src_sc
an, int pixel_count, int blend_type, FX_LPCBYTE clip_scan) | |
| 2824 { | |
| 2825 int blended_colors[3]; | |
| 2826 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 2827 for (int col = 0; col < pixel_count; col ++) { | |
| 2828 FX_BYTE back_alpha = dest_scan[3]; | |
| 2829 if (back_alpha == 0) { | |
| 2830 if (clip_scan) { | |
| 2831 int src_alpha = clip_scan[col] * src_scan[3] / 255; | |
| 2832 dest_scan[3] = src_alpha; | |
| 2833 dest_scan[0] = src_scan[2]; | |
| 2834 dest_scan[1] = src_scan[1]; | |
| 2835 dest_scan[2] = src_scan[0]; | |
| 2836 } else { | |
| 2837 FXARGB_RGBORDERCOPY(dest_scan, src_scan); | |
| 2838 } | |
| 2839 dest_scan += 4; | |
| 2840 src_scan += 4; | |
| 2841 continue; | |
| 2842 } | |
| 2843 FX_BYTE src_alpha; | |
| 2844 if (clip_scan == NULL) { | |
| 2845 src_alpha = src_scan[3]; | |
| 2846 } else { | |
| 2847 src_alpha = clip_scan[col] * src_scan[3] / 255; | |
| 2848 } | |
| 2849 if (src_alpha == 0) { | |
| 2850 dest_scan += 4; | |
| 2851 src_scan += 4; | |
| 2852 continue; | |
| 2853 } | |
| 2854 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 2855 dest_scan[3] = dest_alpha; | |
| 2856 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 2857 if (bNonseparableBlend) { | |
| 2858 FX_BYTE dest_scan_o[3]; | |
| 2859 dest_scan_o[0] = dest_scan[2]; | |
| 2860 dest_scan_o[1] = dest_scan[1]; | |
| 2861 dest_scan_o[2] = dest_scan[0]; | |
| 2862 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); | |
| 2863 } | |
| 2864 for (int color = 0; color < 3; color ++) { | |
| 2865 int index = 2 - color; | |
| 2866 if (blend_type) { | |
| 2867 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 2868 _BLEND(blend_type, dest_scan[index], *src_scan); | |
| 2869 blended = FXDIB_ALPHA_MERGE(*src_scan, blended, back_alpha); | |
| 2870 dest_scan[index] = FXDIB_ALPHA_MERGE(dest_scan[index], blended,
alpha_ratio); | |
| 2871 } else { | |
| 2872 dest_scan[index] = FXDIB_ALPHA_MERGE(dest_scan[index], *src_scan
, alpha_ratio); | |
| 2873 } | |
| 2874 src_scan ++; | |
| 2875 } | |
| 2876 dest_scan += 4; | |
| 2877 src_scan++; | |
| 2878 } | |
| 2879 } | |
| 2880 void _CompositeRow_Rgb2Argb_Blend_NoClip_RgbByteOrder(FX_LPBYTE dest_scan, FX_LP
CBYTE src_scan, int width, int blend_type, int src_Bpp) | |
| 2881 { | |
| 2882 int blended_colors[3]; | |
| 2883 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 2884 int src_gap = src_Bpp - 3; | |
| 2885 for (int col = 0; col < width; col ++) { | |
| 2886 FX_BYTE back_alpha = dest_scan[3]; | |
| 2887 if (back_alpha == 0) { | |
| 2888 if (src_Bpp == 4) { | |
| 2889 FXARGB_SETRGBORDERDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_
scan)); | |
| 2890 } else { | |
| 2891 FXARGB_SETRGBORDERDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[2],
src_scan[1], src_scan[0])); | |
| 2892 } | |
| 2893 dest_scan += 4; | |
| 2894 src_scan += src_Bpp; | |
| 2895 continue; | |
| 2896 } | |
| 2897 dest_scan[3] = 0xff; | |
| 2898 if (bNonseparableBlend) { | |
| 2899 FX_BYTE dest_scan_o[3]; | |
| 2900 dest_scan_o[0] = dest_scan[2]; | |
| 2901 dest_scan_o[1] = dest_scan[1]; | |
| 2902 dest_scan_o[2] = dest_scan[0]; | |
| 2903 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); | |
| 2904 } | |
| 2905 for (int color = 0; color < 3; color ++) { | |
| 2906 int index = 2 - color; | |
| 2907 int src_color = FX_GAMMA(*src_scan); | |
| 2908 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 2909 _BLEND(blend_type, dest_scan[index], src_color); | |
| 2910 dest_scan[index] = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha)
; | |
| 2911 src_scan ++; | |
| 2912 } | |
| 2913 dest_scan += 4; | |
| 2914 src_scan += src_gap; | |
| 2915 } | |
| 2916 } | |
| 2917 inline void _CompositeRow_Argb2Rgb_Blend_RgbByteOrder(FX_LPBYTE dest_scan, FX_LP
CBYTE src_scan, int width, int blend_type, int dest_Bpp, FX_LPCBYTE clip_scan) | |
| 2918 { | |
| 2919 int blended_colors[3]; | |
| 2920 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 2921 for (int col = 0; col < width; col ++) { | |
| 2922 FX_BYTE src_alpha; | |
| 2923 if (clip_scan) { | |
| 2924 src_alpha = src_scan[3] * (*clip_scan++) / 255; | |
| 2925 } else { | |
| 2926 src_alpha = src_scan[3]; | |
| 2927 } | |
| 2928 if (src_alpha == 0) { | |
| 2929 dest_scan += dest_Bpp; | |
| 2930 src_scan += 4; | |
| 2931 continue; | |
| 2932 } | |
| 2933 if (bNonseparableBlend) { | |
| 2934 FX_BYTE dest_scan_o[3]; | |
| 2935 dest_scan_o[0] = dest_scan[2]; | |
| 2936 dest_scan_o[1] = dest_scan[1]; | |
| 2937 dest_scan_o[2] = dest_scan[0]; | |
| 2938 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); | |
| 2939 } | |
| 2940 for (int color = 0; color < 3; color ++) { | |
| 2941 int index = 2 - color; | |
| 2942 int back_color = FX_GAMMA(dest_scan[index]); | |
| 2943 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 2944 _BLEND(blend_type, back_color, *src_scan); | |
| 2945 dest_scan[index] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(back_color, bl
ended, src_alpha)); | |
| 2946 src_scan ++; | |
| 2947 } | |
| 2948 dest_scan += dest_Bpp; | |
| 2949 src_scan ++; | |
| 2950 } | |
| 2951 } | |
| 2952 inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip_RgbByteOrder(FX_LPBYTE dest_sc
an, FX_LPCBYTE src_scan, int width, int src_Bpp) | |
| 2953 { | |
| 2954 for (int col = 0; col < width; col ++) { | |
| 2955 if (src_Bpp == 4) { | |
| 2956 FXARGB_SETRGBORDERDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan
)); | |
| 2957 } else { | |
| 2958 FXARGB_SETRGBORDERDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[2], src_
scan[1], src_scan[0])); | |
| 2959 } | |
| 2960 dest_scan += 4; | |
| 2961 src_scan += src_Bpp; | |
| 2962 } | |
| 2963 } | |
| 2964 inline void _CompositeRow_Rgb2Rgb_Blend_NoClip_RgbByteOrder(FX_LPBYTE dest_scan,
FX_LPCBYTE src_scan, int width, int blend_type, int dest_Bpp, int src_Bpp) | |
| 2965 { | |
| 2966 int blended_colors[3]; | |
| 2967 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 2968 int src_gap = src_Bpp - 3; | |
| 2969 for (int col = 0; col < width; col ++) { | |
| 2970 if (bNonseparableBlend) { | |
| 2971 FX_BYTE dest_scan_o[3]; | |
| 2972 dest_scan_o[0] = dest_scan[2]; | |
| 2973 dest_scan_o[1] = dest_scan[1]; | |
| 2974 dest_scan_o[2] = dest_scan[0]; | |
| 2975 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); | |
| 2976 } | |
| 2977 for (int color = 0; color < 3; color ++) { | |
| 2978 int index = 2 - color; | |
| 2979 int back_color = FX_GAMMA(dest_scan[index]); | |
| 2980 int src_color = FX_GAMMA(*src_scan); | |
| 2981 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 2982 _BLEND(blend_type, back_color, src_color); | |
| 2983 dest_scan[index] = FX_GAMMA_INVERSE(blended); | |
| 2984 src_scan ++; | |
| 2985 } | |
| 2986 dest_scan += dest_Bpp; | |
| 2987 src_scan += src_gap; | |
| 2988 } | |
| 2989 } | |
| 2990 inline void _CompositeRow_Argb2Rgb_NoBlend_RgbByteOrder(FX_LPBYTE dest_scan, FX_
LPCBYTE src_scan, int width, int dest_Bpp, FX_LPCBYTE clip_scan) | |
| 2991 { | |
| 2992 for (int col = 0; col < width; col ++) { | |
| 2993 FX_BYTE src_alpha; | |
| 2994 if (clip_scan) { | |
| 2995 src_alpha = src_scan[3] * (*clip_scan++) / 255; | |
| 2996 } else { | |
| 2997 src_alpha = src_scan[3]; | |
| 2998 } | |
| 2999 if (src_alpha == 255) { | |
| 3000 dest_scan[2] = FX_GAMMA_INVERSE(*src_scan++); | |
| 3001 dest_scan[1] = FX_GAMMA_INVERSE(*src_scan++); | |
| 3002 dest_scan[0] = FX_GAMMA_INVERSE(*src_scan++); | |
| 3003 dest_scan += dest_Bpp; | |
| 3004 src_scan ++; | |
| 3005 continue; | |
| 3006 } | |
| 3007 if (src_alpha == 0) { | |
| 3008 dest_scan += dest_Bpp; | |
| 3009 src_scan += 4; | |
| 3010 continue; | |
| 3011 } | |
| 3012 for (int color = 0; color < 3; color ++) { | |
| 3013 int index = 2 - color; | |
| 3014 dest_scan[index] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX_GAMMA(dest_
scan[index]), *src_scan, src_alpha)); | |
| 3015 src_scan ++; | |
| 3016 } | |
| 3017 dest_scan += dest_Bpp; | |
| 3018 src_scan ++; | |
| 3019 } | |
| 3020 } | |
| 3021 inline void _CompositeRow_Rgb2Rgb_NoBlend_NoClip_RgbByteOrder(FX_LPBYTE dest_sca
n, FX_LPCBYTE src_scan, int width, int dest_Bpp, int src_Bpp) | |
| 3022 { | |
| 3023 for (int col = 0; col < width; col ++) { | |
| 3024 dest_scan[2] = src_scan[0]; | |
| 3025 dest_scan[1] = src_scan[1]; | |
| 3026 dest_scan[0] = src_scan[2]; | |
| 3027 dest_scan += dest_Bpp; | |
| 3028 src_scan += src_Bpp; | |
| 3029 } | |
| 3030 } | |
| 3031 inline void _CompositeRow_Rgb2Argb_Blend_Clip_RgbByteOrder(FX_LPBYTE dest_scan,
FX_LPCBYTE src_scan, int width, int blend_type, int src_Bpp, FX_LPCBYTE clip_sca
n) | |
| 3032 { | |
| 3033 int blended_colors[3]; | |
| 3034 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 3035 int src_gap = src_Bpp - 3; | |
| 3036 for (int col = 0; col < width; col ++) { | |
| 3037 int src_alpha = *clip_scan ++; | |
| 3038 FX_BYTE back_alpha = dest_scan[3]; | |
| 3039 if (back_alpha == 0) { | |
| 3040 dest_scan[2] = FX_GAMMA(*src_scan++); | |
| 3041 dest_scan[1] = FX_GAMMA(*src_scan++); | |
| 3042 dest_scan[0] = FX_GAMMA(*src_scan++); | |
| 3043 src_scan += src_gap; | |
| 3044 dest_scan += 4; | |
| 3045 continue; | |
| 3046 } | |
| 3047 if (src_alpha == 0) { | |
| 3048 dest_scan += 4; | |
| 3049 src_scan += src_Bpp; | |
| 3050 continue; | |
| 3051 } | |
| 3052 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 3053 dest_scan[3] = dest_alpha; | |
| 3054 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 3055 if (bNonseparableBlend) { | |
| 3056 FX_BYTE dest_scan_o[3]; | |
| 3057 dest_scan_o[0] = dest_scan[2]; | |
| 3058 dest_scan_o[1] = dest_scan[1]; | |
| 3059 dest_scan_o[2] = dest_scan[0]; | |
| 3060 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); | |
| 3061 } | |
| 3062 for (int color = 0; color < 3; color ++) { | |
| 3063 int index = 2 - color; | |
| 3064 int src_color = FX_GAMMA(*src_scan); | |
| 3065 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 3066 _BLEND(blend_type, dest_scan[index], src_color); | |
| 3067 blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha); | |
| 3068 dest_scan[index] = FXDIB_ALPHA_MERGE(dest_scan[index], blended, alph
a_ratio); | |
| 3069 src_scan ++; | |
| 3070 } | |
| 3071 dest_scan += 4; | |
| 3072 src_scan += src_gap; | |
| 3073 } | |
| 3074 } | |
| 3075 inline void _CompositeRow_Rgb2Rgb_Blend_Clip_RgbByteOrder(FX_LPBYTE dest_scan, F
X_LPCBYTE src_scan, int width, int blend_type, int dest_Bpp, int src_Bpp, FX_LPC
BYTE clip_scan) | |
| 3076 { | |
| 3077 int blended_colors[3]; | |
| 3078 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | |
| 3079 int src_gap = src_Bpp - 3; | |
| 3080 for (int col = 0; col < width; col ++) { | |
| 3081 FX_BYTE src_alpha = *clip_scan ++; | |
| 3082 if (src_alpha == 0) { | |
| 3083 dest_scan += dest_Bpp; | |
| 3084 src_scan += src_Bpp; | |
| 3085 continue; | |
| 3086 } | |
| 3087 if (bNonseparableBlend) { | |
| 3088 FX_BYTE dest_scan_o[3]; | |
| 3089 dest_scan_o[0] = dest_scan[2]; | |
| 3090 dest_scan_o[1] = dest_scan[1]; | |
| 3091 dest_scan_o[2] = dest_scan[0]; | |
| 3092 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); | |
| 3093 } | |
| 3094 for (int color = 0; color < 3; color ++) { | |
| 3095 int index = 2 - color; | |
| 3096 int src_color = FX_GAMMA(*src_scan); | |
| 3097 int back_color = FX_GAMMA(dest_scan[index]); | |
| 3098 int blended = bNonseparableBlend ? blended_colors[color] : | |
| 3099 _BLEND(blend_type, back_color, src_color); | |
| 3100 dest_scan[index] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(back_color, bl
ended, src_alpha)); | |
| 3101 src_scan ++; | |
| 3102 } | |
| 3103 dest_scan += dest_Bpp; | |
| 3104 src_scan += src_gap; | |
| 3105 } | |
| 3106 } | |
| 3107 inline void _CompositeRow_Rgb2Argb_NoBlend_Clip_RgbByteOrder(FX_LPBYTE dest_scan
, FX_LPCBYTE src_scan, int width, int src_Bpp, FX_LPCBYTE clip_scan) | |
| 3108 { | |
| 3109 int src_gap = src_Bpp - 3; | |
| 3110 for (int col = 0; col < width; col ++) { | |
| 3111 int src_alpha = clip_scan[col]; | |
| 3112 if (src_alpha == 255) { | |
| 3113 dest_scan[2] = FX_GAMMA(*src_scan++); | |
| 3114 dest_scan[1] = FX_GAMMA(*src_scan++); | |
| 3115 dest_scan[0] = FX_GAMMA(*src_scan++); | |
| 3116 dest_scan[3] = 255; | |
| 3117 dest_scan += 4; | |
| 3118 src_scan += src_gap; | |
| 3119 continue; | |
| 3120 } | |
| 3121 if (src_alpha == 0) { | |
| 3122 dest_scan += 4; | |
| 3123 src_scan += src_Bpp; | |
| 3124 continue; | |
| 3125 } | |
| 3126 int back_alpha = dest_scan[3]; | |
| 3127 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 3128 dest_scan[3] = dest_alpha; | |
| 3129 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 3130 for (int color = 0; color < 3; color ++) { | |
| 3131 int index = 2 - color; | |
| 3132 dest_scan[index] = FXDIB_ALPHA_MERGE(dest_scan[index], FX_GAMMA(*src
_scan), alpha_ratio); | |
| 3133 src_scan ++; | |
| 3134 } | |
| 3135 dest_scan += 4; | |
| 3136 src_scan += src_gap; | |
| 3137 } | |
| 3138 } | |
| 3139 inline void _CompositeRow_Rgb2Rgb_NoBlend_Clip_RgbByteOrder(FX_LPBYTE dest_scan,
FX_LPCBYTE src_scan, int width, int dest_Bpp, int src_Bpp, FX_LPCBYTE clip_scan
) | |
| 3140 { | |
| 3141 for (int col = 0; col < width; col ++) { | |
| 3142 int src_alpha = clip_scan[col]; | |
| 3143 if (src_alpha == 255) { | |
| 3144 dest_scan[2] = src_scan[0]; | |
| 3145 dest_scan[1] = src_scan[1]; | |
| 3146 dest_scan[0] = src_scan[2]; | |
| 3147 } else if (src_alpha) { | |
| 3148 dest_scan[2] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan
[2]), FX_GAMMA(*src_scan), src_alpha)); | |
| 3149 src_scan ++; | |
| 3150 dest_scan[1] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan
[1]), FX_GAMMA(*src_scan), src_alpha)); | |
| 3151 src_scan ++; | |
| 3152 dest_scan[0] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan
[0]), FX_GAMMA(*src_scan), src_alpha)); | |
| 3153 dest_scan += dest_Bpp; | |
| 3154 src_scan += src_Bpp - 2; | |
| 3155 continue; | |
| 3156 } | |
| 3157 dest_scan += dest_Bpp; | |
| 3158 src_scan += src_Bpp; | |
| 3159 } | |
| 3160 } | |
| 3161 inline void _CompositeRow_8bppRgb2Rgb_NoBlend_RgbByteOrder(FX_LPBYTE dest_scan,
FX_LPCBYTE src_scan, FX_ARGB* pPalette, int pixel_count, | |
| 3162 int DestBpp, FX_LPCBYTE clip_scan) | |
| 3163 { | |
| 3164 for (int col = 0; col < pixel_count; col ++) { | |
| 3165 FX_ARGB argb = pPalette ? pPalette[*src_scan] : (*src_scan) * 0x010101; | |
| 3166 int src_r = FXARGB_R(argb); | |
| 3167 int src_g = FXARGB_G(argb); | |
| 3168 int src_b = FXARGB_B(argb); | |
| 3169 if (clip_scan && clip_scan[col] < 255) { | |
| 3170 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], src_b, clip_scan[col]
); | |
| 3171 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], src_g, clip_scan[col]
); | |
| 3172 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], src_r, clip_scan[col]
); | |
| 3173 } else { | |
| 3174 dest_scan[2] = src_b; | |
| 3175 dest_scan[1] = src_g; | |
| 3176 dest_scan[0] = src_r; | |
| 3177 } | |
| 3178 dest_scan += DestBpp; | |
| 3179 src_scan ++; | |
| 3180 } | |
| 3181 } | |
| 3182 inline void _CompositeRow_1bppRgb2Rgb_NoBlend_RgbByteOrder(FX_LPBYTE dest_scan,
FX_LPCBYTE src_scan, int src_left, | |
| 3183 FX_ARGB* pPalette, int pixel_count, int DestBpp, FX_LPCBYTE clip_scan) | |
| 3184 { | |
| 3185 int reset_r, reset_g, reset_b; | |
| 3186 int set_r, set_g, set_b; | |
| 3187 if (pPalette) { | |
| 3188 reset_r = FXARGB_R(pPalette[0]); | |
| 3189 reset_g = FXARGB_G(pPalette[0]); | |
| 3190 reset_b = FXARGB_B(pPalette[0]); | |
| 3191 set_r = FXARGB_R(pPalette[1]); | |
| 3192 set_g = FXARGB_G(pPalette[1]); | |
| 3193 set_b = FXARGB_B(pPalette[1]); | |
| 3194 } else { | |
| 3195 reset_r = reset_g = reset_b = 0; | |
| 3196 set_r = set_g = set_b = 255; | |
| 3197 } | |
| 3198 for (int col = 0; col < pixel_count; col ++) { | |
| 3199 int src_r, src_g, src_b; | |
| 3200 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
{ | |
| 3201 src_r = set_r; | |
| 3202 src_g = set_g; | |
| 3203 src_b = set_b; | |
| 3204 } else { | |
| 3205 src_r = reset_r; | |
| 3206 src_g = reset_g; | |
| 3207 src_b = reset_b; | |
| 3208 } | |
| 3209 if (clip_scan && clip_scan[col] < 255) { | |
| 3210 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], src_b, clip_scan[col]
); | |
| 3211 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], src_g, clip_scan[col]
); | |
| 3212 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], src_r, clip_scan[col]
); | |
| 3213 } else { | |
| 3214 dest_scan[2] = src_b; | |
| 3215 dest_scan[1] = src_g; | |
| 3216 dest_scan[0] = src_r; | |
| 3217 } | |
| 3218 dest_scan += DestBpp; | |
| 3219 } | |
| 3220 } | |
| 3221 inline void _CompositeRow_8bppRgb2Argb_NoBlend_RgbByteOrder(FX_LPBYTE dest_scan,
FX_LPCBYTE src_scan, int width, | |
| 3222 FX_ARGB* pPalette, FX_LPCBYTE clip_scan) | |
| 3223 { | |
| 3224 for (int col = 0; col < width; col ++) { | |
| 3225 int src_r, src_g, src_b; | |
| 3226 if (pPalette) { | |
| 3227 FX_ARGB argb = pPalette[*src_scan]; | |
| 3228 src_r = FXARGB_R(argb); | |
| 3229 src_g = FXARGB_G(argb); | |
| 3230 src_b = FXARGB_B(argb); | |
| 3231 } else { | |
| 3232 src_r = src_g = src_b = *src_scan; | |
| 3233 } | |
| 3234 if (clip_scan == NULL || clip_scan[col] == 255) { | |
| 3235 dest_scan[2] = FX_GAMMA(src_b); | |
| 3236 dest_scan[1] = FX_GAMMA(src_g); | |
| 3237 dest_scan[0] = FX_GAMMA(src_r); | |
| 3238 dest_scan[3] = 255; | |
| 3239 src_scan ++; | |
| 3240 dest_scan += 4; | |
| 3241 continue; | |
| 3242 } | |
| 3243 int src_alpha = clip_scan[col]; | |
| 3244 if (src_alpha == 0) { | |
| 3245 dest_scan += 4; | |
| 3246 src_scan ++; | |
| 3247 continue; | |
| 3248 } | |
| 3249 int back_alpha = dest_scan[3]; | |
| 3250 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 3251 dest_scan[3] = dest_alpha; | |
| 3252 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 3253 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], FX_GAMMA(src_b), alpha_ra
tio); | |
| 3254 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], FX_GAMMA(src_g), alpha_ra
tio); | |
| 3255 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], FX_GAMMA(src_r), alpha_ra
tio); | |
| 3256 dest_scan += 4; | |
| 3257 src_scan ++; | |
| 3258 } | |
| 3259 } | |
| 3260 inline void _CompositeRow_1bppRgb2Argb_NoBlend_RgbByteOrder(FX_LPBYTE dest_scan,
FX_LPCBYTE src_scan, int src_left, int width, | |
| 3261 FX_ARGB* pPalette, FX_LPCBYTE clip_scan) | |
| 3262 { | |
| 3263 int reset_r, reset_g, reset_b; | |
| 3264 int set_r, set_g, set_b; | |
| 3265 if (pPalette) { | |
| 3266 reset_r = FXARGB_R(pPalette[0]); | |
| 3267 reset_g = FXARGB_G(pPalette[0]); | |
| 3268 reset_b = FXARGB_B(pPalette[0]); | |
| 3269 set_r = FXARGB_R(pPalette[1]); | |
| 3270 set_g = FXARGB_G(pPalette[1]); | |
| 3271 set_b = FXARGB_B(pPalette[1]); | |
| 3272 } else { | |
| 3273 reset_r = reset_g = reset_b = 0; | |
| 3274 set_r = set_g = set_b = 255; | |
| 3275 } | |
| 3276 for (int col = 0; col < width; col ++) { | |
| 3277 int src_r, src_g, src_b; | |
| 3278 if (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
{ | |
| 3279 src_r = set_r; | |
| 3280 src_g = set_g; | |
| 3281 src_b = set_b; | |
| 3282 } else { | |
| 3283 src_r = reset_r; | |
| 3284 src_g = reset_g; | |
| 3285 src_b = reset_b; | |
| 3286 } | |
| 3287 if (clip_scan == NULL || clip_scan[col] == 255) { | |
| 3288 dest_scan[2] = FX_GAMMA(src_b); | |
| 3289 dest_scan[1] = FX_GAMMA(src_g); | |
| 3290 dest_scan[0] = FX_GAMMA(src_r); | |
| 3291 dest_scan[3] = 255; | |
| 3292 dest_scan += 4; | |
| 3293 continue; | |
| 3294 } | |
| 3295 int src_alpha = clip_scan[col]; | |
| 3296 if (src_alpha == 0) { | |
| 3297 dest_scan += 4; | |
| 3298 continue; | |
| 3299 } | |
| 3300 int back_alpha = dest_scan[3]; | |
| 3301 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 3302 dest_scan[3] = dest_alpha; | |
| 3303 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 3304 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], FX_GAMMA(src_b), alpha_ra
tio); | |
| 3305 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], FX_GAMMA(src_g), alpha_ra
tio); | |
| 3306 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], FX_GAMMA(src_r), alpha_ra
tio); | |
| 3307 dest_scan += 4; | |
| 3308 } | |
| 3309 } | |
| 3310 void _CompositeRow_ByteMask2Argb_RgbByteOrder(FX_LPBYTE dest_scan, FX_LPCBYTE sr
c_scan, int mask_alpha, int src_r, int src_g, int src_b, int pixel_count, | |
| 3311 int blend_type, FX_LPCBYTE clip_scan) | |
| 3312 { | |
| 3313 for (int col = 0; col < pixel_count; col ++) { | |
| 3314 int src_alpha; | |
| 3315 if (clip_scan) { | |
| 3316 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; | |
| 3317 } else { | |
| 3318 src_alpha = mask_alpha * src_scan[col] / 255; | |
| 3319 } | |
| 3320 FX_BYTE back_alpha = dest_scan[3]; | |
| 3321 if (back_alpha == 0) { | |
| 3322 FXARGB_SETRGBORDERDIB(dest_scan, FXARGB_MAKE(src_alpha, src_r, src_g
, src_b)); | |
| 3323 dest_scan += 4; | |
| 3324 continue; | |
| 3325 } | |
| 3326 if (src_alpha == 0) { | |
| 3327 dest_scan += 4; | |
| 3328 continue; | |
| 3329 } | |
| 3330 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 3331 dest_scan[3] = dest_alpha; | |
| 3332 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 3333 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { | |
| 3334 int blended_colors[3]; | |
| 3335 FX_BYTE src_scan[3]; | |
| 3336 FX_BYTE dest_scan_o[3]; | |
| 3337 src_scan[0] = src_b; | |
| 3338 src_scan[1] = src_g; | |
| 3339 src_scan[2] = src_r; | |
| 3340 dest_scan_o[0] = dest_scan[2]; | |
| 3341 dest_scan_o[1] = dest_scan[1]; | |
| 3342 dest_scan_o[2] = dest_scan[0]; | |
| 3343 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); | |
| 3344 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], al
pha_ratio); | |
| 3345 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], al
pha_ratio); | |
| 3346 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], al
pha_ratio); | |
| 3347 } else if (blend_type) { | |
| 3348 int blended = _BLEND(blend_type, dest_scan[2], src_b); | |
| 3349 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); | |
| 3350 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended, alpha_ratio)
; | |
| 3351 blended = _BLEND(blend_type, dest_scan[1], src_g); | |
| 3352 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); | |
| 3353 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], blended, alpha_ratio)
; | |
| 3354 blended = _BLEND(blend_type, dest_scan[0], src_r); | |
| 3355 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); | |
| 3356 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended, alpha_ratio)
; | |
| 3357 } else { | |
| 3358 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], src_b, alpha_ratio); | |
| 3359 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], src_g, alpha_ratio); | |
| 3360 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], src_r, alpha_ratio); | |
| 3361 } | |
| 3362 dest_scan += 4; | |
| 3363 } | |
| 3364 } | |
| 3365 void _CompositeRow_ByteMask2Rgb_RgbByteOrder(FX_LPBYTE dest_scan, FX_LPCBYTE src
_scan, int mask_alpha, int src_r, int src_g, int src_b, int pixel_count, | |
| 3366 int blend_type, int Bpp, FX_LPCBYTE clip_scan) | |
| 3367 { | |
| 3368 for (int col = 0; col < pixel_count; col ++) { | |
| 3369 int src_alpha; | |
| 3370 if (clip_scan) { | |
| 3371 src_alpha = mask_alpha * clip_scan[col] * src_scan[col] / 255 / 255; | |
| 3372 } else { | |
| 3373 src_alpha = mask_alpha * src_scan[col] / 255; | |
| 3374 } | |
| 3375 if (src_alpha == 0) { | |
| 3376 dest_scan += Bpp; | |
| 3377 continue; | |
| 3378 } | |
| 3379 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { | |
| 3380 int blended_colors[3]; | |
| 3381 FX_BYTE src_scan[3]; | |
| 3382 FX_BYTE dest_scan_o[3]; | |
| 3383 src_scan[0] = src_b; | |
| 3384 src_scan[1] = src_g; | |
| 3385 src_scan[2] = src_r; | |
| 3386 dest_scan_o[0] = dest_scan[2]; | |
| 3387 dest_scan_o[1] = dest_scan[1]; | |
| 3388 dest_scan_o[2] = dest_scan[0]; | |
| 3389 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); | |
| 3390 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], sr
c_alpha); | |
| 3391 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], sr
c_alpha); | |
| 3392 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], sr
c_alpha); | |
| 3393 } else if (blend_type) { | |
| 3394 int blended = _BLEND(blend_type, dest_scan[2], src_b); | |
| 3395 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended, src_alpha); | |
| 3396 blended = _BLEND(blend_type, dest_scan[1], src_g); | |
| 3397 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], blended, src_alpha); | |
| 3398 blended = _BLEND(blend_type, dest_scan[0], src_r); | |
| 3399 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended, src_alpha); | |
| 3400 } else { | |
| 3401 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], src_b, src_alpha); | |
| 3402 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], src_g, src_alpha); | |
| 3403 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], src_r, src_alpha); | |
| 3404 } | |
| 3405 dest_scan += Bpp; | |
| 3406 } | |
| 3407 } | |
| 3408 void _CompositeRow_BitMask2Argb_RgbByteOrder(FX_LPBYTE dest_scan, FX_LPCBYTE src
_scan, int mask_alpha, int src_r, int src_g, int src_b, | |
| 3409 int src_left, int pixel_count, int blend_type, FX_LPCBYTE clip_scan) | |
| 3410 { | |
| 3411 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && mask_alpha == 2
55) { | |
| 3412 FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b); | |
| 3413 for (int col = 0; col < pixel_count; col ++) { | |
| 3414 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8
))) { | |
| 3415 FXARGB_SETRGBORDERDIB(dest_scan, argb); | |
| 3416 } | |
| 3417 dest_scan += 4; | |
| 3418 } | |
| 3419 return; | |
| 3420 } | |
| 3421 for (int col = 0; col < pixel_count; col ++) { | |
| 3422 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))
)) { | |
| 3423 dest_scan += 4; | |
| 3424 continue; | |
| 3425 } | |
| 3426 int src_alpha; | |
| 3427 if (clip_scan) { | |
| 3428 src_alpha = mask_alpha * clip_scan[col] / 255; | |
| 3429 } else { | |
| 3430 src_alpha = mask_alpha; | |
| 3431 } | |
| 3432 FX_BYTE back_alpha = dest_scan[3]; | |
| 3433 if (back_alpha == 0) { | |
| 3434 FXARGB_SETRGBORDERDIB(dest_scan, FXARGB_MAKE(src_alpha, src_r, src_g
, src_b)); | |
| 3435 dest_scan += 4; | |
| 3436 continue; | |
| 3437 } | |
| 3438 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 2
55; | |
| 3439 dest_scan[3] = dest_alpha; | |
| 3440 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 3441 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { | |
| 3442 int blended_colors[3]; | |
| 3443 FX_BYTE src_scan[3]; | |
| 3444 FX_BYTE dest_scan_o[3]; | |
| 3445 src_scan[0] = src_b; | |
| 3446 src_scan[1] = src_g; | |
| 3447 src_scan[2] = src_r; | |
| 3448 dest_scan_o[0] = dest_scan[2]; | |
| 3449 dest_scan_o[1] = dest_scan[1]; | |
| 3450 dest_scan_o[2] = dest_scan[0]; | |
| 3451 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); | |
| 3452 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], al
pha_ratio); | |
| 3453 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], al
pha_ratio); | |
| 3454 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], al
pha_ratio); | |
| 3455 } else if (blend_type) { | |
| 3456 int blended = _BLEND(blend_type, dest_scan[2], src_b); | |
| 3457 blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); | |
| 3458 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended, alpha_ratio)
; | |
| 3459 blended = _BLEND(blend_type, dest_scan[1], src_g); | |
| 3460 blended = FXDIB_ALPHA_MERGE(src_g, blended, back_alpha); | |
| 3461 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], blended, alpha_ratio)
; | |
| 3462 blended = _BLEND(blend_type, dest_scan[0], src_r); | |
| 3463 blended = FXDIB_ALPHA_MERGE(src_r, blended, back_alpha); | |
| 3464 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended, alpha_ratio)
; | |
| 3465 } else { | |
| 3466 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], src_b, alpha_ratio); | |
| 3467 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], src_g, alpha_ratio); | |
| 3468 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], src_r, alpha_ratio); | |
| 3469 } | |
| 3470 dest_scan += 4; | |
| 3471 } | |
| 3472 } | |
| 3473 void _CompositeRow_BitMask2Rgb_RgbByteOrder(FX_LPBYTE dest_scan, FX_LPCBYTE src_
scan, int mask_alpha, int src_r, int src_g, int src_b, | |
| 3474 int src_left, int pixel_count, int blend_type, int Bpp, FX_LPCBYTE clip_
scan) | |
| 3475 { | |
| 3476 if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL && mask_alpha == 2
55) { | |
| 3477 for (int col = 0; col < pixel_count; col ++) { | |
| 3478 if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8
))) { | |
| 3479 dest_scan[2] = src_b; | |
| 3480 dest_scan[1] = src_g; | |
| 3481 dest_scan[0] = src_r; | |
| 3482 } | |
| 3483 dest_scan += Bpp; | |
| 3484 } | |
| 3485 return; | |
| 3486 } | |
| 3487 for (int col = 0; col < pixel_count; col ++) { | |
| 3488 if (!(src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))
)) { | |
| 3489 dest_scan += Bpp; | |
| 3490 continue; | |
| 3491 } | |
| 3492 int src_alpha; | |
| 3493 if (clip_scan) { | |
| 3494 src_alpha = mask_alpha * clip_scan[col] / 255; | |
| 3495 } else { | |
| 3496 src_alpha = mask_alpha; | |
| 3497 } | |
| 3498 if (src_alpha == 0) { | |
| 3499 dest_scan += Bpp; | |
| 3500 continue; | |
| 3501 } | |
| 3502 if (blend_type >= FXDIB_BLEND_NONSEPARABLE) { | |
| 3503 int blended_colors[3]; | |
| 3504 FX_BYTE src_scan[3]; | |
| 3505 FX_BYTE dest_scan_o[3]; | |
| 3506 src_scan[0] = src_b; | |
| 3507 src_scan[1] = src_g; | |
| 3508 src_scan[2] = src_r; | |
| 3509 dest_scan_o[0] = dest_scan[2]; | |
| 3510 dest_scan_o[1] = dest_scan[1]; | |
| 3511 dest_scan_o[2] = dest_scan[0]; | |
| 3512 _RGB_Blend(blend_type, src_scan, dest_scan_o, blended_colors); | |
| 3513 dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended_colors[0], sr
c_alpha); | |
| 3514 dest_scan[1] = FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], sr
c_alpha); | |
| 3515 dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], sr
c_alpha); | |
| 3516 } else if (blend_type) { | |
| 3517 int back_color = FX_GAMMA(dest_scan[2]); | |
| 3518 int blended = _BLEND(blend_type, back_color, src_b); | |
| 3519 dest_scan[2] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(back_color, blende
d, src_alpha)); | |
| 3520 back_color = FX_GAMMA(dest_scan[1]); | |
| 3521 blended = _BLEND(blend_type, back_color, src_g); | |
| 3522 dest_scan[1] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(back_color, blende
d, src_alpha)); | |
| 3523 back_color = FX_GAMMA(dest_scan[0]); | |
| 3524 blended = _BLEND(blend_type, back_color, src_r); | |
| 3525 dest_scan[0] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(back_color, blende
d, src_alpha)); | |
| 3526 } else { | |
| 3527 dest_scan[2] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan
[2]), src_b, src_alpha)); | |
| 3528 dest_scan[1] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan
[1]), src_g, src_alpha)); | |
| 3529 dest_scan[0] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan
[0]), src_r, src_alpha)); | |
| 3530 } | |
| 3531 dest_scan += Bpp; | |
| 3532 } | |
| 3533 } | |
| 3534 inline FX_BOOL _ScanlineCompositor_InitSourceMask(FXDIB_Format dest_format, int
alpha_flag, FX_DWORD mask_color, int& mask_alpha, | |
| 3535 int& mask_red, int& mask_green, int& mask_blue, int& mask_black, | |
| 3536 void* icc_module, void* pIccTransform) | |
| 3537 { | |
| 3538 ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module; | |
| 3539 if (alpha_flag >> 8) { | |
| 3540 mask_alpha = alpha_flag & 0xff; | |
| 3541 mask_red = FXSYS_GetCValue(mask_color); | |
| 3542 mask_green = FXSYS_GetMValue(mask_color); | |
| 3543 mask_blue = FXSYS_GetYValue(mask_color); | |
| 3544 mask_black = FXSYS_GetKValue(mask_color); | |
| 3545 } else { | |
| 3546 mask_alpha = FXARGB_A(mask_color); | |
| 3547 mask_red = FXARGB_R(mask_color); | |
| 3548 mask_green = FXARGB_G(mask_color); | |
| 3549 mask_blue = FXARGB_B(mask_color); | |
| 3550 } | |
| 3551 if (dest_format == FXDIB_8bppMask) { | |
| 3552 return TRUE; | |
| 3553 } | |
| 3554 if ((dest_format & 0xff) == 8) { | |
| 3555 if (pIccTransform) { | |
| 3556 mask_color = (alpha_flag >> 8) ? FXCMYK_TODIB(mask_color) : FXARGB_T
ODIB(mask_color); | |
| 3557 FX_LPBYTE gray_p = (FX_LPBYTE)&mask_color; | |
| 3558 pIccModule->TranslateScanline(pIccTransform, gray_p, gray_p, 1); | |
| 3559 mask_red = dest_format & 0x0400 ? FX_CCOLOR(gray_p[0]) : gray_p[0]; | |
| 3560 } else { | |
| 3561 if (alpha_flag >> 8) { | |
| 3562 FX_BYTE r, g, b; | |
| 3563 AdobeCMYK_to_sRGB1(mask_red, mask_green, mask_blue, mask_black, | |
| 3564 r, g, b); | |
| 3565 mask_red = FXRGB2GRAY(r, g, b); | |
| 3566 } else { | |
| 3567 mask_red = FXRGB2GRAY(mask_red, mask_green, mask_blue); | |
| 3568 } | |
| 3569 if (dest_format & 0x0400) { | |
| 3570 mask_red = FX_CCOLOR(mask_red); | |
| 3571 } | |
| 3572 } | |
| 3573 } else { | |
| 3574 FX_LPBYTE mask_color_p = (FX_LPBYTE)&mask_color; | |
| 3575 mask_color = (alpha_flag >> 8) ? FXCMYK_TODIB(mask_color) : FXARGB_TODIB
(mask_color); | |
| 3576 if (pIccTransform) { | |
| 3577 pIccModule->TranslateScanline(pIccTransform, mask_color_p, mask_colo
r_p, 1); | |
| 3578 mask_red = mask_color_p[2]; | |
| 3579 mask_green = mask_color_p[1]; | |
| 3580 mask_blue = mask_color_p[0]; | |
| 3581 } else if (alpha_flag >> 8) { | |
| 3582 AdobeCMYK_to_sRGB1(mask_color_p[0], mask_color_p[1], mask_color_p[2]
, mask_color_p[3], | |
| 3583 mask_color_p[2], mask_color_p[1], mask_color_p[0]
); | |
| 3584 mask_red = mask_color_p[2]; | |
| 3585 mask_green = mask_color_p[1]; | |
| 3586 mask_blue = mask_color_p[0]; | |
| 3587 } | |
| 3588 } | |
| 3589 return TRUE; | |
| 3590 } | |
| 3591 inline void _ScanlineCompositor_InitSourcePalette(FXDIB_Format src_format, FXDIB
_Format dest_format, | |
| 3592 FX_DWORD*& pDestPalette, FX_DWORD* pSrcPalette, | |
| 3593 void* icc_module, void* pIccTransform) | |
| 3594 { | |
| 3595 ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module; | |
| 3596 FX_BOOL isSrcCmyk = src_format & 0x0400 ? TRUE : FALSE; | |
| 3597 FX_BOOL isDstCmyk = dest_format & 0x0400 ? TRUE : FALSE; | |
| 3598 pDestPalette = NULL; | |
| 3599 if (pIccTransform) { | |
| 3600 if (pSrcPalette) { | |
| 3601 if ((dest_format & 0xff) == 8) { | |
| 3602 int pal_count = 1 << (src_format & 0xff); | |
| 3603 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count); | |
| 3604 if (!gray_pal) { | |
| 3605 return; | |
| 3606 } | |
| 3607 pDestPalette = (FX_DWORD*)gray_pal; | |
| 3608 for (int i = 0; i < pal_count; i ++) { | |
| 3609 FX_DWORD color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) :
FXARGB_TODIB(pSrcPalette[i]); | |
| 3610 pIccModule->TranslateScanline(pIccTransform, gray_pal, (FX_L
PCBYTE)&color, 1); | |
| 3611 gray_pal ++; | |
| 3612 } | |
| 3613 } else { | |
| 3614 int palsize = 1 << (src_format & 0xff); | |
| 3615 pDestPalette = FX_Alloc(FX_DWORD, palsize); | |
| 3616 if (!pDestPalette) { | |
| 3617 return; | |
| 3618 } | |
| 3619 for (int i = 0; i < palsize; i ++) { | |
| 3620 FX_DWORD color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) :
FXARGB_TODIB(pSrcPalette[i]); | |
| 3621 pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)&col
or, (FX_LPCBYTE)&color, 1); | |
| 3622 pDestPalette[i] = isDstCmyk ? FXCMYK_TODIB(color) : FXARGB_T
ODIB(color); | |
| 3623 } | |
| 3624 } | |
| 3625 } else { | |
| 3626 int pal_count = 1 << (src_format & 0xff); | |
| 3627 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count); | |
| 3628 if (!gray_pal) { | |
| 3629 return; | |
| 3630 } | |
| 3631 if (pal_count == 2) { | |
| 3632 gray_pal[0] = 0; | |
| 3633 gray_pal[1] = 255; | |
| 3634 } else { | |
| 3635 for (int i = 0; i < pal_count; i++) { | |
| 3636 gray_pal[i] = i; | |
| 3637 } | |
| 3638 } | |
| 3639 if ((dest_format & 0xff) == 8) { | |
| 3640 pIccModule->TranslateScanline(pIccTransform, gray_pal, gray_pal,
pal_count); | |
| 3641 pDestPalette = (FX_DWORD*)gray_pal; | |
| 3642 } else { | |
| 3643 pDestPalette = FX_Alloc(FX_DWORD, pal_count); | |
| 3644 if (!pDestPalette) { | |
| 3645 FX_Free(gray_pal); | |
| 3646 return; | |
| 3647 } | |
| 3648 for (int i = 0; i < pal_count; i ++) { | |
| 3649 pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)&pDe
stPalette[i], &gray_pal[i], 1); | |
| 3650 pDestPalette[i] = isDstCmyk ? FXCMYK_TODIB(pDestPalette[i])
: FXARGB_TODIB(pDestPalette[i]); | |
| 3651 } | |
| 3652 FX_Free(gray_pal); | |
| 3653 } | |
| 3654 } | |
| 3655 } else { | |
| 3656 if (pSrcPalette) { | |
| 3657 if ((dest_format & 0xff) == 8) { | |
| 3658 int pal_count = 1 << (src_format & 0xff); | |
| 3659 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count); | |
| 3660 if (!gray_pal) { | |
| 3661 return; | |
| 3662 } | |
| 3663 pDestPalette = (FX_DWORD*)gray_pal; | |
| 3664 if (isSrcCmyk) { | |
| 3665 for (int i = 0; i < pal_count; i ++) { | |
| 3666 FX_CMYK cmyk = pSrcPalette[i]; | |
| 3667 FX_BYTE r, g, b; | |
| 3668 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValu
e(cmyk), FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), | |
| 3669 r, g, b); | |
| 3670 *gray_pal ++ = FXRGB2GRAY(r, g, b); | |
| 3671 } | |
| 3672 } else | |
| 3673 for (int i = 0; i < pal_count; i ++) { | |
| 3674 FX_ARGB argb = pSrcPalette[i]; | |
| 3675 *gray_pal ++ = FXRGB2GRAY(FXARGB_R(argb), FXARGB_G(argb)
, FXARGB_B(argb)); | |
| 3676 } | |
| 3677 } else { | |
| 3678 int palsize = 1 << (src_format & 0xff); | |
| 3679 pDestPalette = FX_Alloc(FX_DWORD, palsize); | |
| 3680 if (!pDestPalette) { | |
| 3681 return; | |
| 3682 } | |
| 3683 if (isDstCmyk == isSrcCmyk) { | |
| 3684 FXSYS_memcpy32(pDestPalette, pSrcPalette, palsize * sizeof(F
X_DWORD)); | |
| 3685 } else { | |
| 3686 for (int i = 0; i < palsize; i ++) { | |
| 3687 FX_CMYK cmyk = pSrcPalette[i]; | |
| 3688 FX_BYTE r, g, b; | |
| 3689 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValu
e(cmyk), FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), | |
| 3690 r, g, b); | |
| 3691 pDestPalette[i] = FXARGB_MAKE(0xff, r, g, b); | |
| 3692 } | |
| 3693 } | |
| 3694 } | |
| 3695 } else { | |
| 3696 if ((dest_format & 0xff) == 8) { | |
| 3697 int pal_count = 1 << (src_format & 0xff); | |
| 3698 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count); | |
| 3699 if (!gray_pal) { | |
| 3700 return; | |
| 3701 } | |
| 3702 if (pal_count == 2) { | |
| 3703 gray_pal[0] = 0; | |
| 3704 gray_pal[1] = 255; | |
| 3705 } else { | |
| 3706 for (int i = 0; i < pal_count; i++) { | |
| 3707 gray_pal[i] = i; | |
| 3708 } | |
| 3709 } | |
| 3710 pDestPalette = (FX_DWORD*)gray_pal; | |
| 3711 } else { | |
| 3712 int palsize = 1 << (src_format & 0xff); | |
| 3713 pDestPalette = FX_Alloc(FX_DWORD, palsize); | |
| 3714 if (!pDestPalette) { | |
| 3715 return; | |
| 3716 } | |
| 3717 if (palsize == 2) { | |
| 3718 pDestPalette[0] = isSrcCmyk ? 255 : 0xff000000; | |
| 3719 pDestPalette[1] = isSrcCmyk ? 0 : 0xffffffff; | |
| 3720 } else { | |
| 3721 for (int i = 0; i < palsize; i++) { | |
| 3722 pDestPalette[i] = isSrcCmyk ? FX_CCOLOR(i) : (i * 0x1010
1); | |
| 3723 } | |
| 3724 } | |
| 3725 if (isSrcCmyk != isDstCmyk) { | |
| 3726 for (int i = 0; i < palsize; i ++) { | |
| 3727 FX_CMYK cmyk = pDestPalette[i]; | |
| 3728 FX_BYTE r, g, b; | |
| 3729 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValu
e(cmyk), FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), | |
| 3730 r, g, b); | |
| 3731 pDestPalette[i] = FXARGB_MAKE(0xff, r, g, b); | |
| 3732 } | |
| 3733 } | |
| 3734 } | |
| 3735 } | |
| 3736 } | |
| 3737 } | |
| 3738 CFX_ScanlineCompositor::CFX_ScanlineCompositor() | |
| 3739 { | |
| 3740 m_pSrcPalette = NULL; | |
| 3741 m_pCacheScanline = NULL; | |
| 3742 m_CacheSize = 0; | |
| 3743 m_bRgbByteOrder = FALSE; | |
| 3744 m_BlendType = FXDIB_BLEND_NORMAL; | |
| 3745 } | |
| 3746 CFX_ScanlineCompositor::~CFX_ScanlineCompositor() | |
| 3747 { | |
| 3748 if (m_pSrcPalette) { | |
| 3749 FX_Free(m_pSrcPalette); | |
| 3750 } | |
| 3751 if (m_pCacheScanline) { | |
| 3752 FX_Free(m_pCacheScanline); | |
| 3753 } | |
| 3754 } | |
| 3755 FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format, FXDIB_Format src_
format, FX_INT32 width, FX_DWORD* pSrcPalette, | |
| 3756 FX_DWORD mask_color, int blend_type, FX_BOO
L bClip, FX_BOOL bRgbByteOrder, int alpha_flag, void* pIccTransform) | |
| 3757 { | |
| 3758 m_SrcFormat = src_format; | |
| 3759 m_DestFormat = dest_format; | |
| 3760 m_BlendType = blend_type; | |
| 3761 m_bRgbByteOrder = bRgbByteOrder; | |
| 3762 ICodec_IccModule* pIccModule = NULL; | |
| 3763 if (CFX_GEModule::Get()->GetCodecModule()) { | |
| 3764 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | |
| 3765 } | |
| 3766 if (pIccModule == NULL) { | |
| 3767 pIccTransform = NULL; | |
| 3768 } | |
| 3769 m_pIccTransform = pIccTransform; | |
| 3770 if ((dest_format & 0xff) == 1) { | |
| 3771 return FALSE; | 5467 return FALSE; |
| 3772 } | 5468 } |
| 3773 if (m_SrcFormat == FXDIB_1bppMask || m_SrcFormat == FXDIB_8bppMask) { | 5469 } |
| 3774 return _ScanlineCompositor_InitSourceMask(dest_format, alpha_flag, mask_
color, | 5470 } |
| 3775 m_MaskAlpha, m_MaskRed, m_MaskGreen, m_MaskBlue, m_MaskBlack, | 5471 if (m_BitmapAlpha < 255) { |
| 3776 pIccModule, pIccTransform); | 5472 m_pAddClipScan = FX_Alloc( |
| 3777 } | 5473 FX_BYTE, m_bVertical ? m_pBitmap->GetHeight() : m_pBitmap->GetWidth()); |
| 3778 if (pIccTransform == NULL && (~src_format & 0x0400) && (dest_format & 0x0400
)) { | 5474 if (!m_pAddClipScan) { |
| 3779 return FALSE; | 5475 return FALSE; |
| 3780 } | 5476 } |
| 3781 if ((m_SrcFormat & 0xff) <= 8) { | 5477 } |
| 3782 if (dest_format == FXDIB_8bppMask) { | 5478 return TRUE; |
| 3783 return TRUE; | 5479 } |
| 3784 } | 5480 void CFX_BitmapComposer::DoCompose(FX_LPBYTE dest_scan, |
| 3785 _ScanlineCompositor_InitSourcePalette(src_format, dest_format, m_pSrcPal
ette, pSrcPalette, | 5481 FX_LPCBYTE src_scan, |
| 3786 pIccModule, pIccTransform); | 5482 int dest_width, |
| 3787 m_Transparency = (dest_format == FXDIB_Argb ? 1 : 0) | 5483 FX_LPCBYTE clip_scan, |
| 3788 + (dest_format & 0x0200 ? 2 : 0) | 5484 FX_LPCBYTE src_extra_alpha, |
| 3789 + (dest_format & 0x0400 ? 4 : 0) | 5485 FX_LPBYTE dst_extra_alpha) { |
| 3790 + ((src_format & 0xff) == 1 ? 8 : 0); | 5486 if (m_BitmapAlpha < 255) { |
| 3791 return TRUE; | 5487 if (clip_scan) { |
| 3792 } | 5488 for (int i = 0; i < dest_width; i++) { |
| 3793 m_Transparency = (src_format & 0x0200 ? 0 : 1) | 5489 m_pAddClipScan[i] = clip_scan[i] * m_BitmapAlpha / 255; |
| 3794 + (dest_format & 0x0200 ? 0 : 2) | 5490 } |
| 3795 + (blend_type == FXDIB_BLEND_NORMAL ? 4 : 0) | 5491 } else { |
| 3796 + (bClip ? 8 : 0) | 5492 FXSYS_memset8(m_pAddClipScan, m_BitmapAlpha, dest_width); |
| 3797 + (src_format & 0x0400 ? 16 : 0) | 5493 } |
| 3798 + (dest_format & 0x0400 ? 32 : 0) | 5494 clip_scan = m_pAddClipScan; |
| 3799 + (pIccTransform ? 64 : 0); | 5495 } |
| 3800 return TRUE; | 5496 if (m_SrcFormat == FXDIB_8bppMask) { |
| 3801 } | 5497 m_Compositor.CompositeByteMaskLine( |
| 3802 void CFX_ScanlineCompositor::CompositeRgbBitmapLine(FX_LPBYTE dest_scan, FX_LPCB
YTE src_scan, int width, FX_LPCBYTE clip_scan, | 5498 dest_scan, src_scan, dest_width, clip_scan, dst_extra_alpha); |
| 3803 FX_LPCBYTE src_extra_alpha, FX_LPBYTE dst_extra_alpha) | 5499 } else if ((m_SrcFormat & 0xff) == 8) { |
| 3804 { | 5500 m_Compositor.CompositePalBitmapLine(dest_scan, |
| 3805 int src_Bpp = (m_SrcFormat & 0xff) >> 3; | 5501 src_scan, |
| 3806 int dest_Bpp = (m_DestFormat & 0xff) >> 3; | 5502 0, |
| 3807 if (m_bRgbByteOrder) { | 5503 dest_width, |
| 3808 switch (m_Transparency) { | 5504 clip_scan, |
| 3809 case 0: | 5505 src_extra_alpha, |
| 3810 case 4: | |
| 3811 case 8: | |
| 3812 case 12: | |
| 3813 _CompositeRow_Argb2Argb_RgbByteOrder(dest_scan, src_scan, width,
m_BlendType, clip_scan); | |
| 3814 break; | |
| 3815 case 1: | |
| 3816 _CompositeRow_Rgb2Argb_Blend_NoClip_RgbByteOrder(dest_scan, src_
scan, width, m_BlendType, src_Bpp); | |
| 3817 break; | |
| 3818 case 2: | |
| 3819 case 10: | |
| 3820 _CompositeRow_Argb2Rgb_Blend_RgbByteOrder(dest_scan, src_scan, w
idth, m_BlendType, dest_Bpp, clip_scan); | |
| 3821 break; | |
| 3822 case 3: | |
| 3823 _CompositeRow_Rgb2Rgb_Blend_NoClip_RgbByteOrder(dest_scan, src_s
can, width, m_BlendType, dest_Bpp, src_Bpp); | |
| 3824 break; | |
| 3825 case 5: | |
| 3826 _CompositeRow_Rgb2Argb_NoBlend_NoClip_RgbByteOrder(dest_scan, sr
c_scan, width, src_Bpp); | |
| 3827 break; | |
| 3828 case 6: | |
| 3829 case 14: | |
| 3830 _CompositeRow_Argb2Rgb_NoBlend_RgbByteOrder(dest_scan, src_scan,
width, dest_Bpp, clip_scan); | |
| 3831 break; | |
| 3832 case 7: | |
| 3833 _CompositeRow_Rgb2Rgb_NoBlend_NoClip_RgbByteOrder(dest_scan, src
_scan, width, dest_Bpp, src_Bpp); | |
| 3834 break; | |
| 3835 case 9: | |
| 3836 _CompositeRow_Rgb2Argb_Blend_Clip_RgbByteOrder(dest_scan, src_sc
an, width, m_BlendType, src_Bpp, clip_scan); | |
| 3837 break; | |
| 3838 case 11: | |
| 3839 _CompositeRow_Rgb2Rgb_Blend_Clip_RgbByteOrder(dest_scan, src_sca
n, width, m_BlendType, dest_Bpp, src_Bpp, clip_scan); | |
| 3840 break; | |
| 3841 case 13: | |
| 3842 _CompositeRow_Rgb2Argb_NoBlend_Clip_RgbByteOrder(dest_scan, src_
scan, width, src_Bpp, clip_scan); | |
| 3843 break; | |
| 3844 case 15: | |
| 3845 _CompositeRow_Rgb2Rgb_NoBlend_Clip_RgbByteOrder(dest_scan, src_s
can, width, dest_Bpp, src_Bpp, clip_scan); | |
| 3846 break; | |
| 3847 } | |
| 3848 return; | |
| 3849 } | |
| 3850 if (m_DestFormat == FXDIB_8bppMask) { | |
| 3851 if (m_SrcFormat & 0x0200) { | |
| 3852 if (m_SrcFormat == FXDIB_Argb) { | |
| 3853 _CompositeRow_Argb2Mask(dest_scan, src_scan, width, clip_scan); | |
| 3854 } else { | |
| 3855 _CompositeRow_Rgba2Mask(dest_scan, src_extra_alpha, width, clip_
scan); | |
| 3856 } | |
| 3857 } else { | |
| 3858 _CompositeRow_Rgb2Mask(dest_scan, src_scan, width, clip_scan); | |
| 3859 } | |
| 3860 } else if ((m_DestFormat & 0xff) == 8) { | |
| 3861 if (m_DestFormat & 0x0400) { | |
| 3862 for (int i = 0; i < width; i ++) { | |
| 3863 *dest_scan = ~*dest_scan; | |
| 3864 dest_scan++; | |
| 3865 } | |
| 3866 } | |
| 3867 if (m_SrcFormat & 0x0200) { | |
| 3868 if (m_DestFormat & 0x0200) { | |
| 3869 _CompositeRow_Argb2Graya(dest_scan, src_scan, width, m_BlendType
, clip_scan, src_extra_alpha, dst_extra_alpha, m_pIccTransform); | |
| 3870 } else { | |
| 3871 _CompositeRow_Argb2Gray(dest_scan, src_scan, width, m_BlendType,
clip_scan, src_extra_alpha, m_pIccTransform); | |
| 3872 } | |
| 3873 } else { | |
| 3874 if (m_DestFormat & 0x0200) { | |
| 3875 _CompositeRow_Rgb2Graya(dest_scan, src_scan, src_Bpp, width, m_B
lendType, clip_scan, dst_extra_alpha, m_pIccTransform); | |
| 3876 } else { | |
| 3877 _CompositeRow_Rgb2Gray(dest_scan, src_scan, src_Bpp, width, m_Bl
endType, clip_scan, m_pIccTransform); | |
| 3878 } | |
| 3879 } | |
| 3880 if (m_DestFormat & 0x0400) { | |
| 3881 for (int i = 0; i < width; i ++) { | |
| 3882 *dest_scan = ~*dest_scan; | |
| 3883 dest_scan++; | |
| 3884 } | |
| 3885 } | |
| 3886 } else { | |
| 3887 int dest_Size = width * dest_Bpp + 4; | |
| 3888 if (dest_Size > m_CacheSize) { | |
| 3889 m_pCacheScanline = FX_Realloc(FX_BYTE, m_pCacheScanline, dest_Size); | |
| 3890 if (!m_pCacheScanline) { | |
| 3891 return; | |
| 3892 } | |
| 3893 m_CacheSize = dest_Size; | |
| 3894 } | |
| 3895 switch (m_Transparency) { | |
| 3896 case 0: | |
| 3897 case 4: | |
| 3898 case 8: | |
| 3899 case 4+8: { | |
| 3900 _CompositeRow_Argb2Argb(dest_scan, src_scan, width, m_BlendT
ype, clip_scan, | |
| 3901 dst_extra_alpha, src_extra_alpha); | |
| 3902 } | |
| 3903 break; | |
| 3904 case 64: | |
| 3905 case 4+64: | |
| 3906 case 8+64: | |
| 3907 case 4+8+64: { | |
| 3908 _CompositeRow_Argb2Argb_Transform(dest_scan, src_scan, width
, m_BlendType, clip_scan, | |
| 3909 dst_extra_alpha, src_extra
_alpha, m_pCacheScanline, m_pIccTransform); | |
| 3910 } | |
| 3911 break; | |
| 3912 case 1: | |
| 3913 _CompositeRow_Rgb2Argb_Blend_NoClip(dest_scan, src_scan, width,
m_BlendType, src_Bpp, | |
| 3914 dst_extra_alpha); | |
| 3915 break; | |
| 3916 case 1+64: | |
| 3917 _CompositeRow_Rgb2Argb_Blend_NoClip_Transform(dest_scan, src_sca
n, width, m_BlendType, src_Bpp, | |
| 3918 dst_extra_alpha, m_pCacheScanline, m_pIccTransform); | |
| 3919 break; | |
| 3920 case 1+8: | |
| 3921 _CompositeRow_Rgb2Argb_Blend_Clip(dest_scan, src_scan, width, m_
BlendType, src_Bpp, clip_scan, | |
| 3922 dst_extra_alpha); | |
| 3923 break; | |
| 3924 case 1+8+64: | |
| 3925 _CompositeRow_Rgb2Argb_Blend_Clip_Transform(dest_scan, src_scan,
width, m_BlendType, src_Bpp, clip_scan, | |
| 3926 dst_extra_alpha, m_pCacheScanline, m_pIccTransform); | |
| 3927 break; | |
| 3928 case 1+4: | |
| 3929 _CompositeRow_Rgb2Argb_NoBlend_NoClip(dest_scan, src_scan, width
, src_Bpp, | |
| 3930 dst_extra_alpha); | |
| 3931 break; | |
| 3932 case 1+4+64: | |
| 3933 _CompositeRow_Rgb2Argb_NoBlend_NoClip_Transform(dest_scan, src_s
can, width, src_Bpp, | |
| 3934 dst_extra_alpha, m_pCacheScanline, m_pIccTransform); | |
| 3935 break; | |
| 3936 case 1+4+8: | |
| 3937 _CompositeRow_Rgb2Argb_NoBlend_Clip(dest_scan, src_scan, width,
src_Bpp, clip_scan, | |
| 3938 dst_extra_alpha); | |
| 3939 break; | |
| 3940 case 1+4+8+64: | |
| 3941 _CompositeRow_Rgb2Argb_NoBlend_Clip_Transform(dest_scan, src_sca
n, width, src_Bpp, clip_scan, | |
| 3942 dst_extra_alpha, m_pCacheScanline, m_pIccTransform); | |
| 3943 break; | |
| 3944 case 2: | |
| 3945 case 2+8: | |
| 3946 _CompositeRow_Argb2Rgb_Blend(dest_scan, src_scan, width, m_Blend
Type, dest_Bpp, clip_scan, | |
| 3947 src_extra_alpha); | |
| 3948 break; | |
| 3949 case 2+64: | |
| 3950 case 2+8+64: | |
| 3951 _CompositeRow_Argb2Rgb_Blend_Transform(dest_scan, src_scan, widt
h, m_BlendType, dest_Bpp, clip_scan, | |
| 3952 src_extra_alpha, m_pCache
Scanline, m_pIccTransform); | |
| 3953 break; | |
| 3954 case 2+4: | |
| 3955 case 2+4+8: | |
| 3956 _CompositeRow_Argb2Rgb_NoBlend(dest_scan, src_scan, width, dest_
Bpp, clip_scan, | |
| 3957 src_extra_alpha); | |
| 3958 break; | |
| 3959 case 2+4+64: | |
| 3960 case 2+4+8+64: | |
| 3961 _CompositeRow_Argb2Rgb_NoBlend_Transform(dest_scan, src_scan, wi
dth, dest_Bpp, clip_scan, | |
| 3962 src_extra_alpha, m_pCacheScanline, m_pIccTransform); | |
| 3963 break; | |
| 3964 case 1+2: | |
| 3965 _CompositeRow_Rgb2Rgb_Blend_NoClip(dest_scan, src_scan, width, m
_BlendType, dest_Bpp, src_Bpp); | |
| 3966 break; | |
| 3967 case 1+2+64: | |
| 3968 _CompositeRow_Rgb2Rgb_Blend_NoClip_Transform(dest_scan, src_scan
, width, m_BlendType, dest_Bpp, src_Bpp, | |
| 3969 m_pCacheScanline, m_pIccTransform); | |
| 3970 break; | |
| 3971 case 1+2+8: | |
| 3972 _CompositeRow_Rgb2Rgb_Blend_Clip(dest_scan, src_scan, width, m_B
lendType, dest_Bpp, src_Bpp, clip_scan); | |
| 3973 break; | |
| 3974 case 1+2+8+64: | |
| 3975 _CompositeRow_Rgb2Rgb_Blend_Clip_Transform(dest_scan, src_scan,
width, m_BlendType, dest_Bpp, src_Bpp, clip_scan, | |
| 3976 m_pCacheScanline, m_pIccTransform); | |
| 3977 break; | |
| 3978 case 1+2+4: | |
| 3979 _CompositeRow_Rgb2Rgb_NoBlend_NoClip(dest_scan, src_scan, width,
dest_Bpp, src_Bpp); | |
| 3980 break; | |
| 3981 case 1+2+4+64: | |
| 3982 _CompositeRow_Rgb2Rgb_NoBlend_NoClip_Transform(dest_scan, src_sc
an, width, dest_Bpp, src_Bpp, | |
| 3983 m_pCacheScanline, m_pIccTransform); | |
| 3984 break; | |
| 3985 case 1+2+4+8: | |
| 3986 _CompositeRow_Rgb2Rgb_NoBlend_Clip(dest_scan, src_scan, width, d
est_Bpp, src_Bpp, clip_scan); | |
| 3987 break; | |
| 3988 case 1+2+4+8+64: | |
| 3989 _CompositeRow_Rgb2Rgb_NoBlend_Clip_Transform(dest_scan, src_scan
, width, dest_Bpp, src_Bpp, clip_scan, | |
| 3990 m_pCacheScanline, m_pIccTransform); | |
| 3991 break; | |
| 3992 } | |
| 3993 } | |
| 3994 } | |
| 3995 void CFX_ScanlineCompositor::CompositePalBitmapLine(FX_LPBYTE dest_scan, FX_LPCB
YTE src_scan, int src_left, int width, FX_LPCBYTE clip_scan, | |
| 3996 FX_LPCBYTE src_extra_alpha, FX_LPBYTE dst_extra_alpha) | |
| 3997 { | |
| 3998 if (m_bRgbByteOrder) { | |
| 3999 if (m_SrcFormat == FXDIB_1bppRgb) { | |
| 4000 if (m_DestFormat == FXDIB_8bppRgb) { | |
| 4001 return; | |
| 4002 } else if(m_DestFormat == FXDIB_Argb) { | |
| 4003 _CompositeRow_1bppRgb2Argb_NoBlend_RgbByteOrder(dest_scan, src_s
can, src_left, width, m_pSrcPalette, clip_scan); | |
| 4004 } else { | |
| 4005 _CompositeRow_1bppRgb2Rgb_NoBlend_RgbByteOrder(dest_scan, src_sc
an, src_left, m_pSrcPalette, width, (m_DestFormat & 0xff) >> 3, clip_scan); | |
| 4006 } | |
| 4007 } else { | |
| 4008 if (m_DestFormat == FXDIB_8bppRgb) { | |
| 4009 return; | |
| 4010 } else if (m_DestFormat == FXDIB_Argb) { | |
| 4011 _CompositeRow_8bppRgb2Argb_NoBlend_RgbByteOrder(dest_scan, src_s
can, width, m_pSrcPalette, clip_scan); | |
| 4012 } else { | |
| 4013 _CompositeRow_8bppRgb2Rgb_NoBlend_RgbByteOrder(dest_scan, src_sc
an, m_pSrcPalette, width, (m_DestFormat & 0xff) >> 3, clip_scan); | |
| 4014 } | |
| 4015 } | |
| 4016 return; | |
| 4017 } | |
| 4018 if (m_DestFormat == FXDIB_8bppMask) { | |
| 4019 _CompositeRow_Rgb2Mask(dest_scan, src_scan, width, clip_scan); | |
| 4020 return; | |
| 4021 } else if ((m_DestFormat & 0xff) == 8) { | |
| 4022 if (m_Transparency & 8) { | |
| 4023 if (m_DestFormat & 0x0200) { | |
| 4024 _CompositeRow_1bppPal2Graya(dest_scan, src_scan, src_left, (FX_L
PCBYTE)m_pSrcPalette, width, m_BlendType, clip_scan, dst_extra_alpha); | |
| 4025 } else { | |
| 4026 _CompositeRow_1bppPal2Gray(dest_scan, src_scan, src_left, (FX_LP
CBYTE)m_pSrcPalette, width, m_BlendType, clip_scan); | |
| 4027 } | |
| 4028 } else { | |
| 4029 if (m_DestFormat & 0x0200) | |
| 4030 _CompositeRow_8bppPal2Graya(dest_scan, src_scan, (FX_LPCBYTE)m_p
SrcPalette, width, m_BlendType, clip_scan, | |
| 4031 dst_extra_alpha, src_extra_alpha); | |
| 4032 else | |
| 4033 _CompositeRow_8bppPal2Gray(dest_scan, src_scan, (FX_LPCBYTE)m_pS
rcPalette, width, m_BlendType, clip_scan, | |
| 4034 src_extra_alpha); | |
| 4035 } | |
| 4036 } else { | |
| 4037 switch (m_Transparency) { | |
| 4038 case 1+2: | |
| 4039 _CompositeRow_8bppRgb2Argb_NoBlend(dest_scan, src_scan, width, m
_pSrcPalette, clip_scan, | |
| 4040 src_extra_alpha); | |
| 4041 break; | |
| 4042 case 1+2+8: | |
| 4043 _CompositeRow_1bppRgb2Argb_NoBlend(dest_scan, src_scan, src_left
, width, m_pSrcPalette, clip_scan); | |
| 4044 break; | |
| 4045 case 0: | |
| 4046 _CompositeRow_8bppRgb2Rgb_NoBlend(dest_scan, src_scan, m_pSrcPal
ette, width, (m_DestFormat & 0xff) >> 3, clip_scan, | |
| 4047 src_extra_alpha); | |
| 4048 break; | |
| 4049 case 0+8: | |
| 4050 _CompositeRow_1bppRgb2Rgb_NoBlend(dest_scan, src_scan, src_left,
m_pSrcPalette, width, (m_DestFormat & 0xff) >> 3, clip_scan); | |
| 4051 break; | |
| 4052 case 0+2: | |
| 4053 _CompositeRow_8bppRgb2Rgb_NoBlend(dest_scan, src_scan, m_pSrcPal
ette, width, (m_DestFormat & 0xff) >> 3, clip_scan, | |
| 4054 src_extra_alpha); | |
| 4055 break; | |
| 4056 case 0+2+8: | |
| 4057 _CompositeRow_1bppRgb2Rgba_NoBlend(dest_scan, src_scan, src_left
, width, m_pSrcPalette, clip_scan, | |
| 4058 dst_extra_alpha); | |
| 4059 break; | |
| 4060 break; | |
| 4061 } | |
| 4062 } | |
| 4063 } | |
| 4064 void CFX_ScanlineCompositor::CompositeByteMaskLine(FX_LPBYTE dest_scan, FX_LPCBY
TE src_scan, int width, FX_LPCBYTE clip_scan, | |
| 4065 FX_LPBYTE dst_extra_alpha) | |
| 4066 { | |
| 4067 if (m_DestFormat == FXDIB_8bppMask) { | |
| 4068 _CompositeRow_ByteMask2Mask(dest_scan, src_scan, m_MaskAlpha, width, cli
p_scan); | |
| 4069 } else if ((m_DestFormat & 0xff) == 8) { | |
| 4070 if (m_DestFormat & 0x0200) { | |
| 4071 _CompositeRow_ByteMask2Graya(dest_scan, src_scan, m_MaskAlpha, m_Mas
kRed, width, clip_scan, dst_extra_alpha); | |
| 4072 } else { | |
| 4073 _CompositeRow_ByteMask2Gray(dest_scan, src_scan, m_MaskAlpha, m_Mask
Red, width, clip_scan); | |
| 4074 } | |
| 4075 } else if (m_bRgbByteOrder) { | |
| 4076 if (m_DestFormat == FXDIB_Argb) | |
| 4077 _CompositeRow_ByteMask2Argb_RgbByteOrder(dest_scan, src_scan, m_Mask
Alpha, m_MaskRed, m_MaskGreen, m_MaskBlue, | |
| 4078 width, m_BlendType, clip_scan); | |
| 4079 else | |
| 4080 _CompositeRow_ByteMask2Rgb_RgbByteOrder(dest_scan, src_scan, m_MaskA
lpha, m_MaskRed, m_MaskGreen, m_MaskBlue, | |
| 4081 width, m_BlendType, (m_DestF
ormat & 0xff) >> 3, clip_scan); | |
| 4082 return; | |
| 4083 } else if (m_DestFormat == FXDIB_Argb) | |
| 4084 _CompositeRow_ByteMask2Argb(dest_scan, src_scan, m_MaskAlpha, m_MaskRed,
m_MaskGreen, m_MaskBlue, | |
| 4085 width, m_BlendType, clip_scan); | |
| 4086 else if (m_DestFormat == FXDIB_Rgb || m_DestFormat == FXDIB_Rgb32) | |
| 4087 _CompositeRow_ByteMask2Rgb(dest_scan, src_scan, m_MaskAlpha, m_MaskRed,
m_MaskGreen, m_MaskBlue, | |
| 4088 width, m_BlendType, (m_DestFormat & 0xff) >>
3, clip_scan); | |
| 4089 else if (m_DestFormat == FXDIB_Rgba) | |
| 4090 _CompositeRow_ByteMask2Rgba(dest_scan, src_scan, m_MaskAlpha, m_MaskRed,
m_MaskGreen, m_MaskBlue, | |
| 4091 width, m_BlendType, clip_scan, dst_extra_alp
ha); | |
| 4092 } | |
| 4093 void CFX_ScanlineCompositor::CompositeBitMaskLine(FX_LPBYTE dest_scan, FX_LPCBYT
E src_scan, int src_left, int width, FX_LPCBYTE clip_scan, | |
| 4094 FX_LPBYTE dst_extra_alpha) | |
| 4095 { | |
| 4096 if (m_DestFormat == FXDIB_8bppMask) { | |
| 4097 _CompositeRow_BitMask2Mask(dest_scan, src_scan, m_MaskAlpha, src_left, w
idth, clip_scan); | |
| 4098 } else if ((m_DestFormat & 0xff) == 8) { | |
| 4099 if (m_DestFormat & 0x0200) | |
| 4100 _CompositeRow_BitMask2Graya(dest_scan, src_scan, m_MaskAlpha, m_Mask
Red, src_left, width, clip_scan, | |
| 4101 dst_extra_alpha); | 5506 dst_extra_alpha); |
| 4102 else { | 5507 } else { |
| 4103 _CompositeRow_BitMask2Gray(dest_scan, src_scan, m_MaskAlpha, m_MaskR
ed, src_left, width, clip_scan); | 5508 m_Compositor.CompositeRgbBitmapLine(dest_scan, |
| 4104 } | 5509 src_scan, |
| 4105 } else if (m_bRgbByteOrder) { | 5510 dest_width, |
| 4106 if (m_DestFormat == FXDIB_Argb) | 5511 clip_scan, |
| 4107 _CompositeRow_BitMask2Argb_RgbByteOrder(dest_scan, src_scan, m_MaskA
lpha, m_MaskRed, m_MaskGreen, m_MaskBlue, | 5512 src_extra_alpha, |
| 4108 src_left, width, m_BlendType
, clip_scan); | 5513 dst_extra_alpha); |
| 4109 else | 5514 } |
| 4110 _CompositeRow_BitMask2Rgb_RgbByteOrder(dest_scan, src_scan, m_MaskAl
pha, m_MaskRed, m_MaskGreen, m_MaskBlue, | 5515 } |
| 4111 src_left, width, m_BlendType,
(m_DestFormat & 0xff) >> 3, clip_scan); | 5516 void CFX_BitmapComposer::ComposeScanline(int line, |
| 4112 return; | 5517 FX_LPCBYTE scanline, |
| 4113 } else if (m_DestFormat == FXDIB_Argb) | 5518 FX_LPCBYTE scan_extra_alpha) { |
| 4114 _CompositeRow_BitMask2Argb(dest_scan, src_scan, m_MaskAlpha, m_MaskRed,
m_MaskGreen, m_MaskBlue, | 5519 if (m_bVertical) { |
| 4115 src_left, width, m_BlendType, clip_scan); | 5520 ComposeScanlineV(line, scanline, scan_extra_alpha); |
| 4116 else if (m_DestFormat == FXDIB_Rgb || m_DestFormat == FXDIB_Rgb32) | 5521 return; |
| 4117 _CompositeRow_BitMask2Rgb(dest_scan, src_scan, m_MaskAlpha, m_MaskRed, m
_MaskGreen, m_MaskBlue, | 5522 } |
| 4118 src_left, width, m_BlendType, (m_DestFormat &
0xff) >> 3, clip_scan); | 5523 FX_LPCBYTE clip_scan = NULL; |
| 4119 } | 5524 if (m_pClipMask) |
| 4120 FX_BOOL CFX_DIBitmap::CompositeBitmap(int dest_left, int dest_top, int width, in
t height, | 5525 clip_scan = m_pClipMask->GetBuffer() + |
| 4121 const CFX_DIBSource* pSrcBitmap, int src_l
eft, int src_top, | 5526 (m_DestTop + line - m_pClipRgn->GetBox().top) * |
| 4122 int blend_type, const CFX_ClipRgn* pClipRg
n, FX_BOOL bRgbByteOrder, void* pIccTransform) | 5527 m_pClipMask->GetPitch() + |
| 4123 { | 5528 (m_DestLeft - m_pClipRgn->GetBox().left); |
| 4124 if (m_pBuffer == NULL) { | 5529 FX_LPBYTE dest_scan = (FX_LPBYTE)m_pBitmap->GetScanline(line + m_DestTop) + |
| 4125 return FALSE; | 5530 m_DestLeft * m_pBitmap->GetBPP() / 8; |
| 4126 } | 5531 FX_LPBYTE dest_alpha_scan = |
| 4127 ASSERT(!pSrcBitmap->IsAlphaMask()); | 5532 m_pBitmap->m_pAlphaMask |
| 4128 ASSERT(m_bpp >= 8); | 5533 ? (FX_LPBYTE)m_pBitmap->m_pAlphaMask->GetScanline(line + m_DestTop) + |
| 4129 if (pSrcBitmap->IsAlphaMask() || m_bpp < 8) { | 5534 m_DestLeft |
| 4130 return FALSE; | 5535 : NULL; |
| 4131 } | 5536 DoCompose(dest_scan, |
| 4132 GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(), p
SrcBitmap->GetHeight(), | 5537 scanline, |
| 4133 src_left, src_top, pClipRgn); | 5538 m_DestWidth, |
| 4134 if (width == 0 || height == 0) { | 5539 clip_scan, |
| 4135 return TRUE; | 5540 scan_extra_alpha, |
| 4136 } | 5541 dest_alpha_scan); |
| 4137 const CFX_DIBitmap* pClipMask = NULL; | 5542 } |
| 4138 FX_RECT clip_box; | 5543 void CFX_BitmapComposer::ComposeScanlineV(int line, |
| 4139 if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { | 5544 FX_LPCBYTE scanline, |
| 4140 ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF); | 5545 FX_LPCBYTE scan_extra_alpha) { |
| 4141 pClipMask = pClipRgn->GetMask(); | 5546 int i; |
| 4142 clip_box = pClipRgn->GetBox(); | 5547 int Bpp = m_pBitmap->GetBPP() / 8; |
| 4143 } | 5548 int dest_pitch = m_pBitmap->GetPitch(); |
| 4144 CFX_ScanlineCompositor compositor; | 5549 int dest_alpha_pitch = |
| 4145 if (!compositor.Init(GetFormat(), pSrcBitmap->GetFormat(), width, pSrcBitmap
->GetPalette(), 0, blend_type, | 5550 m_pBitmap->m_pAlphaMask ? m_pBitmap->m_pAlphaMask->GetPitch() : 0; |
| 4146 pClipMask != NULL, bRgbByteOrder, 0, pIccTransform)) { | 5551 int dest_x = m_DestLeft + (m_bFlipX ? (m_DestWidth - line - 1) : line); |
| 4147 return FALSE; | 5552 FX_LPBYTE dest_buf = |
| 4148 } | 5553 m_pBitmap->GetBuffer() + dest_x * Bpp + m_DestTop * dest_pitch; |
| 4149 int dest_Bpp = m_bpp / 8; | 5554 FX_LPBYTE dest_alpha_buf = m_pBitmap->m_pAlphaMask |
| 4150 int src_Bpp = pSrcBitmap->GetBPP() / 8; | 5555 ? m_pBitmap->m_pAlphaMask->GetBuffer() + |
| 4151 FX_BOOL bRgb = FALSE; | 5556 dest_x + m_DestTop * dest_alpha_pitch |
| 4152 FX_BOOL bCmyk = FALSE; | 5557 : NULL; |
| 4153 if (src_Bpp > 1) { | 5558 if (m_bFlipY) { |
| 4154 if (pSrcBitmap->IsCmykImage()) { | 5559 dest_buf += dest_pitch * (m_DestHeight - 1); |
| 4155 bCmyk = TRUE; | 5560 dest_alpha_buf += dest_alpha_pitch * (m_DestHeight - 1); |
| 4156 } else { | 5561 } |
| 4157 bRgb = TRUE; | 5562 int y_step = dest_pitch; |
| 4158 } | 5563 int y_alpha_step = dest_alpha_pitch; |
| 4159 } | 5564 if (m_bFlipY) { |
| 4160 CFX_DIBitmap* pSrcAlphaMask = pSrcBitmap->m_pAlphaMask; | 5565 y_step = -y_step; |
| 4161 for (int row = 0; row < height; row ++) { | 5566 y_alpha_step = -y_alpha_step; |
| 4162 FX_LPBYTE dest_scan = m_pBuffer + (dest_top + row) * m_Pitch + dest_left
* dest_Bpp; | 5567 } |
| 4163 FX_LPCBYTE src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left
* src_Bpp; | 5568 FX_LPBYTE src_scan = m_pScanlineV; |
| 4164 FX_LPCBYTE src_scan_extra_alpha = pSrcAlphaMask ? pSrcAlphaMask->GetScan
line(src_top + row) + src_left : NULL; | 5569 FX_LPBYTE dest_scan = dest_buf; |
| 4165 FX_LPBYTE dst_scan_extra_alpha = m_pAlphaMask ? (FX_LPBYTE)m_pAlphaMask-
>GetScanline(dest_top + row) + dest_left : NULL; | 5570 for (i = 0; i < m_DestHeight; i++) { |
| 4166 FX_LPCBYTE clip_scan = NULL; | 5571 for (int j = 0; j < Bpp; j++) { |
| 4167 if (pClipMask) { | 5572 *src_scan++ = dest_scan[j]; |
| 4168 clip_scan = pClipMask->m_pBuffer + (dest_top + row - clip_box.top) *
pClipMask->m_Pitch + (dest_left - clip_box.left); | 5573 } |
| 4169 } | 5574 dest_scan += y_step; |
| 4170 if (bRgb) { | 5575 } |
| 4171 compositor.CompositeRgbBitmapLine(dest_scan, src_scan, width, clip_s
can, src_scan_extra_alpha, dst_scan_extra_alpha); | 5576 FX_LPBYTE src_alpha_scan = m_pScanlineAlphaV; |
| 4172 } else { | 5577 FX_LPBYTE dest_alpha_scan = dest_alpha_buf; |
| 4173 compositor.CompositePalBitmapLine(dest_scan, src_scan, src_left, wid
th, clip_scan, src_scan_extra_alpha, dst_scan_extra_alpha); | 5578 if (dest_alpha_scan) { |
| 4174 } | 5579 for (i = 0; i < m_DestHeight; i++) { |
| 4175 } | 5580 *src_alpha_scan++ = *dest_alpha_scan; |
| 4176 return TRUE; | 5581 dest_alpha_scan += y_alpha_step; |
| 4177 } | 5582 } |
| 4178 FX_BOOL CFX_DIBitmap::CompositeMask(int dest_left, int dest_top, int width, int
height, | 5583 } |
| 4179 const CFX_DIBSource* pMask, FX_DWORD color,
int src_left, int src_top, | 5584 FX_LPBYTE clip_scan = NULL; |
| 4180 int blend_type, const CFX_ClipRgn* pClipRgn,
FX_BOOL bRgbByteOrder, int alpha_flag, void* pIccTransform) | 5585 if (m_pClipMask) { |
| 4181 { | 5586 clip_scan = m_pClipScanV; |
| 4182 if (m_pBuffer == NULL) { | 5587 int clip_pitch = m_pClipMask->GetPitch(); |
| 4183 return FALSE; | 5588 FX_LPCBYTE src_clip = m_pClipMask->GetBuffer() + |
| 4184 } | 5589 (m_DestTop - m_pClipRgn->GetBox().top) * clip_pitch + |
| 4185 ASSERT(pMask->IsAlphaMask()); | 5590 (dest_x - m_pClipRgn->GetBox().left); |
| 4186 ASSERT(m_bpp >= 8); | |
| 4187 if (!pMask->IsAlphaMask() || m_bpp < 8) { | |
| 4188 return FALSE; | |
| 4189 } | |
| 4190 GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(), pMask-
>GetHeight(), src_left, src_top, pClipRgn); | |
| 4191 if (width == 0 || height == 0) { | |
| 4192 return TRUE; | |
| 4193 } | |
| 4194 int src_alpha = (FX_BYTE)(alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(
color); | |
| 4195 if (src_alpha == 0) { | |
| 4196 return TRUE; | |
| 4197 } | |
| 4198 const CFX_DIBitmap* pClipMask = NULL; | |
| 4199 FX_RECT clip_box; | |
| 4200 if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { | |
| 4201 ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF); | |
| 4202 pClipMask = pClipRgn->GetMask(); | |
| 4203 clip_box = pClipRgn->GetBox(); | |
| 4204 } | |
| 4205 int src_bpp = pMask->GetBPP(); | |
| 4206 int Bpp = GetBPP() / 8; | |
| 4207 CFX_ScanlineCompositor compositor; | |
| 4208 if (!compositor.Init(GetFormat(), pMask->GetFormat(), width, NULL, color, bl
end_type, pClipMask != NULL, bRgbByteOrder, alpha_flag, pIccTransform)) { | |
| 4209 return FALSE; | |
| 4210 } | |
| 4211 for (int row = 0; row < height; row ++) { | |
| 4212 FX_LPBYTE dest_scan = m_pBuffer + (dest_top + row) * m_Pitch + dest_left
* Bpp; | |
| 4213 FX_LPCBYTE src_scan = pMask->GetScanline(src_top + row); | |
| 4214 FX_LPBYTE dst_scan_extra_alpha = m_pAlphaMask ? (FX_LPBYTE)m_pAlphaMask-
>GetScanline(dest_top + row) + dest_left : NULL; | |
| 4215 FX_LPCBYTE clip_scan = NULL; | |
| 4216 if (pClipMask) { | |
| 4217 clip_scan = pClipMask->m_pBuffer + (dest_top + row - clip_box.top) *
pClipMask->m_Pitch + (dest_left - clip_box.left); | |
| 4218 } | |
| 4219 if (src_bpp == 1) { | |
| 4220 compositor.CompositeBitMaskLine(dest_scan, src_scan, src_left, width
, clip_scan, dst_scan_extra_alpha); | |
| 4221 } else { | |
| 4222 compositor.CompositeByteMaskLine(dest_scan, src_scan + src_left, wid
th, clip_scan, dst_scan_extra_alpha); | |
| 4223 } | |
| 4224 } | |
| 4225 return TRUE; | |
| 4226 } | |
| 4227 FX_BOOL CFX_DIBitmap::CompositeRect(int left, int top, int width, int height, FX
_DWORD color, int alpha_flag, void* pIccTransform) | |
| 4228 { | |
| 4229 if (m_pBuffer == NULL) { | |
| 4230 return FALSE; | |
| 4231 } | |
| 4232 int src_alpha = (alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color); | |
| 4233 if (src_alpha == 0) { | |
| 4234 return TRUE; | |
| 4235 } | |
| 4236 FX_RECT rect(left, top, left + width, top + height); | |
| 4237 rect.Intersect(0, 0, m_Width, m_Height); | |
| 4238 if (rect.IsEmpty()) { | |
| 4239 return TRUE; | |
| 4240 } | |
| 4241 width = rect.Width(); | |
| 4242 FX_DWORD dst_color; | |
| 4243 if (alpha_flag >> 8) { | |
| 4244 dst_color = FXCMYK_TODIB(color); | |
| 4245 } else { | |
| 4246 dst_color = FXARGB_TODIB(color); | |
| 4247 } | |
| 4248 FX_LPBYTE color_p = (FX_LPBYTE)&dst_color; | |
| 4249 if (m_bpp == 8) { | |
| 4250 FX_BYTE gray = 255; | |
| 4251 if (!IsAlphaMask()) { | |
| 4252 if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && CFX_GE
Module::Get()->GetCodecModule()->GetIccModule()) { | |
| 4253 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModu
le()->GetIccModule(); | |
| 4254 pIccModule->TranslateScanline(pIccTransform, &gray, color_p, 1); | |
| 4255 } else { | |
| 4256 if (alpha_flag >> 8) { | |
| 4257 FX_BYTE r, g, b; | |
| 4258 AdobeCMYK_to_sRGB1(color_p[0], color_p[1], color_p[2], color
_p[3], | |
| 4259 r, g, b); | |
| 4260 gray = FXRGB2GRAY(r, g, b); | |
| 4261 } else { | |
| 4262 gray = (FX_BYTE)FXRGB2GRAY((int)color_p[2], color_p[1], colo
r_p[0]); | |
| 4263 } | |
| 4264 } | |
| 4265 if (IsCmykImage()) { | |
| 4266 gray = ~gray; | |
| 4267 } | |
| 4268 } | |
| 4269 for (int row = rect.top; row < rect.bottom; row ++) { | |
| 4270 FX_LPBYTE dest_scan = m_pBuffer + row * m_Pitch + rect.left; | |
| 4271 if (src_alpha == 255) { | |
| 4272 FXSYS_memset8(dest_scan, gray, width); | |
| 4273 } else | |
| 4274 for (int col = 0; col < width; col ++) { | |
| 4275 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | |
| 4276 dest_scan ++; | |
| 4277 } | |
| 4278 } | |
| 4279 return TRUE; | |
| 4280 } else if (m_bpp == 1) { | |
| 4281 ASSERT(!IsCmykImage() && (FX_BYTE)(alpha_flag >> 8) == 0); | |
| 4282 int left_shift = rect.left % 8; | |
| 4283 int right_shift = rect.right % 8; | |
| 4284 int width = rect.right / 8 - rect.left / 8; | |
| 4285 int index = 0; | |
| 4286 if (m_pPalette == NULL) { | |
| 4287 index = ((FX_BYTE)color == 0xff) ? 1 : 0; | |
| 4288 } else { | |
| 4289 for (int i = 0; i < 2; i ++) | |
| 4290 if (m_pPalette[i] == color) { | |
| 4291 index = i; | |
| 4292 } | |
| 4293 } | |
| 4294 for (int row = rect.top; row < rect.bottom; row ++) { | |
| 4295 FX_BYTE* dest_scan_top = (FX_BYTE*)GetScanline(row) + rect.left / 8; | |
| 4296 FX_BYTE* dest_scan_top_r = (FX_BYTE*)GetScanline(row) + rect.right /
8; | |
| 4297 FX_BYTE left_flag = *dest_scan_top & (255 << (8 - left_shift)); | |
| 4298 FX_BYTE right_flag = *dest_scan_top_r & (255 >> right_shift); | |
| 4299 if (width) { | |
| 4300 FXSYS_memset8(dest_scan_top + 1, index ? 255 : 0, width - 1); | |
| 4301 if (!index) { | |
| 4302 *dest_scan_top &= left_flag; | |
| 4303 *dest_scan_top_r &= right_flag; | |
| 4304 } else { | |
| 4305 *dest_scan_top |= ~left_flag; | |
| 4306 *dest_scan_top_r |= ~right_flag; | |
| 4307 } | |
| 4308 } else { | |
| 4309 if (!index) { | |
| 4310 *dest_scan_top &= left_flag | right_flag; | |
| 4311 } else { | |
| 4312 *dest_scan_top |= ~(left_flag | right_flag); | |
| 4313 } | |
| 4314 } | |
| 4315 } | |
| 4316 return TRUE; | |
| 4317 } | |
| 4318 ASSERT(m_bpp >= 24); | |
| 4319 if (m_bpp < 24) { | |
| 4320 return FALSE; | |
| 4321 } | |
| 4322 if (pIccTransform && CFX_GEModule::Get()->GetCodecModule()) { | |
| 4323 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); | |
| 4324 pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1); | |
| 4325 } else { | |
| 4326 if (alpha_flag >> 8 && !IsCmykImage()) | |
| 4327 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), F
XSYS_GetYValue(color), FXSYS_GetKValue(color), | |
| 4328 color_p[2], color_p[1], color_p[0]); | |
| 4329 else if (!(alpha_flag >> 8) && IsCmykImage()) { | |
| 4330 return FALSE; | |
| 4331 } | |
| 4332 } | |
| 4333 if(!IsCmykImage()) { | |
| 4334 color_p[3] = (FX_BYTE)src_alpha; | |
| 4335 } | |
| 4336 int Bpp = m_bpp / 8; | |
| 4337 FX_BOOL bAlpha = HasAlpha(); | |
| 4338 FX_BOOL bArgb = GetFormat() == FXDIB_Argb ? TRUE : FALSE; | |
| 4339 if (src_alpha == 255) { | |
| 4340 for (int row = rect.top; row < rect.bottom; row ++) { | |
| 4341 FX_LPBYTE dest_scan = m_pBuffer + row * m_Pitch + rect.left * Bpp; | |
| 4342 FX_LPBYTE dest_scan_alpha = m_pAlphaMask ? (FX_LPBYTE)m_pAlphaMask->
GetScanline(row) + rect.left : NULL; | |
| 4343 if (dest_scan_alpha) { | |
| 4344 FXSYS_memset8(dest_scan_alpha, 0xff, width); | |
| 4345 } | |
| 4346 if (Bpp == 4) { | |
| 4347 FX_DWORD* scan = (FX_DWORD*)dest_scan; | |
| 4348 for (int col = 0; col < width; col ++) { | |
| 4349 *scan ++ = dst_color; | |
| 4350 } | |
| 4351 } else { | |
| 4352 for (int col = 0; col < width; col ++) { | |
| 4353 *dest_scan ++ = color_p[0]; | |
| 4354 *dest_scan ++ = color_p[1]; | |
| 4355 *dest_scan ++ = color_p[2]; | |
| 4356 } | |
| 4357 } | |
| 4358 } | |
| 4359 return TRUE; | |
| 4360 } | |
| 4361 for (int row = rect.top; row < rect.bottom; row ++) { | |
| 4362 FX_LPBYTE dest_scan = m_pBuffer + row * m_Pitch + rect.left * Bpp; | |
| 4363 if (bAlpha) { | |
| 4364 if (bArgb) { | |
| 4365 for (int col = 0; col < width; col ++) { | |
| 4366 FX_BYTE back_alpha = dest_scan[3]; | |
| 4367 if (back_alpha == 0) { | |
| 4368 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_alpha, color_p[
2], color_p[1], color_p[0])); | |
| 4369 dest_scan += 4; | |
| 4370 continue; | |
| 4371 } | |
| 4372 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * s
rc_alpha / 255; | |
| 4373 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 4374 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, color_p[0], alpha
_ratio); | |
| 4375 dest_scan ++; | |
| 4376 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, color_p[1], alpha
_ratio); | |
| 4377 dest_scan ++; | |
| 4378 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, color_p[2], alpha
_ratio); | |
| 4379 dest_scan ++; | |
| 4380 *dest_scan++ = dest_alpha; | |
| 4381 } | |
| 4382 } else { | |
| 4383 FX_LPBYTE dest_scan_alpha = (FX_LPBYTE)m_pAlphaMask->GetScanline
(row) + rect.left; | |
| 4384 for (int col = 0; col < width; col ++) { | |
| 4385 FX_BYTE back_alpha = *dest_scan_alpha; | |
| 4386 if (back_alpha == 0) { | |
| 4387 *dest_scan_alpha++ = src_alpha; | |
| 4388 FXSYS_memcpy32(dest_scan, color_p, Bpp); | |
| 4389 dest_scan += Bpp; | |
| 4390 continue; | |
| 4391 } | |
| 4392 FX_BYTE dest_alpha = back_alpha + src_alpha - back_alpha * s
rc_alpha / 255; | |
| 4393 *dest_scan_alpha ++ = dest_alpha; | |
| 4394 int alpha_ratio = src_alpha * 255 / dest_alpha; | |
| 4395 for(int comps = 0; comps < Bpp; comps ++) { | |
| 4396 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, color_p[comps
], alpha_ratio); | |
| 4397 dest_scan ++; | |
| 4398 } | |
| 4399 } | |
| 4400 } | |
| 4401 } else { | |
| 4402 for (int col = 0; col < width; col ++) { | |
| 4403 for(int comps = 0; comps < Bpp; comps ++) { | |
| 4404 if (comps == 3) { | |
| 4405 *dest_scan ++ = 255; | |
| 4406 continue; | |
| 4407 } | |
| 4408 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, color_p[comps], s
rc_alpha); | |
| 4409 dest_scan ++; | |
| 4410 } | |
| 4411 } | |
| 4412 } | |
| 4413 } | |
| 4414 return TRUE; | |
| 4415 } | |
| 4416 CFX_BitmapComposer::CFX_BitmapComposer() | |
| 4417 { | |
| 4418 m_pScanlineV = NULL; | |
| 4419 m_pScanlineAlphaV = NULL; | |
| 4420 m_pClipScanV = NULL; | |
| 4421 m_pAddClipScan = NULL; | |
| 4422 m_bRgbByteOrder = FALSE; | |
| 4423 m_BlendType = FXDIB_BLEND_NORMAL; | |
| 4424 } | |
| 4425 CFX_BitmapComposer::~CFX_BitmapComposer() | |
| 4426 { | |
| 4427 if (m_pScanlineV) { | |
| 4428 FX_Free(m_pScanlineV); | |
| 4429 } | |
| 4430 if (m_pScanlineAlphaV) { | |
| 4431 FX_Free(m_pScanlineAlphaV); | |
| 4432 } | |
| 4433 if (m_pClipScanV) { | |
| 4434 FX_Free(m_pClipScanV); | |
| 4435 } | |
| 4436 if (m_pAddClipScan) { | |
| 4437 FX_Free(m_pAddClipScan); | |
| 4438 } | |
| 4439 } | |
| 4440 void CFX_BitmapComposer::Compose(CFX_DIBitmap* pDest, const CFX_ClipRgn* pClipRg
n, int bitmap_alpha, | |
| 4441 FX_DWORD mask_color, FX_RECT& dest_rect, FX_BOO
L bVertical, | |
| 4442 FX_BOOL bFlipX, FX_BOOL bFlipY, FX_BOOL bRgbByt
eOrder, | |
| 4443 int alpha_flag, void* pIccTransform, int blend_
type) | |
| 4444 { | |
| 4445 m_pBitmap = pDest; | |
| 4446 m_pClipRgn = pClipRgn; | |
| 4447 m_DestLeft = dest_rect.left; | |
| 4448 m_DestTop = dest_rect.top; | |
| 4449 m_DestWidth = dest_rect.Width(); | |
| 4450 m_DestHeight = dest_rect.Height(); | |
| 4451 m_BitmapAlpha = bitmap_alpha; | |
| 4452 m_MaskColor = mask_color; | |
| 4453 m_pClipMask = NULL; | |
| 4454 if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { | |
| 4455 m_pClipMask = pClipRgn->GetMask(); | |
| 4456 } | |
| 4457 m_bVertical = bVertical; | |
| 4458 m_bFlipX = bFlipX; | |
| 4459 m_bFlipY = bFlipY; | |
| 4460 m_AlphaFlag = alpha_flag; | |
| 4461 m_pIccTransform = pIccTransform; | |
| 4462 m_bRgbByteOrder = bRgbByteOrder; | |
| 4463 m_BlendType = blend_type; | |
| 4464 } | |
| 4465 FX_BOOL CFX_BitmapComposer::SetInfo(int width, int height, FXDIB_Format src_form
at, FX_DWORD* pSrcPalette) | |
| 4466 { | |
| 4467 m_SrcFormat = src_format; | |
| 4468 if (!m_Compositor.Init(m_pBitmap->GetFormat(), src_format, width, pSrcPalett
e, m_MaskColor, FXDIB_BLEND_NORMAL, | |
| 4469 m_pClipMask != NULL || (m_BitmapAlpha < 255), m_bRgbB
yteOrder, m_AlphaFlag, m_pIccTransform)) { | |
| 4470 return FALSE; | |
| 4471 } | |
| 4472 if (m_bVertical) { | |
| 4473 m_pScanlineV = FX_Alloc(FX_BYTE, m_pBitmap->GetBPP() / 8 * width + 4); | |
| 4474 if (!m_pScanlineV) { | |
| 4475 return FALSE; | |
| 4476 } | |
| 4477 m_pClipScanV = FX_Alloc(FX_BYTE, m_pBitmap->GetHeight()); | |
| 4478 if (!m_pClipScanV) { | |
| 4479 return FALSE; | |
| 4480 } | |
| 4481 if (m_pBitmap->m_pAlphaMask) { | |
| 4482 m_pScanlineAlphaV = FX_Alloc(FX_BYTE, width + 4); | |
| 4483 if (!m_pScanlineAlphaV) { | |
| 4484 return FALSE; | |
| 4485 } | |
| 4486 } | |
| 4487 } | |
| 4488 if (m_BitmapAlpha < 255) { | |
| 4489 m_pAddClipScan = FX_Alloc(FX_BYTE, m_bVertical ? m_pBitmap->GetHeight()
: m_pBitmap->GetWidth()); | |
| 4490 if (!m_pAddClipScan) { | |
| 4491 return FALSE; | |
| 4492 } | |
| 4493 } | |
| 4494 return TRUE; | |
| 4495 } | |
| 4496 void CFX_BitmapComposer::DoCompose(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int
dest_width, FX_LPCBYTE clip_scan, | |
| 4497 FX_LPCBYTE src_extra_alpha, FX_LPBYTE dst_ext
ra_alpha) | |
| 4498 { | |
| 4499 if (m_BitmapAlpha < 255) { | |
| 4500 if (clip_scan) { | |
| 4501 for (int i = 0; i < dest_width; i ++) { | |
| 4502 m_pAddClipScan[i] = clip_scan[i] * m_BitmapAlpha / 255; | |
| 4503 } | |
| 4504 } else { | |
| 4505 FXSYS_memset8(m_pAddClipScan, m_BitmapAlpha, dest_width); | |
| 4506 } | |
| 4507 clip_scan = m_pAddClipScan; | |
| 4508 } | |
| 4509 if (m_SrcFormat == FXDIB_8bppMask) { | |
| 4510 m_Compositor.CompositeByteMaskLine(dest_scan, src_scan, dest_width, clip
_scan, dst_extra_alpha); | |
| 4511 } else if ((m_SrcFormat & 0xff) == 8) { | |
| 4512 m_Compositor.CompositePalBitmapLine(dest_scan, src_scan, 0, dest_width,
clip_scan, src_extra_alpha, dst_extra_alpha); | |
| 4513 } else { | |
| 4514 m_Compositor.CompositeRgbBitmapLine(dest_scan, src_scan, dest_width, cli
p_scan, src_extra_alpha, dst_extra_alpha); | |
| 4515 } | |
| 4516 } | |
| 4517 void CFX_BitmapComposer::ComposeScanline(int line, FX_LPCBYTE scanline, FX_LPCBY
TE scan_extra_alpha) | |
| 4518 { | |
| 4519 if (m_bVertical) { | |
| 4520 ComposeScanlineV(line, scanline, scan_extra_alpha); | |
| 4521 return; | |
| 4522 } | |
| 4523 FX_LPCBYTE clip_scan = NULL; | |
| 4524 if (m_pClipMask) | |
| 4525 clip_scan = m_pClipMask->GetBuffer() + (m_DestTop + line - m_pClipRgn->G
etBox().top) * | |
| 4526 m_pClipMask->GetPitch() + (m_DestLeft - m_pClipRgn->GetBox()
.left); | |
| 4527 FX_LPBYTE dest_scan = (FX_LPBYTE)m_pBitmap->GetScanline(line + m_DestTop) + | |
| 4528 m_DestLeft * m_pBitmap->GetBPP() / 8; | |
| 4529 FX_LPBYTE dest_alpha_scan = m_pBitmap->m_pAlphaMask ? | |
| 4530 (FX_LPBYTE)m_pBitmap->m_pAlphaMask->GetScanline(
line + m_DestTop) + m_DestLeft : NULL; | |
| 4531 DoCompose(dest_scan, scanline, m_DestWidth, clip_scan, scan_extra_alpha, des
t_alpha_scan); | |
| 4532 } | |
| 4533 void CFX_BitmapComposer::ComposeScanlineV(int line, FX_LPCBYTE scanline, FX_LPCB
YTE scan_extra_alpha) | |
| 4534 { | |
| 4535 int i; | |
| 4536 int Bpp = m_pBitmap->GetBPP() / 8; | |
| 4537 int dest_pitch = m_pBitmap->GetPitch(); | |
| 4538 int dest_alpha_pitch = m_pBitmap->m_pAlphaMask ? m_pBitmap->m_pAlphaMask->Ge
tPitch() : 0; | |
| 4539 int dest_x = m_DestLeft + (m_bFlipX ? (m_DestWidth - line - 1) : line); | |
| 4540 FX_LPBYTE dest_buf = m_pBitmap->GetBuffer() + dest_x * Bpp + m_DestTop * des
t_pitch; | |
| 4541 FX_LPBYTE dest_alpha_buf = m_pBitmap->m_pAlphaMask ? | |
| 4542 m_pBitmap->m_pAlphaMask->GetBuffer() + dest_x + m
_DestTop * dest_alpha_pitch : NULL; | |
| 4543 if (m_bFlipY) { | 5591 if (m_bFlipY) { |
| 4544 dest_buf += dest_pitch * (m_DestHeight - 1); | 5592 src_clip += clip_pitch * (m_DestHeight - 1); |
| 4545 dest_alpha_buf += dest_alpha_pitch * (m_DestHeight - 1); | 5593 clip_pitch = -clip_pitch; |
| 4546 } | 5594 } |
| 4547 int y_step = dest_pitch; | 5595 for (i = 0; i < m_DestHeight; i++) { |
| 4548 int y_alpha_step = dest_alpha_pitch; | 5596 clip_scan[i] = *src_clip; |
| 4549 if (m_bFlipY) { | 5597 src_clip += clip_pitch; |
| 4550 y_step = -y_step; | 5598 } |
| 4551 y_alpha_step = -y_alpha_step; | 5599 } |
| 4552 } | 5600 DoCompose(m_pScanlineV, |
| 4553 FX_LPBYTE src_scan = m_pScanlineV; | 5601 scanline, |
| 4554 FX_LPBYTE dest_scan = dest_buf; | 5602 m_DestHeight, |
| 4555 for (i = 0; i < m_DestHeight; i ++) { | 5603 clip_scan, |
| 4556 for (int j = 0; j < Bpp; j ++) { | 5604 scan_extra_alpha, |
| 4557 *src_scan++ = dest_scan[j]; | 5605 m_pScanlineAlphaV); |
| 4558 } | 5606 src_scan = m_pScanlineV; |
| 4559 dest_scan += y_step; | 5607 dest_scan = dest_buf; |
| 4560 } | 5608 for (i = 0; i < m_DestHeight; i++) { |
| 4561 FX_LPBYTE src_alpha_scan = m_pScanlineAlphaV; | 5609 for (int j = 0; j < Bpp; j++) { |
| 4562 FX_LPBYTE dest_alpha_scan = dest_alpha_buf; | 5610 dest_scan[j] = *src_scan++; |
| 4563 if (dest_alpha_scan) { | 5611 } |
| 4564 for (i = 0; i < m_DestHeight; i ++) { | 5612 dest_scan += y_step; |
| 4565 *src_alpha_scan++ = *dest_alpha_scan; | 5613 } |
| 4566 dest_alpha_scan += y_alpha_step; | 5614 src_alpha_scan = m_pScanlineAlphaV; |
| 4567 } | 5615 dest_alpha_scan = dest_alpha_buf; |
| 4568 } | 5616 if (dest_alpha_scan) { |
| 4569 FX_LPBYTE clip_scan = NULL; | 5617 for (i = 0; i < m_DestHeight; i++) { |
| 4570 if (m_pClipMask) { | 5618 *dest_alpha_scan = *src_alpha_scan++; |
| 4571 clip_scan = m_pClipScanV; | 5619 dest_alpha_scan += y_alpha_step; |
| 4572 int clip_pitch = m_pClipMask->GetPitch(); | 5620 } |
| 4573 FX_LPCBYTE src_clip = m_pClipMask->GetBuffer() + (m_DestTop - m_pClipRgn
->GetBox().top) * | 5621 } |
| 4574 clip_pitch + (dest_x - m_pClipRgn->GetBox().left); | 5622 } |
| 4575 if (m_bFlipY) { | |
| 4576 src_clip += clip_pitch * (m_DestHeight - 1); | |
| 4577 clip_pitch = -clip_pitch; | |
| 4578 } | |
| 4579 for (i = 0; i < m_DestHeight; i ++) { | |
| 4580 clip_scan[i] = *src_clip; | |
| 4581 src_clip += clip_pitch; | |
| 4582 } | |
| 4583 } | |
| 4584 DoCompose(m_pScanlineV, scanline, m_DestHeight, clip_scan, scan_extra_alpha,
m_pScanlineAlphaV); | |
| 4585 src_scan = m_pScanlineV; | |
| 4586 dest_scan = dest_buf; | |
| 4587 for (i = 0; i < m_DestHeight; i ++) { | |
| 4588 for (int j = 0; j < Bpp; j ++) { | |
| 4589 dest_scan[j] = *src_scan++; | |
| 4590 } | |
| 4591 dest_scan += y_step; | |
| 4592 } | |
| 4593 src_alpha_scan = m_pScanlineAlphaV; | |
| 4594 dest_alpha_scan = dest_alpha_buf; | |
| 4595 if (dest_alpha_scan) { | |
| 4596 for (i = 0; i < m_DestHeight; i ++) { | |
| 4597 *dest_alpha_scan = *src_alpha_scan++; | |
| 4598 dest_alpha_scan += y_alpha_step; | |
| 4599 } | |
| 4600 } | |
| 4601 } | |
| OLD | NEW |