20 foreach ($gd_image_array as $key => $gd_image) {
22 $ImageWidths[$key] = ImageSX($gd_image);
23 $ImageHeights[$key] = ImageSY($gd_image);
24 $bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
25 $totalcolors[$key] = ImageColorsTotal($gd_image);
28 for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
29 for ($x = 0; $x < $ImageWidths[$key]; $x++) {
31 $a = round(255 * ((127 - $argb[
'alpha']) / 127));
36 if ($bpp[$key] == 32) {
37 $icXOR[$key] .= chr($b).chr($g).chr($r).chr($a);
38 } elseif ($bpp[$key] == 24) {
39 $icXOR[$key] .= chr($b).chr($g).chr($r);
43 @$icANDmask[$key][$y] .=
'1';
45 @$icANDmask[$key][$y] .=
'0';
49 while (strlen($icANDmask[$key][$y]) % 32) {
50 $icANDmask[$key][$y] .=
'0';
54 foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
55 for (
$i = 0;
$i < strlen($scanlinemaskbits);
$i += 8) {
56 $icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits,
$i, 8), 8,
'0', STR_PAD_LEFT)));
62 foreach ($gd_image_array as $key => $gd_image) {
63 $biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
66 $BitmapInfoHeader[$key] =
'';
67 $BitmapInfoHeader[$key] .=
"\x28\x00\x00\x00";
72 $BitmapInfoHeader[$key] .=
"\x01\x00";
73 $BitmapInfoHeader[$key] .= chr($bpp[$key]).
"\x00";
74 $BitmapInfoHeader[$key] .=
"\x00\x00\x00\x00";
76 $BitmapInfoHeader[$key] .=
"\x00\x00\x00\x00";
77 $BitmapInfoHeader[$key] .=
"\x00\x00\x00\x00";
78 $BitmapInfoHeader[$key] .=
"\x00\x00\x00\x00";
79 $BitmapInfoHeader[$key] .=
"\x00\x00\x00\x00";
83 $icondata =
"\x00\x00";
84 $icondata .=
"\x01\x00";
87 $dwImageOffset = 6 + (count($gd_image_array) * 16);
88 foreach ($gd_image_array as $key => $gd_image) {
91 $icondata .= chr($ImageWidths[$key]);
92 $icondata .= chr($ImageHeights[$key]);
93 $icondata .= chr($totalcolors[$key]);
96 $icondata .=
"\x01\x00";
97 $icondata .= chr($bpp[$key]).
"\x00";
99 $dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
103 $dwImageOffset += strlen($BitmapInfoHeader[$key]);
104 $dwImageOffset += strlen($icXOR[$key]);
105 $dwImageOffset += strlen($icAND[$key]);
108 foreach ($gd_image_array as $key => $gd_image) {
109 $icondata .= $BitmapInfoHeader[$key];
110 $icondata .= $icXOR[$key];
111 $icondata .= $icAND[$key];