节选的库中判断图片格式的代码(判断jpg,png,gif,tiff)
By
admin
at 2017-11-23 • 0人收藏 • 1206人看过
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); } }
登录后方可回帖