24
25
void GUIImageBufferCopyArea(
26
27
const guint8 *src_data,
27
gint src_width, gint src_height, gint src_bpl,
28
const gint src_width, const gint src_height, const gint src_bpl,
29
gint tar_width, gint tar_height, gint tar_bpl,
30
gint tar_x, gint tar_y,
30
const gint tar_width, const gint tar_height, const gint tar_bpl,
31
const gint tar_x, const gint tar_y,
31
32
const gboolean blend,
32
33
gint (*progress_cb)(const gulong, const gulong, gpointer),
33
34
gpointer progress_data
42
43
gpointer progress_data
44
45
void GUIImageBufferRotateCW90(
46
47
const guint8 *src_data,
47
gint src_width, gint src_height, gint src_bpl,
48
const gint src_width, const gint src_height, const gint src_bpl,
49
gint tar_width, gint tar_height, gint tar_bpl
50
const gint tar_width, const gint tar_height, const gint tar_bpl
51
52
void GUIImageBufferRotateCCW90(
53
54
const guint8 *src_data,
54
gint src_width, gint src_height, gint src_bpl,
55
const gint src_width, const gint src_height, const gint src_bpl,
56
gint tar_width, gint tar_height, gint tar_bpl
57
const gint tar_width, const gint tar_height, const gint tar_bpl
58
59
void GUIImageBufferRotateCW180(
60
61
const guint8 *src_data,
61
gint src_width, gint src_height, gint src_bpl,
62
const gint src_width, const gint src_height, const gint src_bpl,
63
gint tar_width, gint tar_height, gint tar_bpl
64
const gint tar_width, const gint tar_height, const gint tar_bpl
65
66
void GUIImageBufferMirrorH(
67
68
const guint8 *src_data,
68
gint src_width, gint src_height, gint src_bpl,
69
const gint src_width, const gint src_height, const gint src_bpl,
70
gint tar_width, gint tar_height, gint tar_bpl
71
const gint tar_width, const gint tar_height, const gint tar_bpl
72
73
void GUIImageBufferMirrorV(
74
75
const guint8 *src_data,
75
gint src_width, gint src_height, gint src_bpl,
77
gint tar_width, gint tar_height, gint tar_bpl
76
const gint src_width, const gint src_height, const gint src_bpl,
78
const gint tar_width, const gint tar_height, const gint tar_bpl
80
81
void GUIImageBufferFlattenWithBG(
200
201
* the target image's pixel.
202
203
void GUIImageBufferCopyArea(
204
205
const guint8 *src_data,
205
gint src_width, gint src_height, gint src_bpl,
206
const gint src_width, const gint src_height, const gint src_bpl,
206
207
guint8 *tar_data,
207
gint tar_width, gint tar_height, gint tar_bpl,
208
gint tar_x, gint tar_y,
208
const gint tar_width, const gint tar_height, const gint tar_bpl,
209
const gint tar_x, const gint tar_y,
209
210
const gboolean blend,
210
211
gint (*progress_cb)(const gulong, const gulong, gpointer),
211
212
gpointer progress_data
215
218
const guint8 *src_ptr, *src_end;
216
219
void (*pixel_op_func)(const gint, guint8 *, const guint8 *);
600
603
* clockwise 90 degrees.
602
605
void GUIImageBufferRotateCW90(
604
607
const guint8 *src_data,
605
gint src_width, gint src_height, gint src_bpl,
608
const gint src_width, const gint src_height, const gint src_bpl,
606
609
guint8 *tar_data,
607
gint tar_width, gint tar_height, gint tar_bpl
610
const gint tar_width, const gint tar_height, const gint tar_bpl
611
616
const guint8 *src_line;
613
618
if((src_width <= 0) || (src_height <= 0) ||
624
629
/* Calculate bytes per line values as needed */
626
src_bpl = src_width * bpp;
628
tar_bpl = tar_width * bpp;
631
_src_bpl = src_width * bpp;
633
_tar_bpl = tar_width * bpp;
630
635
/* Copy/rotate clockwise 90 degrees */
631
636
for(sy = 0, tx = tar_width - 1;
651
656
* counter-clockwise 90 degrees.
653
658
void GUIImageBufferRotateCCW90(
655
660
const guint8 *src_data,
656
gint src_width, gint src_height, gint src_bpl,
661
const gint src_width, const gint src_height, const gint src_bpl,
657
662
guint8 *tar_data,
658
gint tar_width, gint tar_height, gint tar_bpl
663
const gint tar_width, const gint tar_height, const gint tar_bpl
662
669
const guint8 *src_line;
664
671
if((src_width <= 0) || (src_height <= 0) ||
702
709
* clockwise 180 degrees.
704
711
void GUIImageBufferRotateCW180(
706
713
const guint8 *src_data,
707
gint src_width, gint src_height, gint src_bpl,
714
const gint src_width, const gint src_height, const gint src_bpl,
708
715
guint8 *tar_data,
709
gint tar_width, gint tar_height, gint tar_bpl
716
const gint tar_width, const gint tar_height, const gint tar_bpl
713
722
const guint8 *src_line;
715
724
if((src_width <= 0) || (src_height <= 0) ||
726
735
/* Calculate bytes per line values as needed */
728
src_bpl = src_width * bpp;
730
tar_bpl = tar_width * bpp;
737
_src_bpl = src_width * bpp;
739
_tar_bpl = tar_width * bpp;
732
741
/* Copy/rotate clockwise 90 degrees */
733
742
for(sy = 0, ty = tar_height - 1;
755
764
void GUIImageBufferMirrorH(
757
766
const guint8 *src_data,
758
gint src_width, gint src_height, gint src_bpl,
767
const gint src_width, const gint src_height, const gint src_bpl,
759
768
guint8 *tar_data,
760
gint tar_width, gint tar_height, gint tar_bpl
769
const gint tar_width, const gint tar_height, const gint tar_bpl
764
775
const guint8 *src_line;
766
777
if((src_width <= 0) || (src_height <= 0) ||
806
817
void GUIImageBufferMirrorV(
808
819
const guint8 *src_data,
809
gint src_width, gint src_height, gint src_bpl,
820
const gint src_width, const gint src_height, const gint src_bpl,
810
821
guint8 *tar_data,
811
gint tar_width, gint tar_height, gint tar_bpl
822
const gint tar_width, const gint tar_height, const gint tar_bpl
815
828
const guint8 *src_line;
817
830
if((src_width <= 0) || (src_height <= 0) ||
828
841
/* Calculate bytes per line values as needed */
830
src_bpl = src_width * bpp;
832
tar_bpl = tar_width * bpp;
843
_src_bpl = src_width * bpp;
845
_tar_bpl = tar_width * bpp;
834
847
/* Copy/mirror horizontally */
835
848
for(sy = 0, ty = tar_height - 1;
992
1005
gint *width_rtn, gint *height_rtn, gint *bpl_rtn
995
#if defined(__GDK_X_H__)
996
1009
gint width, height, src_bpp, src_bpl, tar_bpp, tar_bpl;
997
1010
const guint8 *src_data;
998
1011
guint8 *tar_data;
1001
1015
GdkRectangle lrect;
1002
GdkWindowPrivate *private = (GdkWindowPrivate *)drawable;
1003
Window xwin = (private != NULL) ? private->xwindow : None;
1016
GdkVisualType visual_type;
1019
GdkWindowPrivate *private;
1005
1021
if(width_rtn != NULL)
1006
1022
*width_rtn = 0;
1009
1025
if(bpl_rtn != NULL)
1028
if(drawable == NULL)
1031
private = (GdkWindowPrivate *)drawable;
1015
1032
xdpy = private->xdisplay;
1033
xwin = private->xwindow;
1034
if((xdpy == NULL) || (xwin == None))
1019
/* If no rectangle is specified then set rectangle to cover the
1037
cmap = private->colormap;
1038
visual = (cmap != NULL) ? gdk_colormap_get_visual(cmap) : NULL;
1040
visual_type = visual->type;
1042
visual_type = gdk_visual_get_best_type();
1044
/* If no rectangle was specified then set the rectangle to
1045
* cover the entire drawable
1022
1047
if(rect == NULL)
1025
lrect.x = private->x;
1026
lrect.y = private->y;
1027
1052
lrect.width = private->width;
1028
1053
lrect.height = private->height;
1068
1095
if(ximg->depth == 8)
1070
gint xoffset_bytes, x, y;
1071
1097
const gint r_div = 7,
1100
gint xoffset_bytes, x, y;
1075
1102
const guint8 *src_ptr;
1076
1103
guint8 *tar_ptr;
1079
1107
xoffset_bytes = ximg->xoffset * src_bpp;
1081
for(y = 0; y < height; y++)
1083
src_ptr = (const guint8 *)(
1084
src_data + (y * src_bpl) + xoffset_bytes
1086
tar_ptr = tar_data + (y * tar_bpl);
1088
for(x = 0; x < width; x++)
1090
/* 8 Bits Format: rrrgggbb */
1091
src_v = (guint)*src_ptr++;
1092
*tar_ptr++ = (guint8)(
1111
case GDK_VISUAL_STATIC_GRAY:
1112
case GDK_VISUAL_GRAYSCALE:
1113
for(y = 0; y < height; y++)
1115
src_ptr = (const guint8 *)(
1116
src_data + (y * src_bpl) + xoffset_bytes
1118
tar_ptr = tar_data + (y * tar_bpl);
1120
for(x = 0; x < width; x++)
1122
*tar_ptr++ = *src_ptr;
1123
*tar_ptr++ = *src_ptr;
1124
*tar_ptr++ = *src_ptr++;
1129
case GDK_VISUAL_STATIC_COLOR:
1130
case GDK_VISUAL_PSEUDO_COLOR:
1134
XDestroyImage(ximg);
1137
if((cmap->colors == NULL) || (cmap->size <= 0))
1140
XDestroyImage(ximg);
1143
for(y = 0; y < height; y++)
1145
src_ptr = (const guint8 *)(
1146
src_data + (y * src_bpl) + xoffset_bytes
1148
tar_ptr = tar_data + (y * tar_bpl);
1150
for(x = 0; x < width; x++)
1152
c = &cmap->colors[*src_ptr];
1154
*tar_ptr++ = (guint8)(c->red >> 8);
1155
*tar_ptr++ = (guint8)(c->green >> 8);
1156
*tar_ptr++ = (guint8)(c->blue >> 8);
1161
default: /* GDK_VISUAL_TRUE_COLOR */
1162
for(y = 0; y < height; y++)
1164
src_ptr = (const guint8 *)(
1165
src_data + (y * src_bpl) + xoffset_bytes
1167
tar_ptr = tar_data + (y * tar_bpl);
1169
for(x = 0; x < width; x++)
1171
/* 8 Bits Format: rrrgggbb */
1172
src_v = (guint32)*src_ptr++;
1173
*tar_ptr++ = (guint8)(
1093
1174
((src_v & 0xE0) >> 5) * 0xff / r_div
1095
*tar_ptr++ = (guint8)(
1176
*tar_ptr++ = (guint8)(
1096
1177
((src_v & 0x1C) >> 2) * 0xff / g_div
1098
*tar_ptr++ = (guint8)(
1179
*tar_ptr++ = (guint8)(
1099
1180
((src_v & 0x03) >> 0) * 0xff / b_div
1104
1187
else if(ximg->depth == 15)
1123
1207
for(x = 0; x < width; x++)
1125
/* 16 Bits Format: arrrrrgg gggbbbbb */
1126
*tar_ptr++ = (guint8)(
1127
((((guint)*src_ptr) & 0x7C00) >> 10) * 0xff / r_div
1129
*tar_ptr++ = (guint8)(
1130
((((guint)*src_ptr) & 0x03E0) >> 5) * 0xff / g_div
1132
*tar_ptr++ = (guint8)(
1133
((((guint)*src_ptr) & 0x001F) >> 0) * 0xff / b_div
1209
/* 15 Bits Format: arrrrrgg gggbbbbb */
1212
*tar_ptr++ = (guint8)(
1213
(guint32)((v16 & 0x7C00) >> 10) * 0xFF / r_div
1215
*tar_ptr++ = (guint8)(
1216
(guint32)((v16 & 0x03E0) >> 5) * 0xFF / g_div
1218
*tar_ptr++ = (guint8)(
1219
(guint32)((v16 & 0x001F) >> 0) * 0xFF / b_div
1159
1244
for(x = 0; x < width; x++)
1161
1246
/* 16 Bits Format: rrrrrggg gggbbbbb */
1162
*tar_ptr++ = (guint8)(
1163
((((guint)*src_ptr) & 0xF800) >> 11) * 0xff / r_div
1165
*tar_ptr++ = (guint8)(
1166
((((guint)*src_ptr) & 0x07E0) >> 5) * 0xff / g_div
1168
*tar_ptr++ = (guint8)(
1169
((((guint)*src_ptr) & 0x001F) >> 0) * 0xff / b_div
1249
*tar_ptr++ = (guint8)(
1250
(guint32)((v16 & 0xF800) >> 11) * 0xFF / r_div
1252
*tar_ptr++ = (guint8)(
1253
(guint32)((v16 & 0x07E0) >> 5) * 0xFF / g_div
1255
*tar_ptr++ = (guint8)(
1256
(guint32)((v16 & 0x001F) >> 0) * 0xFF / b_div
1261
1346
gint *width_rtn, gint *height_rtn, gint *bpl_rtn
1264
#if defined(__GDK_X_H__)
1265
1350
gint width, height, src_bpp, src_bpl, tar_bpp, tar_bpl;
1266
1351
const guint8 *src_data;
1267
1352
guint8 *tar_data;
1270
1356
GdkRectangle lrect;
1271
GdkWindowPrivate *private = (GdkWindowPrivate *)drawable;
1272
Window xwin = (private != NULL) ? private->xwindow : None;
1357
GdkVisualType visual_type;
1360
GdkWindowPrivate *private;
1274
1362
if(width_rtn != NULL)
1275
1363
*width_rtn = 0;
1278
1366
if(bpl_rtn != NULL)
1369
if(drawable == NULL)
1372
private = (GdkWindowPrivate *)drawable;
1284
1373
xdpy = private->xdisplay;
1374
xwin = private->xwindow;
1375
if((xdpy == NULL) || (xwin == None))
1288
/* If no rectangle is specified then set rectangle to cover the
1378
cmap = private->colormap;
1379
visual = (cmap != NULL) ? gdk_colormap_get_visual(cmap) : NULL;
1381
visual_type = visual->type;
1383
visual_type = gdk_visual_get_best_type();
1385
/* If no rectangle was specified then set the rectangle to
1386
* cover the entire drawable
1291
1388
if(rect == NULL)
1294
lrect.x = private->x;
1295
lrect.y = private->y;
1296
1393
lrect.width = private->width;
1297
1394
lrect.height = private->height;
1334
1433
/* Begin copying the XImage data to the return data */
1335
if(ximg->depth == 8)
1434
if(ximg->depth == 1)
1337
gint xoffset_bytes, x, y;
1338
const gint r_div = 7,
1436
gint x, y, xoffset_bytes;
1342
1437
const guint8 *src_ptr;
1343
1438
guint8 *tar_ptr;
1346
xoffset_bytes = ximg->xoffset * src_bpp;
1441
xoffset_bytes = ximg->xoffset * src_bpp;
1348
1443
for(y = 0; y < height; y++)
1355
1450
for(x = 0; x < width; x++)
1357
/* 8 Bits Format: rrrgggbb */
1358
src_v = (guint)*src_ptr++;
1359
*tar_ptr++ = (guint8)(
1360
((src_v & 0xE0) >> 5) * 0xff / r_div
1362
*tar_ptr++ = (guint8)(
1452
if(src_ptr[x / 8] & (1 << (x % 8)))
1469
else if(ximg->depth == 8)
1471
const gint r_div = 7,
1474
gint xoffset_bytes, x, y;
1476
const guint8 *src_ptr;
1481
xoffset_bytes = ximg->xoffset * src_bpp;
1485
case GDK_VISUAL_STATIC_GRAY:
1486
case GDK_VISUAL_GRAYSCALE:
1487
for(y = 0; y < height; y++)
1489
src_ptr = (const guint8 *)(
1490
src_data + (y * src_bpl) + xoffset_bytes
1492
tar_ptr = tar_data + (y * tar_bpl);
1494
for(x = 0; x < width; x++)
1496
*tar_ptr++ = *src_ptr;
1497
*tar_ptr++ = *src_ptr;
1498
*tar_ptr++ = *src_ptr++;
1504
case GDK_VISUAL_STATIC_COLOR:
1505
case GDK_VISUAL_PSEUDO_COLOR:
1509
XDestroyImage(ximg);
1512
if((cmap->colors == NULL) || (cmap->size <= 0))
1515
XDestroyImage(ximg);
1518
for(y = 0; y < height; y++)
1520
src_ptr = (const guint8 *)(
1521
src_data + (y * src_bpl) + xoffset_bytes
1523
tar_ptr = tar_data + (y * tar_bpl);
1525
for(x = 0; x < width; x++)
1527
c = &cmap->colors[*src_ptr];
1529
*tar_ptr++ = (guint8)(c->red >> 8);
1530
*tar_ptr++ = (guint8)(c->green >> 8);
1531
*tar_ptr++ = (guint8)(c->blue >> 8);
1537
default: /* GDK_VISUAL_TRUE_COLOR */
1538
for(y = 0; y < height; y++)
1540
src_ptr = (const guint8 *)(
1541
src_data + (y * src_bpl) + xoffset_bytes
1543
tar_ptr = tar_data + (y * tar_bpl);
1545
for(x = 0; x < width; x++)
1547
/* 8 Bits Format: rrrgggbb */
1548
src_v = (guint32)*src_ptr++;
1549
*tar_ptr++ = (guint8)(
1550
((src_v & 0xE0) >> 5) * 0xff / r_div
1552
*tar_ptr++ = (guint8)(
1363
1553
((src_v & 0x1C) >> 2) * 0xff / g_div
1365
*tar_ptr++ = (guint8)(
1555
*tar_ptr++ = (guint8)(
1366
1556
((src_v & 0x03) >> 0) * 0xff / b_div
1372
1564
else if(ximg->depth == 15)
1391
1584
for(x = 0; x < width; x++)
1393
/* 16 Bits Format: arrrrrgg gggbbbbb */
1394
*tar_ptr++ = (guint8)(
1395
((((guint)*src_ptr) & 0x7C00) >> 10) * 0xff / r_div
1397
*tar_ptr++ = (guint8)(
1398
((((guint)*src_ptr) & 0x03E0) >> 5) * 0xff / g_div
1400
*tar_ptr++ = (guint8)(
1401
((((guint)*src_ptr) & 0x001F) >> 0) * 0xff / b_div
1586
/* 15 Bits Format: arrrrrgg gggbbbbb */
1589
*tar_ptr++ = (guint8)(
1590
(guint32)((v16 & 0x7C00) >> 10) * 0xFF / r_div
1592
*tar_ptr++ = (guint8)(
1593
(guint32)((v16 & 0x03E0) >> 5) * 0xFF / g_div
1595
*tar_ptr++ = (guint8)(
1596
(guint32)((v16 & 0x001F) >> 0) * 0xFF / b_div
1403
1598
/* Alpha channel may not be defined
1404
*tar_ptr++ = (((guint)*src_ptr) & (1 << 15)) ?
1599
*tar_ptr++ = (v16 & (1 << 15)) ? 0xff : 0x00;
1407
1601
*tar_ptr++ = 0xff;
1432
1625
for(x = 0; x < width; x++)
1434
1627
/* 16 Bits Format: rrrrrggg gggbbbbb */
1435
*tar_ptr++ = (guint8)(
1436
((((guint)*src_ptr) & 0xF800) >> 11) * 0xff / r_div
1438
*tar_ptr++ = (guint8)(
1439
((((guint)*src_ptr) & 0x07E0) >> 5) * 0xff / g_div
1441
*tar_ptr++ = (guint8)(
1442
((((guint)*src_ptr) & 0x001F) >> 0) * 0xff / b_div
1630
*tar_ptr++ = (guint8)(
1631
(guint32)((v16 & 0xF800) >> 11) * 0xff / r_div
1633
*tar_ptr++ = (guint8)(
1634
(guint32)((v16 & 0x07E0) >> 5) * 0xff / g_div
1636
*tar_ptr++ = (guint8)(
1637
(guint32)((v16 & 0x001F) >> 0) * 0xff / b_div
1444
1639
*tar_ptr++ = 0xff;