void MystCursorManager::setCursor(uint16 id) { // Zero means empty cursor if (id == 0) { static const byte emptyCursor[4] = { 0, 0, 0, 0 }; CursorMan.replaceCursor(&emptyCursor, 2, 2, 0, 0, 0); return; } // Both Myst and Myst ME use the "MystBitmap" format for cursor images. MohawkSurface *mhkSurface = _bmpDecoder->decodeImage(_vm->getResource(ID_WDIB, id)); Graphics::Surface *surface = mhkSurface->getSurface(); Common::SeekableReadStream *clrcStream = _vm->getResource(ID_CLRC, id); uint16 hotspotX = clrcStream->readUint16LE(); uint16 hotspotY = clrcStream->readUint16LE(); delete clrcStream; // Myst ME stores some cursors as 24bpp images instead of 8bpp if (surface->format.bytesPerPixel == 1) { CursorMan.replaceCursor(surface->getPixels(), surface->w, surface->h, hotspotX, hotspotY, 0); CursorMan.replaceCursorPalette(mhkSurface->getPalette(), 0, 256); } else { Graphics::PixelFormat pixelFormat = g_system->getScreenFormat(); CursorMan.replaceCursor(surface->getPixels(), surface->w, surface->h, hotspotX, hotspotY, pixelFormat.RGBToColor(255, 255, 255), false, &pixelFormat); } _vm->_needsUpdate = true; delete mhkSurface; }
void LBGraphics::copyOffsetAnimImageToScreen(uint16 image, int left, int top) { MohawkSurface *mhkSurface = findImage(image); left -= mhkSurface->getOffsetX(); top -= mhkSurface->getOffsetY(); GraphicsManager::copyAnimImageToScreen(image, left, top); }
void RivenGraphics::drawInventoryImage(uint16 id, const Common::Rect *rect) { MohawkSurface *mhkSurface = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, id)); mhkSurface->convertToTrueColor(); Graphics::Surface *surface = mhkSurface->getSurface(); _vm->_system->copyRectToScreen((byte *)surface->pixels, surface->pitch, rect->left, rect->top, surface->w, surface->h); delete mhkSurface; }
void RivenGraphics::drawExtrasImage(uint16 id, Common::Rect dstRect) { MohawkSurface *mhkSurface = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, id)); mhkSurface->convertToTrueColor(); Graphics::Surface *surface = mhkSurface->getSurface(); assert(dstRect.width() == surface->w); for (uint16 i = 0; i < surface->h; i++) memcpy(_mainScreen->getBasePtr(dstRect.left, i + dstRect.top), surface->getBasePtr(0, i), surface->pitch); delete mhkSurface; _dirtyScreen = true; }
void RivenGraphics::beginCredits() { // Clear the old cache clearCache(); // Now cache all the credits images for (uint16 i = 302; i <= 320; i++) { MohawkSurface *surface = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, i)); surface->convertToTrueColor(); addImageToCache(i, surface); } // And clear our screen too clearMainScreen(); }
bool LBGraphics::imageIsTransparentAt(uint16 image, bool useOffsets, int x, int y) { MohawkSurface *mhkSurface = findImage(image); if (useOffsets) { x += mhkSurface->getOffsetX(); y += mhkSurface->getOffsetY(); } if (x < 0 || y < 0) return true; Graphics::Surface *surface = mhkSurface->getSurface(); if (x >= surface->w || y >= surface->h) return true; return *(byte *)surface->getBasePtr(x, y) == 0; }
void MystCursorManager::setCursor(uint16 id) { // Zero means empty cursor if (id == 0) { static const byte emptyCursor[4] = { 0, 0, 0, 0 }; CursorMan.replaceCursor(&emptyCursor, 2, 2, 0, 0, 0); return; } Common::SeekableReadStream *clrcStream = _vm->getResource(ID_CLRC, id); uint16 hotspotX = clrcStream->readUint16LE(); uint16 hotspotY = clrcStream->readUint16LE(); delete clrcStream; // Both Myst and Myst ME use the "MystBitmap" format for cursor images. MohawkSurface *mhkSurface = _vm->_gfx->findImage(id); Graphics::Surface *surface = mhkSurface->getSurface(); // Myst ME stores some cursors as 24bpp images instead of 8bpp if (surface->format.bytesPerPixel == 1) { // The transparent color is almost always 255, except for the main cursor (100) // in the D'ni archive, where it is 0. // Using the color of the first pixel as the transparent color for the main cursor always works. byte transparentColor; if (id == kDefaultMystCursor) { transparentColor = ((byte *)surface->getPixels())[0]; } else { transparentColor = 255; } CursorMan.replaceCursor(surface->getPixels(), surface->w, surface->h, hotspotX, hotspotY, transparentColor); // We're using the screen palette for the original game, but we need // to use this for any 8bpp cursor in ME. if (_vm->getFeatures() & GF_ME) CursorMan.replaceCursorPalette(mhkSurface->getPalette(), 0, 256); } else { Graphics::PixelFormat pixelFormat = g_system->getScreenFormat(); CursorMan.replaceCursor(surface->getPixels(), surface->w, surface->h, hotspotX, hotspotY, pixelFormat.RGBToColor(255, 255, 255), false, &pixelFormat); } }
MohawkSurface *RivenGraphics::decodeImage(uint16 id) { MohawkSurface *surface = _bitmapDecoder->decodeImage(_vm->getResource(ID_TBMP, id)); surface->convertToTrueColor(); return surface; }