Graphics::ManagedSurface *AVISurface::duplicateTransparency() const { if (_streamCount <= 1) { return nullptr; } else { Graphics::ManagedSurface *dest = new Graphics::ManagedSurface(_movieFrameSurface[1]->w, _movieFrameSurface[1]->h, Graphics::PixelFormat::createFormatCLUT8()); dest->blitFrom(*_movieFrameSurface[1]); return dest; } }
Graphics::ManagedSurface *AVISurface::duplicateSecondaryFrame() const { if (_streamCount <= 1) { return nullptr; } else { Graphics::ManagedSurface *dest = new Graphics::ManagedSurface(_movieFrameSurface[1]->w, _movieFrameSurface[1]->h, _movieFrameSurface[1]->format); dest->blitFrom(*_movieFrameSurface[1]); return dest; } }
void AVISurface::copyMovieFrame(const Graphics::Surface &src, Graphics::ManagedSurface &dest) { // WORKAROUND: Handle rare cases where frame sizes don't match the video size Common::Rect copyRect(0, 0, MIN(src.w, dest.w), MIN(src.h, dest.h)); if (src.format.bytesPerPixel == 1) { // Paletted 8-bit, so convert to 16-bit and copy over const byte *palette = _decoder->getPalette(); if (palette) { Graphics::Surface *s = src.convertTo(dest.format, palette); dest.blitFrom(*s, copyRect, Common::Point(0, 0)); s->free(); delete s; } } else if (src.format.bytesPerPixel == 2) { // Source is already 16-bit, with no alpha, so do a straight copy dest.blitFrom(src, copyRect, Common::Point(0, 0)); } else { // Source is 32-bit which may have transparent pixels. Copy over each // pixel, replacing transparent pixels with the special transparency color byte a, r, g, b; assert(src.format.bytesPerPixel == 4 && dest.format.bytesPerPixel == 2); uint16 transPixel = _videoSurface->getTransparencyColor(); for (uint y = 0; y < MIN(src.h, dest.h); ++y) { const uint32 *pSrc = (const uint32 *)src.getBasePtr(0, y); uint16 *pDest = (uint16 *)dest.getBasePtr(0, y); for (uint x = 0; x < MIN(src.w, dest.w); ++x, ++pSrc, ++pDest) { src.format.colorToARGB(*pSrc, a, r, g, b); assert(a == 0 || a == 0xff); *pDest = (a == 0) ? transPixel : dest.format.RGBToColor(r, g, b); } } } }
void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { for (uint16 i = 0; i < CHANNEL_COUNT; i++) { if (_sprites[i]->_enabled) { if ((_sprites[i]->_trails == 0 && renderTrail) || (_sprites[i]->_trails == 1 && !renderTrail)) continue; Cast *cast; if (!_vm->_currentScore->_casts.contains(_sprites[i]->_castId)) { if (!_vm->getSharedCasts()->contains(_sprites[i]->_castId)) { warning("Cast id %d not found", _sprites[i]->_castId); continue; } else { cast = _vm->getSharedCasts()->getVal(_sprites[i]->_castId); } } else { cast = _vm->_currentScore->_casts[_sprites[i]->_castId]; } if (cast->type == kCastText) { renderText(surface, i); continue; } Image::ImageDecoder *img = getImageFrom(_sprites[i]->_castId); if (!img) { warning("Image with id %d not found", _sprites[i]->_castId); continue; } if (!img->getSurface()) { //TODO //BMPDecoder doesnt cover all BITD resources (not all have first two bytes 'BM') //Some BITD's first two bytes 0x6 0x0 warning("Can not load image %d", _sprites[i]->_castId); continue; } uint32 regX = static_cast<BitmapCast *>(_sprites[i]->_cast)->regX; uint32 regY = static_cast<BitmapCast *>(_sprites[i]->_cast)->regY; uint32 rectLeft = static_cast<BitmapCast *>(_sprites[i]->_cast)->initialRect.left; uint32 rectTop = static_cast<BitmapCast *>(_sprites[i]->_cast)->initialRect.top; int x = _sprites[i]->_startPoint.x - regX + rectLeft; int y = _sprites[i]->_startPoint.y - regY + rectTop; int height = _sprites[i]->_height; int width = _sprites[i]->_width; Common::Rect drawRect = Common::Rect(x, y, x + width, y + height); _drawRects.push_back(drawRect); switch (_sprites[i]->_ink) { case kInkTypeCopy: surface.blitFrom(*img->getSurface(), Common::Point(x, y)); break; case kInkTypeTransparent: //FIXME: is it always white (last entry in pallette)? surface.transBlitFrom(*img->getSurface(), Common::Point(x, y), _vm->getPaletteColorCount() - 1); break; case kInkTypeBackgndTrans: drawBackgndTransSprite(surface, *img->getSurface(), drawRect); break; case kInkTypeMatte: drawMatteSprite(surface, *img->getSurface(), drawRect); break; case kInkTypeGhost: drawGhostSprite(surface, *img->getSurface(), drawRect); break; case kInkTypeReverse: drawReverseSprite(surface, *img->getSurface(), drawRect); break; default: warning("Unhandled ink type %d", _sprites[i]->_ink); surface.blitFrom(*img->getSurface(), Common::Point(x, y)); break; } } } }