Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. mGifFile = DGifOpen(this, onRead, &mError);
  2. if (mError) {
  3. throw System::InvalidOperation(GifErrorString(mError));
  4. }
  5.  
  6. mError = DGifSlurp(mGifFile);
  7. if (mError == 0) {
  8. throw System::InvalidOperation(GifErrorString(mGifFile->Error));
  9. }
  10. ...
  11.  
  12. mImageNumber = (mImageNumber + 1) % (mGifFile->ImageCount);
  13. auto& img = mGifFile->SavedImages[mImageNumber];
  14.  
  15. assert(img.ImageDesc.Width == mGifFile->SWidth && img.ImageDesc.Height == mGifFile->SHeight);
  16.  
  17. std::vector<uint32> colorData(img.ImageDesc.Width * img.ImageDesc.Height);
  18. auto colorMap = img.ImageDesc.ColorMap ? img.ImageDesc.ColorMap : mGifFile->SColorMap;
  19.  
  20. memset(&mGcb, 0, sizeof(mGcb));
  21. int ret = DGifSavedExtensionToGCB(mGifFile, mImageNumber, &mGcb);
  22. if (ret == GIF_OK) {
  23. mHasGcb = true;
  24. mLastFrame = sTime->getGameTime();
  25. } else {
  26. mHasGcb = false;
  27. }
  28.  
  29. for (uint32 i = 0; i < colorData.size(); ++i) {
  30. auto& clrObj = colorMap->Colors[img.RasterBits[i]];
  31. auto r = clrObj.Red;
  32. auto g = clrObj.Green;
  33. auto b = clrObj.Blue;
  34. auto alpha = 0xFF;
  35. colorData[i] = (alpha << 24) | (b << 16) | (g << 8) | r;
  36. }
  37.  
  38. mTexture->fromMemory(mGifFile->SWidth, mGifFile->SHeight, colorData);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement