Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Loads sctex file into loaded helper structure
- /// </summary>
- /// <param name="filename">Filename</param>
- /// <returns>Pointer to HelperImageData </returns>
- LoaderSctex::HelperImageData* LoaderSctex::Load(const std::string& filename)
- {
- if (!Files::Exists(filename))
- {
- mLog->Print("LoaderSctex", std::string("File ") + filename + std::string(" does not exist!"));
- return nullptr;
- }
- HelperImageData* image = new HelperImageData();
- FILE* f = fopen(filename.c_str(), "rb");
- fread(&image->mHeader, sizeof(Header), 1, f);
- image->mImageRecord = new ImageRecord[image->mHeader.mNumImages];
- fread(image->mImageRecord, sizeof(ImageRecord), image->mHeader.mNumImages, f);
- image->mImageData = new ImageData[image->mHeader.mNumImages];
- for (size_t i = 0; i < image->mHeader.mNumImages; i++)
- {
- image->mImageData[i].mData = new unsigned char[image->mImageRecord[i].mSize];
- fseek(f, (long)image->mImageRecord[i].mOffset, SEEK_SET);
- fread(image->mImageData[i].mData, sizeof(char), image->mImageRecord[i].mSize, f);
- }
- fclose(f);
- return image;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement