void VideoDecoder::setSystemPalette() { const byte *vidPalette = getPalette(); byte *sysPalette = new byte[256 * 4]; for (uint16 i = 0; i < 256; i++) { sysPalette[i * 4] = vidPalette[i * 3]; sysPalette[i * 4 + 1] = vidPalette[i * 3 + 1]; sysPalette[i * 4 + 2] = vidPalette[i * 3 + 2]; sysPalette[i * 4 + 3] = 0; } g_system->getPaletteManager()->setPalette(sysPalette, 0, 256); delete[] sysPalette; }
/** * Initializes the alternate surface for swapping out as needed. * performs a colour swap for TFTD style buttons, and a palette inversion for coloured buttons * we use two seperate surfaces because it's far easier to keep track of * whether or not this surface is inverted. */ void BattlescapeButton::initSurfaces() { delete _altSurface; _altSurface = new Surface(_surface->w, _surface->h, _x, _y); _altSurface->setPalette(getPalette()); // Lock the surface _altSurface->lock(); // tftd mode: use a colour lookup table instead of simple palette inversion for our "pressed" state if (_tftdMode) { // this is our colour lookup table const int colorFrom[] = {1, 2, 3, 4, 7, 8, 31, 47, 153, 156, 159}; const int colorTo[] = {2, 3, 4, 5, 11, 10, 2, 2, 96, 9, 97}; for (int x = 0, y = 0; x < getWidth() && y < getHeight();) { Uint8 pixel = getPixel(x, y); for (int i = 0; i != sizeof(colorFrom)/sizeof(colorFrom[0]); ++i) { if (pixel == colorFrom[i]) { pixel = colorTo[i]; break; } } _altSurface->setPixelIterative(&x, &y, pixel); } } else { for (int x = 0, y = 0; x < getWidth() && y < getHeight();) { Uint8 pixel = getPixel(x, y); if (pixel > 0) { _altSurface->setPixelIterative(&x, &y, pixel + 2 * ((int)_color + 3 - (int)pixel)); } else { _altSurface->setPixelIterative(&x, &y, 0); } } } // Unlock the surface _altSurface->unlock(); }
void StaticTile::renderBitmap() { int bw = Tile::getBitmap()->getW(); int bh = Tile::getBitmap()->getH(); Color currentColor; Tile::getBitmap()->copyTo(pbitmap, 0, 0); for (int x = 0; x < bw; x++) { for (int y = 0; y < bh; y++) { currentColor.fromPixel(pbitmap->getPixel(x, y), pbitmap->getSurface()->format); pbitmap->setPixel(x, y,getPalette()->getReplacementColor(currentColor).toPixel(pbitmap->getSurface()->format)); } } }
virtual video::SColor getItemstackColor(const ItemStack &stack, Client *client) const { // Look for direct color definition const std::string &colorstring = stack.metadata.getString("color", 0); video::SColor directcolor; if (!colorstring.empty() && parseColorString(colorstring, directcolor, true)) return directcolor; // See if there is a palette Palette *palette = getPalette(stack.name, client); const std::string &index = stack.metadata.getString("palette_index", 0); if (palette && !index.empty()) return (*palette)[mystoi(index, 0, 255)]; // Fallback color return get(stack.name).color; }
void DreamWebEngine::fadeDOS() { return; // FIXME later waitForVSync(); //processEvents will be called from vsync uint8 *dst = _startPal; getPalette(dst, 0, 64); for (int fade = 0; fade < 64; ++fade) { for (int c = 0; c < 768; ++c) { //original sources decrement 768 values -> 256 colors if (dst[c]) { --dst[c]; } } setPalette(dst, 0, 64); waitForVSync(); } }
void KNThemeManager::loadTheme(const QString &themeFilePath) { QFile themeFile(themeFilePath); //Check the theme file exist or not. Open the file as ReadOnly mode. if(!themeFile.exists() || !themeFile.open(QIODevice::ReadOnly)) { return; } //Read the data and close the file. QJsonObject themeData=QJsonDocument::fromJson(themeFile.readAll()).object(); themeFile.close(); //Generate the temporary palette map and name hash list. //We don't write it to palette list to avoid the bad file. QHash<QString, QPalette> paletteList; //Parse the theme data. QStringList paletteNames=themeData.keys(); for(QStringList::iterator i=paletteNames.begin(); i!=paletteNames.end(); ++i) { //Check whether we have loaded this name before. if(paletteList.contains(*i)) { continue; } //Parse the data. parsePalette(*i, &themeData, paletteList); } //Check the new map is available or not. if(!paletteList.isEmpty()) { //Save the palette map. m_paletteList=paletteList; //Update all the widget's palette in the widget list. for(QLinkedList<QWidget *>::iterator i=m_widgetList.begin(); i!=m_widgetList.end(); ++i) { (*i)->setPalette(getPalette((*i)->objectName())); } //Emit the theme change signal. emit themeChange(); } }
void MoviePlayerSMK::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) { uint h = getHeight(); uint w = getWidth(); const Graphics::Surface *surface = decodeNextFrame(); if (!surface) return; const byte *src = (const byte *)surface->getPixels(); dst += y * pitch + x; do { memcpy(dst, src, w); dst += pitch; src += w; } while (--h); if (hasDirtyPalette()) g_system->getPaletteManager()->setPalette(getPalette(), 0, 256); }
void ArchivItem_BitmapBase::getVisibleArea(int& vx, int& vy, unsigned& vw, unsigned& vh) const { if((width_ == 0) || (height_ == 0)) { vx = vy = vw = vh = 0; return; } const ArchivItem_Palette* palette = getPalette(); if(getBBP() == 1 && !palette->hasTransparency()) { vx = vy = 0; vw = width_; vh = height_; return; } if(getBBP() == 1) doGetVisibleArea(vx, vy, vw, vh, [this, palette](auto x, auto y) { return palette->isTransparent(this->getPalettedPixel(x, y)); }); else doGetVisibleArea(vx, vy, vw, vh, [this](auto x, auto y) { return this->getPixelPtr(x, y)[3] == 0u; }); }
/** * Changes the screen's resolution. The display surface * and palette have to be reset for this to happen properly. * @param width Width in pixels. * @param height Height in pixels. */ void Screen::setResolution(int width, int height) { makeVideoFlags(); if (!_surface || (_surface && (_surface->getSurface()->format->BitsPerPixel != _bpp || _surface->getSurface()->w != BASE_WIDTH || _surface->getSurface()->h != BASE_HEIGHT))) // don't reallocate _surface if not necessary, it's a waste of CPU cycles { if (_surface) delete _surface; _surface = new Surface((int)BASE_WIDTH, (int)BASE_HEIGHT, 0, 0, Screen::isHQXEnabled() ? 32 : 8); // only HQX needs 32bpp for this surface; the OpenGL class has its own 32bpp buffer if (_surface->getSurface()->format->BitsPerPixel == 8) _surface->setPalette(deferredPalette); } SDL_SetColorKey(_surface->getSurface(), 0, 0); // turn off color key! Log(LOG_INFO) << "Attempting to set display to " << width << "x" << height << "x" << _bpp << "..."; _screen = SDL_SetVideoMode(width, height, _bpp, _flags); if (_screen == 0) { throw Exception(SDL_GetError()); } _scaleX = getWidth() / (double)BASE_WIDTH; _scaleY = getHeight() / (double)BASE_HEIGHT; if (isOpenGLEnabled()) { glOutput.init(BASE_WIDTH, BASE_HEIGHT); glOutput.linear = Options::getBool("useOpenGLSmoothing"); // setting from shader file will override this, though glOutput.set_shader(CrossPlatform::getDataFile(Options::getString("useOpenGLShader")).c_str()); glOutput.setVSync(Options::getBool("vSyncForOpenGL")); OpenGL::checkErrors = Options::getBool("checkOpenGLErrors"); } Log(LOG_INFO) << "Display set to " << getWidth() << "x" << getHeight() << "x" << (int)_screen->format->BitsPerPixel << "."; if (_screen->format->BitsPerPixel == 8) { setPalette(getPalette()); } }
void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint pitch) { uint h = getHeight(); uint w = getWidth(); const Graphics::Surface *surface = decodeNextFrame(); byte *src = (byte *)surface->pixels; if (hasDirtyPalette()) _vm->setPaletteFromPtr(getPalette(), 256); if (_vm->_game.features & GF_16BIT_COLOR) { dst += y * pitch + x * 2; do { for (uint i = 0; i < w; i++) { uint16 color = READ_LE_UINT16(_vm->_hePalettes + _vm->_hePaletteSlot + 768 + src[i] * 2); switch (dstType) { case kDstScreen: WRITE_UINT16(dst + i * 2, color); break; case kDstResource: WRITE_LE_UINT16(dst + i * 2, color); break; default: error("copyFrameToBuffer: Unknown dstType %d", dstType); } } dst += pitch; src += w; } while (--h); } else { dst += y * pitch + x; do { memcpy(dst, src, w); dst += pitch; src += w; } while (--h); } }
int Screen::equalizePalette(const byte palette[PALETTE_SIZE]) { int total = 0; byte tempPalette[PALETTE_SIZE]; getPalette(tempPalette); // For any palette component that doesn't already match the given destination // palette, change by 1 towards the reference palette component for (int idx = 0; idx < PALETTE_SIZE; ++idx) { if (tempPalette[idx] > palette[idx]) { tempPalette[idx] = MAX((int)palette[idx], (int)tempPalette[idx] - 4); ++total; } else if (tempPalette[idx] < palette[idx]) { tempPalette[idx] = MIN((int)palette[idx], (int)tempPalette[idx] + 4); ++total; } } if (total > 0) // Palette changed, so reload it setPalette(tempPalette); return total; }
/** * Draws a text string on the surface. * @param x X coordinate in pixels. * @param y Y coordinate in pixels. * @param s Character string to draw. * @param color Color of string. */ void Surface::drawString(Sint16 x, Sint16 y, const char *s, Uint8 color) { stringColor(_surface, x, y, s, Palette::getRGBA(getPalette(), color)); }
/** * Draws a filled polygon on the surface. * @param x Array of x coordinates. * @param y Array of y coordinates. * @param n Number of points. * @param color Color of the polygon. */ void Surface::drawPolygon(Sint16 *x, Sint16 *y, int n, Uint8 color) { filledPolygonColor(_surface, x, y, n, Palette::getRGBA(getPalette(), color)); }
/** * Draws a filled circle on the surface. * @param x X coordinate in pixels. * @param y Y coordinate in pixels. * @param r Radius in pixels. * @param color Color of the circle. */ void Surface::drawCircle(Sint16 x, Sint16 y, Sint16 r, Uint8 color) { filledCircleColor(_surface, x, y, r, Palette::getRGBA(getPalette(), color)); }
/** * Draws a line on the surface. * @param x1 Start x coordinate in pixels. * @param y1 Start y coordinate in pixels. * @param x2 End x coordinate in pixels. * @param y2 End y coordinate in pixels. * @param color Color of the line. */ void Surface::drawLine(Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 color) { lineColor(_surface, x1, y1, x2, y2, Palette::getRGBA(getPalette(), color)); }
void TVDemo::colors() { TColorGroup &group1 = *new TColorGroup("Desktop") + *new TColorItem("Color", 1)+ *new TColorGroup("Menus") + *new TColorItem("Normal", 2)+ *new TColorItem("Disabled", 3)+ *new TColorItem("Shortcut", 4)+ *new TColorItem("Selected", 5)+ *new TColorItem("Selected disabled", 6)+ *new TColorItem("Shortcut selected", 7 ); TColorGroup &group2 = *new TColorGroup("Dialogs/Calc") + *new TColorItem("Frame/background", 33)+ *new TColorItem("Frame icons", 34)+ *new TColorItem("Scroll bar page", 35)+ *new TColorItem("Scroll bar icons", 36)+ *new TColorItem("Static text", 37)+ *new TColorItem("Label normal", 38)+ *new TColorItem("Label selected", 39)+ *new TColorItem("Label shortcut", 40 ); TColorItem &item_coll1 = *new TColorItem("Button normal", 41)+ *new TColorItem("Button default", 42)+ *new TColorItem("Button selected", 43)+ *new TColorItem("Button disabled", 44)+ *new TColorItem("Button shortcut", 45)+ *new TColorItem("Button shadow", 46)+ *new TColorItem("Cluster normal", 47)+ *new TColorItem("Cluster selected", 48)+ *new TColorItem("Cluster shortcut", 49 ); TColorItem &item_coll2 = *new TColorItem("Input normal", 50)+ *new TColorItem("Input selected", 51)+ *new TColorItem("Input arrow", 52)+ *new TColorItem("History button", 53)+ *new TColorItem("History sides", 54)+ *new TColorItem("History bar page", 55)+ *new TColorItem("History bar icons", 56)+ *new TColorItem("List normal", 57)+ *new TColorItem("List focused", 58)+ *new TColorItem("List selected", 59)+ *new TColorItem("List divider", 60)+ *new TColorItem("Information pane", 61 ); group2 = group2 + item_coll1 + item_coll2; TColorGroup &group3 = *new TColorGroup("Viewer") + *new TColorItem("Frame passive", 8)+ *new TColorItem("Frame active", 9)+ *new TColorItem("Frame icons", 10)+ *new TColorItem("Scroll bar page", 11)+ *new TColorItem("Scroll bar icons", 12)+ *new TColorItem("Text", 13)+ *new TColorGroup("Puzzle")+ *new TColorItem("Frame passive", 8)+ *new TColorItem("Frame active", 9)+ *new TColorItem("Frame icons", 10)+ *new TColorItem("Scroll bar page", 11)+ *new TColorItem("Scroll bar icons", 12)+ *new TColorItem("Normal text", 13)+ *new TColorItem("Highlighted text", 14 ); TColorGroup &group4 = *new TColorGroup("Calendar") + *new TColorItem("Frame passive", 16)+ *new TColorItem("Frame active", 17)+ *new TColorItem("Frame icons", 18)+ *new TColorItem("Scroll bar page", 19)+ *new TColorItem("Scroll bar icons", 20)+ *new TColorItem("Normal text", 21)+ *new TColorItem("Current day", 22)+ *new TColorGroup("Ascii table") + *new TColorItem("Frame passive", 24)+ *new TColorItem("Frame active", 25)+ *new TColorItem("Frame icons", 26)+ *new TColorItem("Scroll bar page", 27)+ *new TColorItem("Scroll bar icons", 28)+ *new TColorItem("Text", 29 ); TColorGroup &group5 = group1 + group2 + group3 + group4; TColorDialog *c = new TColorDialog((TPalette*)0, &group5 ); if( validView( c ) != 0 ) { c->helpCtx = hcOCColorsDBox; // set context help constant c->setData(&getPalette()); if( deskTop->execView( c ) != cmCancel ) { getPalette() = *(c->pal); deskTop->setState( sfVisible, False ); deskTop->setState( sfVisible, True ); } destroy( c ); } }
/** * Resets the screen surfaces based on the current display options, * as they don't automatically take effect. * @param resetVideo Reset display surface. */ void Screen::resetDisplay(bool resetVideo) { int width = Options::displayWidth; int height = Options::displayHeight; #ifdef __linux__ Uint32 oldFlags = _flags; #endif makeVideoFlags(); if (!_surface || (_surface && (_surface->getSurface()->format->BitsPerPixel != _bpp || _surface->getSurface()->w != _baseWidth || _surface->getSurface()->h != _baseHeight))) // don't reallocate _surface if not necessary, it's a waste of CPU cycles { if (_surface) delete _surface; _surface = new Surface(_baseWidth, _baseHeight, 0, 0, Screen::is32bitEnabled() ? 32 : 8); // only HQX needs 32bpp for this surface; the OpenGL class has its own 32bpp buffer if (_surface->getSurface()->format->BitsPerPixel == 8) _surface->setPalette(deferredPalette); } SDL_SetColorKey(_surface->getSurface(), 0, 0); // turn off color key! if (resetVideo || _screen->format->BitsPerPixel != _bpp) { #ifdef __linux__ // Workaround for segfault when switching to opengl if (!(oldFlags & SDL_OPENGL) && (_flags & SDL_OPENGL)) { Uint8 cursor = 0; char *_oldtitle = 0; SDL_WM_GetCaption(&_oldtitle, NULL); std::string title(_oldtitle); SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_InitSubSystem(SDL_INIT_VIDEO); SDL_ShowCursor(SDL_ENABLE); SDL_EnableUNICODE(1); SDL_WM_SetCaption(title.c_str(), 0); SDL_SetCursor(SDL_CreateCursor(&cursor, &cursor, 1,1,0,0)); } #endif Log(LOG_INFO) << "Attempting to set display to " << width << "x" << height << "x" << _bpp << "..."; _screen = SDL_SetVideoMode(width, height, _bpp, _flags); if (_screen == 0) { Log(LOG_ERROR) << SDL_GetError(); Log(LOG_INFO) << "Attempting to set display to default resolution..."; _screen = SDL_SetVideoMode(640, 400, _bpp, _flags); if (_screen == 0) { throw Exception(SDL_GetError()); } } Log(LOG_INFO) << "Display set to " << getWidth() << "x" << getHeight() << "x" << (int)_screen->format->BitsPerPixel << "."; } else { clear(); } Options::displayWidth = getWidth(); Options::displayHeight = getHeight(); _scaleX = getWidth() / (double)_baseWidth; _scaleY = getHeight() / (double)_baseHeight; _clear.x = 0; _clear.y = 0; _clear.w = getWidth(); _clear.h = getHeight(); double pixelRatioY = 1.0; if (Options::nonSquarePixelRatio && !Options::allowResize) { pixelRatioY = 1.2; } bool cursorInBlackBands; if (!Options::keepAspectRatio) { cursorInBlackBands = false; } else if (Options::fullscreen) { cursorInBlackBands = Options::cursorInBlackBandsInFullscreen; } else if (!Options::borderless) { cursorInBlackBands = Options::cursorInBlackBandsInWindow; } else { cursorInBlackBands = Options::cursorInBlackBandsInBorderlessWindow; } if (_scaleX > _scaleY && Options::keepAspectRatio) { int targetWidth = (int)floor(_scaleY * (double)_baseWidth); _topBlackBand = _bottomBlackBand = 0; _leftBlackBand = (getWidth() - targetWidth) / 2; if (_leftBlackBand < 0) { _leftBlackBand = 0; } _rightBlackBand = getWidth() - targetWidth - _leftBlackBand; _cursorTopBlackBand = 0; if (cursorInBlackBands) { _scaleX = _scaleY; _cursorLeftBlackBand = _leftBlackBand; } else { _cursorLeftBlackBand = 0; } } else if (_scaleY > _scaleX && Options::keepAspectRatio) { int targetHeight = (int)floor(_scaleX * (double)_baseHeight * pixelRatioY); _topBlackBand = (getHeight() - targetHeight) / 2; if (_topBlackBand < 0) { _topBlackBand = 0; } _bottomBlackBand = getHeight() - targetHeight - _topBlackBand; if (_bottomBlackBand < 0) { _bottomBlackBand = 0; } _leftBlackBand = _rightBlackBand = 0; _cursorLeftBlackBand = 0; if (cursorInBlackBands) { _scaleY = _scaleX; _cursorTopBlackBand = _topBlackBand; } else { _cursorTopBlackBand = 0; } } else { _topBlackBand = _bottomBlackBand = _leftBlackBand = _rightBlackBand = _cursorTopBlackBand = _cursorLeftBlackBand = 0; } if (isOpenGLEnabled()) { #ifndef __NO_OPENGL glOutput.init(_baseWidth, _baseHeight); glOutput.linear = Options::useOpenGLSmoothing; // setting from shader file will override this, though glOutput.set_shader(FileMap::getFilePath(Options::useOpenGLShader).c_str()); glOutput.setVSync(Options::vSyncForOpenGL); OpenGL::checkErrors = Options::checkOpenGLErrors; #endif } if (_screen->format->BitsPerPixel == 8) { setPalette(getPalette()); } }
/** * Draws a filled ellipse on the surface. * @param x X coordinate in pixels. * @param y Y coordinate in pixels. * @param rx Radius in pixels on X axis. * @param ry Radius in pixels on Y axis. * @param color Color of the circle. */ void Surface::drawEllipse(Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 color) { filledEllipseColor(_surface, x, y, rx, ry, Palette::getRGBA(getPalette(), color)); }
void VideoDecoder::setSystemPalette() { g_system->getPaletteManager()->setPalette(getPalette(), 0, 256); }
/** * Draws the view of all the facilities in the base, connectors * between them and crafts landed in hangars. */ void BaseView::draw() { Surface::draw(); // Draw grid squares for (int x = 0; x < 8; ++x) { for (int y = 0; y < 8; ++y) { Surface *frame = _texture->getFrame(0); frame->setX(x * GRID_SIZE); frame->setY(y * GRID_SIZE); frame->blit(this); } } std::vector<Craft*>::iterator craft = _base->getCrafts()->begin(); for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i) { // Draw facility shape int num = 0; for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); ++y) { for (int x = (*i)->getX(); x < (*i)->getX() + (*i)->getRules()->getSize(); ++x) { Surface *frame; if ((*i)->getBuildTime() == 0) frame = _texture->getFrame((*i)->getRules()->getSpriteShape() + num); else frame = _texture->getFrame((*i)->getRules()->getSpriteShape() + num + 2 + (*i)->getRules()->getSize()); frame->setX(x * GRID_SIZE); frame->setY(y * GRID_SIZE); frame->blit(this); num++; } } } for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i) { // Draw connectors if ((*i)->getBuildTime() == 0) { // Facilities to the right int x = (*i)->getX() + (*i)->getRules()->getSize(); if (x < BASE_SIZE) { for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); ++y) { if (_facilities[x][y] != 0 && _facilities[x][y]->getBuildTime() == 0) { Surface *frame = _texture->getFrame(7); frame->setX(x * GRID_SIZE - GRID_SIZE / 2); frame->setY(y * GRID_SIZE); frame->blit(this); } } } // Facilities to the bottom int y = (*i)->getY() + (*i)->getRules()->getSize(); if (y < BASE_SIZE) { for (int x = (*i)->getX(); x < (*i)->getX() + (*i)->getRules()->getSize(); ++x) { if (_facilities[x][y] != 0 && _facilities[x][y]->getBuildTime() == 0) { Surface *frame = _texture->getFrame(8); frame->setX(x * GRID_SIZE); frame->setY(y * GRID_SIZE - GRID_SIZE / 2); frame->blit(this); } } } } } for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i) { // Draw facility graphic int num = 0; for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); ++y) { for (int x = (*i)->getX(); x < (*i)->getX() + (*i)->getRules()->getSize(); ++x) { if ((*i)->getRules()->getSize() == 1) { Surface *frame = _texture->getFrame((*i)->getRules()->getSpriteFacility() + num); frame->setX(x * GRID_SIZE); frame->setY(y * GRID_SIZE); frame->blit(this); } num++; } } // Draw crafts if ((*i)->getBuildTime() == 0 && (*i)->getRules()->getCrafts() > 0 && craft != _base->getCrafts()->end()) { Surface *frame = _texture->getFrame((*craft)->getRules()->getSprite() + 33); frame->setX((*i)->getX() * GRID_SIZE + ((*i)->getRules()->getSize() - 1) * GRID_SIZE / 2 + 2); frame->setY((*i)->getY() * GRID_SIZE + ((*i)->getRules()->getSize() - 1) * GRID_SIZE / 2 - 4); frame->blit(this); ++craft; } // Draw time remaining if ((*i)->getBuildTime() > 0) { Text *text = new Text(GRID_SIZE * (*i)->getRules()->getSize(), 16, 0, 0); text->setPalette(getPalette()); text->setFonts(_big, _small); text->setX((*i)->getX() * GRID_SIZE); text->setY((*i)->getY() * GRID_SIZE + (GRID_SIZE * (*i)->getRules()->getSize() - 16) / 2); text->setBig(); std::wstringstream ss; ss << (*i)->getBuildTime(); text->setAlign(ALIGN_CENTER); text->setColor(Palette::blockOffset(13)+5); text->setText(ss.str()); text->blit(this); delete text; } } }
void TsubtitlePGSParser::parseObject(Tbitdata &bitData, int nSize) { SHORT object_id = bitData.readShort(); BYTE m_sequence_desc; if (m_pCurrentObject == NULL) { return; } //if (m_pCurrentObject->m_nState == 0) for (TcompositionObjects::iterator c = m_compositionObjects.begin(); c != m_compositionObjects.end(); c++) { if ((*c) == m_pCurrentObject || (*c)->m_nWindows == 0) { continue; } for (int i = 0; i < (*c)->m_nWindows; i++) { if (object_id == (*c)->m_Windows[i].m_objectId && (*c)->m_Windows[i].m_rtStop == INVALID_TIME && (*c)->m_Windows[i].data[0].size() > 0) { (*c)->m_Windows[i].m_rtStop = m_pCurrentObject->m_rtTime; #if DEBUG_PGS char_t rtString[32], rtString2[32]; rt2Str((*c)->m_Windows[i].m_rtStart, rtString); rt2Str((*c)->m_Windows[i].m_rtStop, rtString2); DPRINTF(_l("[%d] ODS From comp %d stop Object[%d]:id %d WindowId:%d (%d x %d at %d,%d) %s %s -> %s"), m_pCurrentObject->m_compositionNumber, (*c)->m_compositionNumber, i, (*c)->m_Windows[i].m_objectId, (*c)->m_Windows[i].m_windowId, (*c)->m_Windows[i].m_width, (*c)->m_Windows[i].m_height, (*c)->m_Windows[i].m_horizontal_position, (*c)->m_Windows[i].m_vertical_position, ((*c)->m_Windows[i].data[0].size() > 0) ? _l("has data") : _l("no data"), rtString, rtString2); #endif } } } m_pCurrentObject->m_version_number = bitData.readByte(); TwindowDefinition *pWindow = NULL; int i = 0; for (i = 0; i < m_pCurrentObject->m_nWindows; i++) { if (m_pCurrentObject->m_Windows[i].m_objectId == object_id) { pWindow = &m_pCurrentObject->m_Windows[i]; break; } } if (pWindow == NULL) { return; } // sequence_descriptor 2 bit first_in_sequence_flag, last_in_sequence_flag m_sequence_desc = bitData.readByte(); if ((m_sequence_desc != 0xc0) && (m_sequence_desc != 0x80)) { if ((m_sequence_desc & 0x40) != 0) { pWindow->dataIndex = 1; } } #if DEBUG_PGS DPRINTF(_l("[%d] ODS Object[%d]:id %d windowId:%d has picture data (%d x %d at %d,%d)"), m_pCurrentObject->m_compositionNumber, i, object_id, pWindow->m_windowId, pWindow->m_width, pWindow->m_height, pWindow->m_horizontal_position, pWindow->m_vertical_position); #endif m_nOSDCount = 0; DWORD object_data_length = (DWORD)bitData.getBits(24); m_pCurrentObject->m_data_length = object_data_length; if (m_sequence_desc == 0xc0 && (nSize - object_data_length) != 7) { DPRINTF(_l("TsubtitlePGSParser::parseObject unexpected picture size")); if (object_data_length > (DWORD)(nSize - 7)) { object_data_length = (DWORD)(nSize - 7); } } //m_pCurrentObject->m_Windows[windowId].m_objectId = object_id; /*m_pCurrentObject->m_width = */bitData.readShort(); /*m_pCurrentObject->m_height = */ bitData.readShort(); pWindow->data[pWindow->dataIndex].reserve(object_data_length - 4); pWindow->data[pWindow->dataIndex].append(bitData.wordpointer, nSize - 11); #if DEBUG_PGS_PARSER DPRINTF(_l("TsubtitlePGSParser::parseObject Object size (%d)"), nSize - 11); #endif bitData.skipBytes(nSize - 11); if ((m_sequence_desc & 0x40) != 0) { pWindow->dataIndex = 1; } getPalette(m_pCurrentObject); }