load = function(path){ //var fullpath = ..io.exist(path) //if( fullpath ) return dll.ImageLoadW(owner.hImage,fullpath); var buffer = ..string.loadBuffer(path); if( buffer ){ if( buffer[1] == 0xFF && buffer[2] == 0xD8 ){ path="*.jpg" } elseif( buffer[1] == 0x89 && buffer[2] == 0x50 && buffer[3] == 0x4e && buffer[4] == 0x47){ path="*.png" } elseif( buffer[1] == 0x47 && buffer[2] == 0x49 && buffer[3] == 0x46){ path="*.gif" } elseif( buffer[1] == 0x0C && buffer[2] == 0xED){ path="*.tiff" } return dll.ImageFromStringB(owner.hImage,buffer,#buffer,path); } }
代码原理是根据图片的头文件格式进行判断,要知道每种图片格式都有自己特定的头文字格式.
标签:buffer,tiff,图片格式,jpg,&&,path From: https://www.cnblogs.com/popdes/p/16704458.html