Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mGifFile = DGifOpen(this, onRead, &mError);
- if (mError) {
- throw System::InvalidOperation(GifErrorString(mError));
- }
- mError = DGifSlurp(mGifFile);
- if (mError == 0) {
- throw System::InvalidOperation(GifErrorString(mGifFile->Error));
- }
- ...
- mImageNumber = (mImageNumber + 1) % (mGifFile->ImageCount);
- auto& img = mGifFile->SavedImages[mImageNumber];
- assert(img.ImageDesc.Width == mGifFile->SWidth && img.ImageDesc.Height == mGifFile->SHeight);
- std::vector<uint32> colorData(img.ImageDesc.Width * img.ImageDesc.Height);
- auto colorMap = img.ImageDesc.ColorMap ? img.ImageDesc.ColorMap : mGifFile->SColorMap;
- memset(&mGcb, 0, sizeof(mGcb));
- int ret = DGifSavedExtensionToGCB(mGifFile, mImageNumber, &mGcb);
- if (ret == GIF_OK) {
- mHasGcb = true;
- mLastFrame = sTime->getGameTime();
- } else {
- mHasGcb = false;
- }
- for (uint32 i = 0; i < colorData.size(); ++i) {
- auto& clrObj = colorMap->Colors[img.RasterBits[i]];
- auto r = clrObj.Red;
- auto g = clrObj.Green;
- auto b = clrObj.Blue;
- auto alpha = 0xFF;
- colorData[i] = (alpha << 24) | (b << 16) | (g << 8) | r;
- }
- mTexture->fromMemory(mGifFile->SWidth, mGifFile->SHeight, colorData);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement