Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Image2d* MkoFileReader::CreateMkoAsset(const std::string& strId, unsigned uType){
- if (uType != MKO_IMAGE)
- throwError(__FUNCTION__ + std::string(" failed. File does not contain Image2d Data."));
- std::string strTextureFilename(128, 0);
- if (!GetString(strTextureFilename, true))
- throwError(__FUNCTION__ + std::string(" invalid mko file. Missing texture filename"));
- Image2d* pAsset = nullptr;
- if (_uVersion == 1){
- struct ImageData{
- unsigned short width;
- unsigned short height;
- unsigned short scale;
- union{
- unsigned char bits;
- struct ImageProperties{
- unsigned char generateMipMap : 1;
- unsigned char filterQuality : 2;
- unsigned char unused : 5;
- } bitfield;
- };
- } data;
- _filestream.read(reinterpret_cast<char*>(&data), sizeof(ImageData));
- if (_filestream.fail())
- throwError(__FUNCTION__ + std::string(" failed. Missing ImageData"));
- if (data.scale <= 0)
- throwError(__FUNCTION__ + std::string(" Invalid scale value."));
- float fScale = 1.0f / static_cast<float>(data.scale);
- pAsset = new Image2d(data.width*data.scale,
- data.height*data.scale,
- static_cast<TextureInfo::FilterQuality>(data.bitfield.filterQuality),
- data.bitfield.generateMipMap,
- strTextureFilename,
- strId);
- }
- return pAsset;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement