19 {
20 $ThisFileInfo['fileformat'] = 'pcd';
21 $ThisFileInfo['video']['dataformat'] = 'pcd';
22 $ThisFileInfo['video']['lossless'] = false;
23
24
25 fseek($fd, $ThisFileInfo['avdataoffset'] + 72, SEEK_SET);
26
27 $PCDflags = fread($fd, 1);
28 $PCDisVertical = ((ord($PCDflags) & 0x01) ? true : false);
29
30
31 if ($PCDisVertical) {
32 $ThisFileInfo['video']['resolution_x'] = 3072;
33 $ThisFileInfo['video']['resolution_y'] = 2048;
34 } else {
35 $ThisFileInfo['video']['resolution_x'] = 2048;
36 $ThisFileInfo['video']['resolution_y'] = 3072;
37 }
38
39
40 if ($ExtractData > 3) {
41
42 $ThisFileInfo['error'][] = 'Cannot extract PSD image data for detail levels above BASE (3)';
43
44 } elseif ($ExtractData > 0) {
45
46 $PCD_levels[1] = array( 192, 128, 0x02000);
47 $PCD_levels[2] = array( 384, 256, 0x0B800);
48 $PCD_levels[3] = array( 768, 512, 0x30000);
49
50
51
52
53 list($PCD_width, $PCD_height, $PCD_dataOffset) = $PCD_levels[3];
54
55 fseek($fd, $ThisFileInfo['avdataoffset'] + $PCD_dataOffset, SEEK_SET);
56
57 for ($y = 0; $y < $PCD_height; $y += 2) {
58
59
60
61
62
63
64 $PCD_data_Y1 = fread($fd, $PCD_width);
65 $PCD_data_Y2 = fread($fd, $PCD_width);
66 $PCD_data_Cb = fread($fd, intval(round($PCD_width / 2)));
67 $PCD_data_Cr = fread($fd, intval(round($PCD_width / 2)));
68
69 for ($x = 0; $x < $PCD_width; $x++) {
70 if ($PCDisVertical) {
71 $ThisFileInfo[
'pcd'][
'data'][$PCD_width - $x][$y] = $this->
YCbCr2RGB(ord($PCD_data_Y1{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
72 $ThisFileInfo[
'pcd'][
'data'][$PCD_width - $x][$y + 1] = $this->
YCbCr2RGB(ord($PCD_data_Y2{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
73 } else {
74 $ThisFileInfo[
'pcd'][
'data'][$y][$x] = $this->
YCbCr2RGB(ord($PCD_data_Y1{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
75 $ThisFileInfo[
'pcd'][
'data'][$y + 1][$x] = $this->
YCbCr2RGB(ord($PCD_data_Y2{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
76 }
77 }
78 }
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 }
94
95 }