276
276
const guchar *src2,
278
278
const guchar *mask,
280
280
const gboolean *affect,
289
286
const guchar *m = mask;
291
288
while (length --)
293
guchar new_alpha = INT_MULT (*m , opacity, tmp);
291
const guchar new_alpha = INT_MULT (*m , opacity, tmp);
295
294
for (b = 0; b < bytes; b++)
296
295
dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b];
341
338
while (length --)
343
guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
341
const guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
345
344
for (b = 0; b < bytes; b++)
346
345
dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b];
357
356
while (length --)
359
guchar new_alpha = INT_MULT (src2[alpha], opacity, tmp);
359
const guchar new_alpha = INT_MULT (src2[alpha], opacity, tmp);
361
362
for (b = 0; b < bytes; b++)
362
363
dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b];
390
389
while (length --)
392
guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
392
const guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
394
395
for (b = 0; b < alpha; b++)
395
396
dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b];
409
410
while (length --)
411
guchar new_alpha = INT_MULT (src2[alpha], opacity, tmp);
413
const guchar new_alpha = INT_MULT (src2[alpha], opacity, tmp);
413
416
for (b = 0; b < alpha; b++)
414
417
dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b];
445
446
while (length --)
447
gint index = src2[0] * 3;
448
guchar new_alpha = INT_MULT3 (255, *m, opacity, tmp);
449
const guint index = src2[0] * 3;
450
const guchar new_alpha = INT_MULT3 (255, *m, opacity, tmp);
450
for (b = 0; b < bytes-1; b++)
453
for (b = 0; b < bytes - 1; b++)
451
454
dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b];
453
456
dest[b] = (new_alpha > 127) ? OPAQUE_OPACITY : src1[b];
465
468
while (length --)
467
gint index = src2[0] * 3;
468
guchar new_alpha = INT_MULT (255, opacity, tmp);
471
const guint index = src2[0] * 3;
472
const guchar new_alpha = INT_MULT (255, opacity, tmp);
470
for (b = 0; b < bytes-1; b++)
475
for (b = 0; b < bytes - 1; b++)
471
476
dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b];
473
478
dest[b] = (new_alpha > 127) ? OPAQUE_OPACITY : src1[b];
474
479
/* alpha channel is opaque */
479
482
src2 += src2_bytes;
505
506
while (length --)
507
gint index = src2[0] * 3;
508
guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
509
guint index = src2[0] * 3;
510
const guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
510
for (b = 0; b < bytes-1; b++)
513
for (b = 0; b < bytes - 1; b++)
511
514
dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b];
513
516
dest[b] = (new_alpha > 127) ? OPAQUE_OPACITY : src1[b];
525
528
while (length --)
527
gint index = src2[0] * 3;
528
guchar new_alpha = INT_MULT (src2[alpha], opacity, tmp);
531
guint index = src2[0] * 3;
532
const guchar new_alpha = INT_MULT (src2[alpha], opacity, tmp);
530
for (b = 0; b < bytes-1; b++)
535
for (b = 0; b < bytes - 1; b++)
531
536
dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b];
533
538
dest[b] = (new_alpha > 127) ? OPAQUE_OPACITY : src1[b];
534
539
/* alpha channel is opaque */
539
542
src2 += src2_bytes;
548
551
const guchar *src2,
550
553
const guchar *mask,
552
555
const gboolean *affect,
561
const guchar * m = mask;
561
const guchar *m = mask;
563
563
while (length --)
565
guchar new_alpha = INT_MULT (*m, opacity, tmp);
566
const guchar new_alpha = INT_MULT (*m, opacity, tmp);
567
569
for (b = 0; b < bytes; b++)
568
570
dest[b] = (affect[b] ?
614
616
while (length --)
616
guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, t1);
619
const guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, t1);
618
622
for (b = 0; b < bytes; b++)
619
623
dest[b] = (affect[b] ?
632
636
while (length --)
634
guchar new_alpha = INT_MULT (src2[alpha],opacity,t1);
639
const guchar new_alpha = INT_MULT (src2[alpha], opacity, t1);
636
dest[0] = INT_BLEND (src2[0] , src1[0] , new_alpha, t1);
637
dest[1] = INT_BLEND (src2[1] , src1[1] , new_alpha, t1);
638
dest[2] = INT_BLEND (src2[2] , src1[2] , new_alpha, t1);
641
dest[0] = INT_BLEND (src2[0], src1[0], new_alpha, t1);
642
dest[1] = INT_BLEND (src2[1], src1[1], new_alpha, t1);
643
dest[2] = INT_BLEND (src2[2], src1[2], new_alpha, t1);
641
646
src2 += src2_bytes;
647
652
while (length --)
649
guchar new_alpha = INT_MULT (src2[alpha],opacity,t1);
655
const guchar new_alpha = INT_MULT (src2[alpha], opacity, t1);
651
658
for (b = 0; b < bytes; b++)
652
659
dest[b] = (affect[b] ?
653
INT_BLEND (src2[b] , src1[b] , new_alpha, t1) :
660
INT_BLEND (src2[b], src1[b], new_alpha, t1) :
738
745
const guchar *src2,
740
747
const guchar *mask,
742
749
const gboolean *affect,
743
gboolean mode_affect, /* how does the combination mode affect alpha? */
750
const gboolean mode_affect, /* how does the combination mode affect alpha? */
745
guint bytes) /* 4 or 2 depending on RGBA or GRAYA */
752
const guint bytes) /* 4 or 2 depending on RGBA or GRAYA */
747
const gint src2_bytes = bytes - 1;
748
const gint alpha = bytes - 1;
754
const gint src2_bytes = bytes - 1;
755
const gint alpha = bytes - 1;
788
guchar src2_alpha = INT_MULT (*m, opacity, tmp);
796
guchar src2_alpha = INT_MULT (*m, opacity, tmp);
790
798
src1[alpha] + INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
792
800
alphify (src2_alpha, new_alpha);
800
dest[alpha] = (src1[alpha]) ? src1[alpha] :
801
(affect[alpha] ? new_alpha : src1[alpha]);
808
dest[alpha] = (src1[alpha] ?
809
src1[alpha] : (affect[alpha] ?
810
new_alpha : src1[alpha]));
813
822
while (length --)
815
guchar src2_alpha = opacity;
825
guchar src2_alpha = opacity;
817
827
src1[alpha] + INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
819
829
alphify (src2_alpha, new_alpha);
822
832
dest[alpha] = (affect[alpha]) ? new_alpha : src1[alpha];
824
dest[alpha] = (src1[alpha]) ? src1[alpha] : (affect[alpha] ? new_alpha : src1[alpha]);
834
dest[alpha] = (src1[alpha] ?
835
src1[alpha] : (affect[alpha] ?
836
new_alpha : src1[alpha]));
836
848
const guchar *src2,
838
850
const guchar *mask,
840
852
const gboolean *affect,
841
gboolean mode_affect, /* how does the combination mode affect alpha? */
853
const gboolean mode_affect, /* how does the combination mode affect alpha? */
843
guint bytes) /* 4 or 2 depending on RGBA or GRAYA */
855
const guint bytes) /* 4 or 2 depending on RGBA or GRAYA */
845
857
const guint alpha = bytes - 1;
848
860
gfloat compl_ratio;
882
dest[alpha] = (affect[alpha]) ? new_alpha : src1[alpha];
894
dest[alpha] = (affect[alpha] ?
895
new_alpha : src1[alpha]);
886
dest[alpha] = (src1[alpha]) ? src1[alpha] :
887
(affect[alpha] ? new_alpha : src1[alpha]);
899
dest[alpha] = (src1[alpha] ?
900
src1[alpha] : (affect[alpha] ?
901
new_alpha : src1[alpha]));
922
dest[alpha] = (affect[alpha]) ? new_alpha : src1[alpha];
937
dest[alpha] = (affect[alpha] ?
938
new_alpha : src1[alpha]);
926
dest[alpha] = (src1[alpha]) ? src1[alpha] :
927
(affect[alpha] ? new_alpha : src1[alpha]);
942
dest[alpha] = (src1[alpha] ?
943
src1[alpha] : (affect[alpha] ?
944
new_alpha : src1[alpha]));
964
dest[alpha] = (affect[alpha]) ? new_alpha : src1[alpha];
982
dest[alpha] = affect[alpha] ? new_alpha : src1[alpha];
968
dest[alpha] = (src1[alpha]) ? src1[alpha] :
969
(affect[alpha] ? new_alpha : src1[alpha]);
986
dest[alpha] = (src1[alpha] ?
987
src1[alpha] : (affect[alpha] ?
988
new_alpha : src1[alpha]));
1004
1024
if (mode_affect)
1006
dest[alpha] = (affect[alpha]) ? new_alpha : src1[alpha];
1026
dest[alpha] = (affect[alpha] ?
1027
new_alpha : src1[alpha]);
1010
dest[alpha] = (src1[alpha]) ? src1[alpha] :
1011
(affect[alpha] ? new_alpha : src1[alpha]);
1031
dest[alpha] = (src1[alpha] ?
1032
src1[alpha] : (affect[alpha] ?
1033
new_alpha : src1[alpha]));
1037
guchar src2_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
1059
register gulong tmp;
1060
guchar src2_alpha = INT_MULT3 (src2[alpha],
1038
1062
guchar new_alpha =
1040
1064
INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
1044
1068
if (mode_affect)
1046
dest[alpha] = (affect[alpha]) ? new_alpha : src1[alpha];
1070
dest[alpha] = (affect[alpha] ?
1071
new_alpha : src1[alpha]);
1050
dest[alpha] = (src1[alpha]) ? src1[alpha] :
1051
(affect[alpha] ? new_alpha : src1[alpha]);
1075
dest[alpha] = (src1[alpha] ?
1076
src1[alpha] : (affect[alpha] ?
1077
new_alpha : src1[alpha]));
1088
1115
if (mode_affect)
1090
dest[alpha] = (affect[alpha]) ? new_alpha : src1[alpha];
1117
dest[alpha] = affect[alpha] ? new_alpha : src1[alpha];
1094
dest[alpha] = (src1[alpha]) ? src1[alpha] :
1095
(affect[alpha] ? new_alpha : src1[alpha]);
1121
dest[alpha] = (src1[alpha] ?
1122
src1[alpha] : (affect[alpha] ?
1123
new_alpha : src1[alpha]));
1119
1148
if (mode_affect)
1121
dest[alpha] = (affect[alpha]) ? new_alpha : src1[alpha];
1150
dest[alpha] = affect[alpha] ? new_alpha : src1[alpha];
1125
dest[alpha] = (src1[alpha]) ? src1[alpha] :
1126
(affect[alpha] ? new_alpha : src1[alpha]);
1154
dest[alpha] = (src1[alpha] ?
1155
src1[alpha] : (affect[alpha] ?
1156
new_alpha : src1[alpha]));
1144
1175
if (mode_affect)
1146
dest[alpha] = (affect[alpha]) ? new_alpha : src1[alpha];
1177
dest[alpha] = affect[alpha] ? new_alpha : src1[alpha];
1150
dest[alpha] = (src1[alpha]) ? src1[alpha] :
1151
(affect[alpha] ? new_alpha : src1[alpha]);
1181
dest[alpha] = (src1[alpha] ?
1182
src1[alpha] : (affect[alpha] ?
1183
new_alpha : src1[alpha]));
1165
1197
const guchar *channel,
1167
1199
const guchar *col,
1200
const guint opacity,
1172
1204
const gint alpha = bytes - 1;
1176
1206
while (length --)
1178
1209
guchar channel_alpha = INT_MULT (255 - *channel, opacity, t);
1180
1211
if (channel_alpha)
1214
const guchar new_alpha =
1184
1215
src[alpha] + INT_MULT ((255 - src[alpha]), channel_alpha, t);
1186
1219
if (new_alpha != 255)
1187
1220
channel_alpha = (channel_alpha * 255) / new_alpha;
1212
1245
const guchar *channel,
1214
1247
const guchar *col,
1248
const guint opacity,
1219
1252
const gint alpha = bytes - 1;
1223
1254
while (length --)
1225
guchar channel_alpha = INT_MULT (*channel, opacity, t);
1257
guchar channel_alpha = INT_MULT (*channel, opacity, t);
1227
1259
if (channel_alpha)
1262
const guchar new_alpha =
1231
1263
src[alpha] + INT_MULT ((255 - src[alpha]), channel_alpha, t);
1233
1267
if (new_alpha != 255)
1234
1268
channel_alpha = (channel_alpha * 255) / new_alpha;
1369
const guint has_alpha1 = HAS_ALPHA (bytes1);
1370
const guint has_alpha2 = HAS_ALPHA (bytes2);
1371
const guint bytes = MIN (bytes1, bytes2);
1377
const guchar *m = mask;
1381
guchar mask_alpha = INT_MULT (*m, opacity, tmp);
1383
for (b = 0; b < bytes; b++)
1384
dest[b] = (affect[b]) ?
1385
INT_BLEND (src2[b], src1[b], mask_alpha, tmp) :
1388
if (has_alpha1 && !has_alpha2)
1400
const guchar mask_alpha = opacity;
1404
for (b = 0; b < bytes; b++)
1405
dest[b] = (affect[b]) ?
1406
INT_BLEND (src2[b], src1[b], mask_alpha, tmp) :
1409
if (has_alpha1 && !has_alpha2)
1407
const guint has_alpha1 = HAS_ALPHA (bytes1);
1408
const guint has_alpha2 = HAS_ALPHA (bytes2);
1409
const guint alpha = bytes1 - has_alpha1;
1410
const guint alpha2 = bytes2 - has_alpha2;
1411
const guchar *m = mask ? mask : &no_mask;
1417
guchar src1_alpha = has_alpha1 ? src1[alpha] : 255;
1418
guchar src2_alpha = has_alpha2 ? src2[alpha2] : 255;
1419
guchar new_alpha = INT_BLEND (src2_alpha, src1_alpha,
1420
INT_MULT (*m, opacity, tmp), tmp);
1424
guint ratio = *m * opacity;
1425
ratio = ratio / 255 * src2_alpha;
1427
ratio = INT_DIV (ratio, new_alpha);
1429
for (b = 0; b < alpha; b++)
1435
else if (src2[b] > src1[b])
1437
guint t = (src2[b] - src1[b]) * ratio;
1438
dest[b] = src1[b] + INT_DIV (t, 255);
1442
guint t = (src1[b] - src2[b]) * ratio;
1443
dest[b] = src1[b] - INT_DIV (t, 255);
1449
for (b = 0; b < alpha; b++)
1454
dest[alpha] = affect[alpha] ? new_alpha : src1[alpha];
1419
1465
/* replace the contents of one pixel row with the other
1840
1886
/**************************************************/
1889
clear_region (PixelRegion *dest)
1893
for (pr = pixel_regions_register (1, dest);
1895
pr = pixel_regions_process (pr))
1897
if (dest->w * dest->bytes == dest->rowstride)
1899
memset (dest->data, 0, dest->w * dest->h * dest->bytes);
1903
guchar *d = dest->data;
1908
memset (d, 0, dest->w * dest->bytes);
1910
d += dest->rowstride;
1843
1918
color_region (PixelRegion *dest,
1844
1919
const guchar *col)
4561
4636
/* Second check - if any single colour channel can't be affected,
4562
4637
we can't use the opacity quickskip.
4564
4639
if (st.opacity_quickskip_possible)
4566
4641
for (i = 0; i < src1->bytes - 1; i++)