@@ -781,6 +781,11 @@ function __construct($preloadData, $readSwitch) {
781
781
$ this ->transcodeFormat = 'bmp ' ;
782
782
$ this ->bitDepth = 16 ;
783
783
break ;
784
+ case TextureFormat::PVRTC_RGB4 :
785
+ $ this ->outputMethod = 'pvr ' ;
786
+ $ this ->transcodeFormat = 'bmp ' ;
787
+ // use PVRTexToolCLI
788
+ break ;
784
789
default :
785
790
throw new Exception ('not implemented: ' .$ this ->textureFormat .' ' .$ this ->textureFormatStr );
786
791
}
@@ -837,8 +842,34 @@ function exportTo($saveTo, $format = 'png', $extraEncodeParam = '') {
837
842
file_put_contents ('output.bmp ' , $ bmp ->readData ($ bmp ->size ));
838
843
unset($ bmp );
839
844
$ transcodeFile = 'output.bmp ' ;
845
+ } else if ($ this ->outputMethod == 'pvr ' ) {
846
+ /*fclose(fopen('output.pvr','wb'));
847
+ $pvr = new FileStream('output.pvr');
848
+ $pvr->write(hex2bin('5056520300000000'));
849
+ $pvr->write(pack('P', [
850
+ TextureFormat::PVRTC_RGB2 => 0,
851
+ TextureFormat::PVRTC_RGB4 => 2,
852
+ TextureFormat::PVRTC_RGBA2 => 1,
853
+ TextureFormat::PVRTC_RGBA4 => 3,
854
+ ][$this->textureFormat]));
855
+ $pvr->write(hex2bin('0000000000000000'));
856
+ $pvr->write(pack('V', $this->height));
857
+ $pvr->write(pack('V', $this->width));
858
+ $pvr->write(hex2bin('0100000001000000010000000100000000000000'));
859
+ $pvr->write($this->imageData);
860
+ unset($pvr);*/
861
+ file_put_contents ('output.pvr ' , $ this ->imageData );
862
+ exec ('pvr-decompress output.pvr output.bmp ' .implode (' ' , [$ this ->width , $ this ->height , [
863
+ TextureFormat::PVRTC_RGB2 => 1 ,
864
+ TextureFormat::PVRTC_RGB4 => 0 ,
865
+ TextureFormat::PVRTC_RGBA2 => 1 ,
866
+ TextureFormat::PVRTC_RGBA4 => 0 ,
867
+ ][$ this ->textureFormat ]]));
868
+ unlink ('output.pvr ' );
869
+ $ transcodeFile = 'output.bmp ' ;
870
+ //throw new Exception('wip');
840
871
} else {
841
- throw new Excpetion ('not supported ' );
872
+ throw new Exception ('not supported ' );
842
873
}
843
874
844
875
if ($ this ->transcodeFormat != $ format ) {
0 commit comments