本文整理汇总了C++中graphics::Surface类的典型用法代码示例。如果您正苦于以下问题:C++ Surface类的具体用法?C++ Surface怎么用?C++ Surface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Surface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
Graphics::Surface *Renderer::getScreenshot() {
Graphics::Surface *s = new Graphics::Surface();
s->create(kOriginalWidth, kOriginalHeight, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
glReadPixels(0, 0, kOriginalWidth, kOriginalHeight, GL_RGBA, GL_UNSIGNED_BYTE, s->pixels);
return s;
}
开发者ID:YakBizzarro,项目名称:residual,代码行数:8,代码来源:gfx.cpp
示例2: vcReadNextWord
void AGOSEngine::vc61() {
uint16 a = vcReadNextWord();
byte *src, *dst, *dstPtr;
uint h, tmp;
Graphics::Surface *screen = _system->lockScreen();
dstPtr = (byte *)screen->getPixels();
if (a == 6) {
src = _curVgaFile2 + 800;
dst = dstPtr;
for (int i = 0; i < _screenHeight; i++) {
memcpy(dst, src, _screenWidth);
src += 320;
dst += screen->pitch;
}
tmp = 4 - 1;
} else {
tmp = a - 1;
}
src = _curVgaFile2 + 3840 * 16 + 3360;
while (tmp--)
src += 1536 * 16 + 1712;
src += 800;
if (a != 5) {
dst = dstPtr + 23 * screen->pitch + 88;
for (h = 0; h < 177; h++) {
memcpy(dst, src, 144);
src += 144;
dst += screen->pitch;
}
if (a != 6) {
_system->unlockScreen();
return;
}
src = _curVgaFile2 + 9984 * 16 + 15344;
}
dst = dstPtr + 157 * screen->pitch + 56;
for (h = 0; h < 17; h++) {
memcpy(dst, src, 208);
src += 208;
dst += screen->pitch;
}
_system->unlockScreen();
if (a == 6)
fullFade();
}
开发者ID:MaddTheSane,项目名称:scummvm,代码行数:57,代码来源:vga_ww.cpp
示例3: setCursor
void EventsClass::setCursor(GfxSurface &cursor) {
Graphics::Surface s = cursor.lockSurface();
const byte *cursorData = (const byte *)s.getPixels();
CursorMan.replaceCursor(cursorData, cursor.getBounds().width(), cursor.getBounds().height(),
cursor._centroid.x, cursor._centroid.y, cursor._transColor);
_lastCursor = CURSOR_NONE;
}
开发者ID:dergunov,项目名称:scummvm,代码行数:9,代码来源:events.cpp
示例4: renderImageToBackground
void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY) {
Graphics::Surface surface;
readImageToSurface(fileName, surface);
uint16 keycolor = *(uint16 *)surface.getBasePtr(keyX, keyY);
blitSurfaceToBkg(surface, destX, destY, keycolor);
surface.free();
}
开发者ID:superg,项目名称:scummvm,代码行数:9,代码来源:render_manager.cpp
示例5: sfLoadMouseCursor
int16 ScriptFunctions::sfLoadMouseCursor(int16 argc, int16 *argv) {
PictureResource *flex = _vm->_res->getPicture(argv[2]);
if (flex) {
Graphics::Surface *surf = flex->getPicture();
CursorMan.replaceCursor(surf->getPixels(), surf->getWidth(), surf->getHeight(), argv[1], argv[0], 0);
_vm->_res->freeResource(flex);
}
return 0;
}
开发者ID:project-cabal,项目名称:cabal,代码行数:9,代码来源:scriptfuncs.cpp
示例6: draw
void SoundLevel::draw(const Common::Rect &r) {
Common::Rect levelRect(_bounds.right + (8 * (_soundLevel - 12)), _bounds.top, _bounds.right, _bounds.bottom);
levelRect = r.findIntersectingRect(levelRect);
if (!levelRect.isEmpty()) {
Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
screen->fillRect(levelRect, g_system->getScreenFormat().RGBToColor(0, 0, 0));
}
}
开发者ID:AlbanBedel,项目名称:scummvm,代码行数:9,代码来源:elements.cpp
示例7: cmdDumpImage
bool Console::cmdDumpImage(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Use %s <TGA/TGZ name> to dump a Z-Vision TGA/TGZ image into a regular BMP image\n", argv[0]);
return true;
}
Common::String fileName = argv[1];
if (!fileName.hasSuffix(".tga")) {
debugPrintf("%s is not an image file", argv[1]);
}
Common::File f;
if (!_engine->getSearchManager()->openFile(f, argv[1])) {
warning("File not found: %s", argv[1]);
return true;
}
Graphics::Surface surface;
_engine->getRenderManager()->readImageToSurface(argv[1], surface, false);
// Open file
Common::DumpFile out;
fileName.setChar('b', fileName.size() - 3);
fileName.setChar('m', fileName.size() - 2);
fileName.setChar('p', fileName.size() - 1);
out.open(fileName);
// Write BMP header
out.writeByte('B');
out.writeByte('M');
out.writeUint32LE(surface.h * surface.pitch + 54);
out.writeUint32LE(0);
out.writeUint32LE(54);
out.writeUint32LE(40);
out.writeUint32LE(surface.w);
out.writeUint32LE(surface.h);
out.writeUint16LE(1);
out.writeUint16LE(16);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
// Write pixel data to BMP
out.write(surface.getPixels(), surface.pitch * surface.h);
out.flush();
out.close();
surface.free();
return true;
}
开发者ID:Cruel,项目名称:scummvm,代码行数:57,代码来源:console.cpp
示例8: drawInventoryImage
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(surface->getPixels(), surface->pitch, rect->left, rect->top, surface->w, surface->h);
delete mhkSurface;
}
开发者ID:MaddTheSane,项目名称:scummvm,代码行数:9,代码来源:riven_graphics.cpp
示例9: MIN
void MinigameBbAnt::scale2x(int x, int y) {
Graphics::Surface *surface = _vm->_screen->_surface;
int srcX = x + 14, srcY = y + 14;
int srcW = kScaleDim, srcH = kScaleDim;
if (srcX < 0) {
srcW += srcX;
srcX = 0;
}
if (srcY < 0) {
srcH += srcY;
srcY = 0;
}
if (srcX + srcW >= 320)
srcW = 320 - srcX - 1;
if (srcY + srcH >= 240)
srcH = 240 - srcY - 1;
for (int yc = 0; yc < srcH; ++yc) {
byte *src = (byte*)surface->getBasePtr(srcX, srcY + yc);
memcpy(&_scaleBuf[yc * kScaleDim], src, srcW);
}
int dstX = x, dstY = y;
int dstW = 2 * kScaleDim, dstH = 2 * kScaleDim;
if (dstX < 0) {
dstW += dstX;
dstX = 0;
}
if (dstY < 0) {
dstH += dstY;
dstY = 0;
}
if (dstX + dstW >= 320)
dstW = 320 - dstX - 1;
if (dstY + dstH >= 240)
dstH = 240 - dstY - 1;
int w = MIN(srcW * 2, dstW), h = MIN(srcH * 2, dstH);
for (int yc = 0; yc < h; ++yc) {
byte *src = _scaleBuf + kScaleDim * (yc / 2);
byte *dst = (byte*)surface->getBasePtr(dstX, dstY + yc);
for (int xc = 0; xc < w; ++xc)
dst[xc] = src[xc / 2];
}
}
开发者ID:33d,项目名称:scummvm,代码行数:56,代码来源:bbant.cpp
示例10: renderFrame
bool AVISurface::renderFrame() {
// Check there's a frame ready for display
if (!_decoder->needsUpdate())
return false;
// Make a copy of each decoder's video frame
for (int idx = 0; idx < _streamCount; ++idx) {
const Graphics::Surface *frame;
if (idx == 0) {
frame = _decoder->decodeNextFrame();
if (!_movieFrameSurface[0])
_movieFrameSurface[0] = new Graphics::ManagedSurface(_decoder->getWidth(), _decoder->getHeight(),
g_system->getScreenFormat());
copyMovieFrame(*frame, *_movieFrameSurface[0]);
} else {
frame = _decoder->decodeNextTransparency();
if (!_movieFrameSurface[1])
_movieFrameSurface[1] = new Graphics::ManagedSurface(_decoder->getWidth(), _decoder->getHeight(),
Graphics::PixelFormat::createFormatCLUT8());
_movieFrameSurface[1]->blitFrom(*frame);
}
}
if (!_framePixels) {
if (_videoSurface->lock()) {
// Blit the frame directly to the video surface
assert(_streamCount == 1);
_videoSurface->blitFrom(Point(0, 0), &_movieFrameSurface[0]->rawSurface());
_videoSurface->unlock();
}
} else {
const Graphics::Surface &frameSurface = _movieFrameSurface[0]->rawSurface();
_videoSurface->lock();
if (frameSurface.format.bytesPerPixel == 1) {
// For paletted 8-bit surfaces, we need to convert it to 16-bit,
// since the blitting method we're using doesn't support palettes
Graphics::Surface *s = frameSurface.convertTo(g_system->getScreenFormat(),
_decoder->getPalette());
_videoSurface->getRawSurface()->blitFrom(*s);
s->free();
delete s;
} else {
_videoSurface->getRawSurface()->blitFrom(frameSurface);
}
_videoSurface->unlock();
}
return false;
}
开发者ID:DrItanium,项目名称:scummvm,代码行数:56,代码来源:avi_surface.cpp
示例11: transBlitFromUnscaled
void Surface::transBlitFromUnscaled(const Graphics::Surface &src, const Common::Point &pt,
bool flipped, int overrideColor) {
Common::Rect drawRect(0, 0, src.w, src.h);
Common::Rect destRect(pt.x, pt.y, pt.x + src.w, pt.y + src.h);
// Clip the display area to on-screen
if (!clip(drawRect, destRect))
// It's completely off-screen
return;
if (flipped)
drawRect = Common::Rect(src.w - drawRect.right, src.h - drawRect.bottom,
src.w - drawRect.left, src.h - drawRect.top);
Common::Point destPt(destRect.left, destRect.top);
addDirtyRect(Common::Rect(destPt.x, destPt.y, destPt.x + drawRect.width(),
destPt.y + drawRect.height()));
switch (src.format.bytesPerPixel) {
case 1:
// 8-bit palettized: Draw loop
assert(_surface.format.bytesPerPixel == 1); // Security check
for (int yp = 0; yp < drawRect.height(); ++yp) {
const byte *srcP = (const byte *)src.getBasePtr(
flipped ? drawRect.right - 1 : drawRect.left, drawRect.top + yp);
byte *destP = (byte *)getBasePtr(destPt.x, destPt.y + yp);
for (int xp = 0; xp < drawRect.width(); ++xp, ++destP) {
if (*srcP != TRANSPARENCY)
*destP = overrideColor ? overrideColor : *srcP;
srcP = flipped ? srcP - 1 : srcP + 1;
}
}
break;
case 2:
// 3DO 15-bit RGB565: Draw loop
assert(_surface.format.bytesPerPixel == 2); // Security check
for (int yp = 0; yp < drawRect.height(); ++yp) {
const uint16 *srcP = (const uint16 *)src.getBasePtr(
flipped ? drawRect.right - 1 : drawRect.left, drawRect.top + yp);
uint16 *destP = (uint16 *)getBasePtr(destPt.x, destPt.y + yp);
for (int xp = 0; xp < drawRect.width(); ++xp, ++destP) {
if (*srcP) // RGB 0, 0, 0 -> transparent on 3DO
*destP = *srcP; // overrideColor ? overrideColor : *srcP;
srcP = flipped ? srcP - 1 : srcP + 1;
}
}
break;
default:
error("Surface: unsupported bytesperpixel");
break;
}
}
开发者ID:winterheart,项目名称:scummvm,代码行数:56,代码来源:surface.cpp
示例12:
Graphics::Surface *OSystem_Android::lockScreen() {
ENTER();
GLTHREADCHECK;
Graphics::Surface *surface = _game_texture->surface();
assert(surface->getPixels());
return surface;
}
开发者ID:Akz-,项目名称:residual,代码行数:10,代码来源:gfx.cpp
示例13: displayMessageOnOSD
void OpenGLGraphicsManager::displayMessageOnOSD(const char *msg) {
#ifdef USE_OSD
// HACK: Actually no client code should use graphics functions from
// another thread. But the MT-32 emulator still does, thus we need to
// make sure this doesn't happen while a updateScreen call is done.
Common::StackLock lock(_osdMutex);
// Slip up the lines.
Common::Array<Common::String> osdLines;
Common::StringTokenizer tokenizer(msg, "\n");
while (!tokenizer.empty()) {
osdLines.push_back(tokenizer.nextToken());
}
// Do the actual drawing like the SDL backend.
const Graphics::Font *font = getFontOSD();
Graphics::Surface *dst = _osd->getSurface();
_osd->fill(0);
_osd->flagDirty();
// Determine a rect which would contain the message string (clipped to the
// screen dimensions).
const int vOffset = 6;
const int lineSpacing = 1;
const int lineHeight = font->getFontHeight() + 2 * lineSpacing;
int width = 0;
int height = lineHeight * osdLines.size() + 2 * vOffset;
for (uint i = 0; i < osdLines.size(); i++) {
width = MAX(width, font->getStringWidth(osdLines[i]) + 14);
}
// Clip the rect
width = MIN<int>(width, dst->w);
height = MIN<int>(height, dst->h);
int dstX = (dst->w - width) / 2;
int dstY = (dst->h - height) / 2;
// Draw a dark gray rect.
const uint32 color = dst->format.RGBToColor(40, 40, 40);
dst->fillRect(Common::Rect(dstX, dstY, dstX + width, dstY + height), color);
// Render the message, centered, and in white
const uint32 white = dst->format.RGBToColor(255, 255, 255);
for (uint i = 0; i < osdLines.size(); ++i) {
font->drawString(dst, osdLines[i],
dstX, dstY + i * lineHeight + vOffset + lineSpacing, width,
white, Graphics::kTextAlignCenter);
}
// Init the OSD display parameters.
_osdAlpha = kOSDInitialAlpha;
_osdFadeStartTime = g_system->getMillis() + kOSDFadeOutDelay;
#endif
}
开发者ID:johndoe123,项目名称:scummvm,代码行数:55,代码来源:opengl-graphics.cpp
示例14: getRGBAPixelFormat
Graphics::Surface *OpenGLSDriver::getViewportScreenshot() const {
Graphics::Surface *s = new Graphics::Surface();
s->create(_viewport.width(), _viewport.height(), getRGBAPixelFormat());
glReadPixels(_viewport.left, g_system->getHeight() - _viewport.bottom, _viewport.width(), _viewport.height(),
GL_RGBA, GL_UNSIGNED_BYTE, s->getPixels());
flipVertical(s);
return s;
}
开发者ID:Botje,项目名称:residualvm,代码行数:11,代码来源:opengls.cpp
示例15: drawImageRect
void RivenGraphics::drawImageRect(uint16 id, Common::Rect srcRect, Common::Rect dstRect) {
// Draw tBMP id from srcRect to dstRect
Graphics::Surface *surface = findImage(id)->getSurface();
assert(srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height());
for (uint16 i = 0; i < srcRect.height(); i++)
memcpy(_mainScreen->getBasePtr(dstRect.left, i + dstRect.top), surface->getBasePtr(srcRect.left, i + srcRect.top), srcRect.width() * surface->format.bytesPerPixel);
_dirtyScreen = true;
}
开发者ID:hchen1014,项目名称:scummvm,代码行数:11,代码来源:riven_graphics.cpp
示例16:
Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) {
Graphics::Surface *tmp = new Graphics::Surface;
if (_font) {
int16 w = _font->getStringWidth(str);
if (w && w < 1024) {
tmp->create(w, _font->getFontHeight(), _engine->_resourcePixelFormat);
drawString(tmp, str, 0, 0, w, color);
}
}
return tmp;
}
开发者ID:Marisa-Chan,项目名称:scummvm,代码行数:11,代码来源:truetype_font.cpp
示例17: drawRect
void RivenGraphics::drawRect(Common::Rect rect, bool active) {
// Useful with debugging. Shows where hotspots are on the screen and whether or not they're active.
Graphics::Surface *screen = _vm->_system->lockScreen();
if (active)
screen->frameRect(rect, _pixelFormat.RGBToColor(0, 255, 0));
else
screen->frameRect(rect, _pixelFormat.RGBToColor(255, 0, 0));
_vm->_system->unlockScreen();
}
开发者ID:hchen1014,项目名称:scummvm,代码行数:11,代码来源:riven_graphics.cpp
示例18: drawFrameWithMaskAndScale
void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask, int32 scale) {
debugC(5, kDebugAnim, "drawFrameWithMaskAndScale(surface, %d, %d, %d, %d, mask, %d)", frame, xx, yy, zz, scale);
int16 dataFrame = frame;
if (_frames[frame]._ref != -1)
dataFrame = _frames[frame]._ref;
int16 rectX = _frames[frame]._x2 - _frames[frame]._x1;
int16 rectY = _frames[frame]._y2 - _frames[frame]._y1;
int16 finalWidth = rectX * scale / 1024;
int16 finalHeight = rectY * scale / 1024;
// compute final x1, y1, x2, y2
int16 xx1 = xx + _x1 + _frames[frame]._x1 * scale / 1024;
int16 yy1 = yy + _y1 + _frames[frame]._y1 * scale / 1024;
int16 xx2 = xx1 + finalWidth;
int16 yy2 = yy1 + finalHeight;
int16 w = _frames[frame]._x2 - _frames[frame]._x1;
_vm->addDirtyRect(xx1, yy1, xx2, yy2);
int32 destPitch = surface.getPitch();
int32 destPitchMask = mask->getWidth();
uint8 *c = _frames[dataFrame]._data;
uint8 *curRow = (uint8 *)surface.getPixels();
uint8 *curRowMask = mask->getDataPtr();
bool shadowFlag = false;
if (strstr(_name, "SHADOW"))
shadowFlag = true;
for (int16 y = yy1; y < yy2; y++) {
for (int16 x = xx1; x < xx2; x++) {
if (x < 0 || x >= 1280 || y < 0 || y >= 400)
continue;
uint8 *cur = curRow + x + y * destPitch;
uint8 *curMask = curRowMask + x + y * destPitchMask;
// find the good c
int16 xs = (x - xx1) * 1024 / scale;
int16 ys = (y - yy1) * 1024 / scale;
uint8 *cc = &c[ys * w + xs];
if (*cc && ((*curMask) >= zz)) {
if (shadowFlag)
*cur = _vm->getShadowLUT()[*cur];
else
*cur = *cc;
}
}
}
}
开发者ID:project-cabal,项目名称:cabal,代码行数:54,代码来源:anim.cpp
示例19: run
int MenuSystem::run() {
//debug("MenuSystem::run()");
_background = new Graphics::Surface();
_background->create(640, 400, Graphics::PixelFormat::createFormatCLUT8());
// Save original background
Graphics::Surface backgroundOrig;
backgroundOrig.create(640, 400, Graphics::PixelFormat::createFormatCLUT8());
memcpy(backgroundOrig.getBasePtr(0,0), _vm->_screen->_frontScreen, 640 * 400);
_currMenuID = kMenuIdNone;
_newMenuID = kMenuIdMain;
_currItemID = kItemIdNone;
_editingDescription = false;
_cfgText = true;
_cfgVoices = true;
_cfgMasterVolume = 10;
_cfgVoicesVolume = 10;
_cfgMusicVolume = 10;
_cfgSoundFXVolume = 10;
_cfgBackgroundVolume = 10;
_running = true;
_top = 30 - _vm->_guiHeight / 2;
_needRedraw = false;
// TODO: buildColorTransTable2
_vm->_palette->buildColorTransTable(0, 16, 7);
_vm->_screen->_renderQueue->clear();
// Draw the menu background and frame
_vm->_screen->blastSprite(0x140 + _vm->_cameraX, 0x175 + _vm->_cameraY, 0, 1, 0x4000);
shadeRect(60, 39, 520, 246, 30, 94);
memcpy(_background->pixels, _vm->_screen->_frontScreen, 640 * 400);
while (_running) {
update();
_vm->_system->updateScreen();
}
// Restore original background
memcpy(_vm->_screen->_frontScreen, backgroundOrig.getBasePtr(0,0), 640 * 400);
_vm->_system->copyRectToScreen((const byte *)_vm->_screen->_frontScreen, 640, 0, 0, 640, 400);
_vm->_system->updateScreen();
// Cleanup
backgroundOrig.free();
_background->free();
delete _background;
return 0;
}
开发者ID:megaboy,项目名称:scummvm,代码行数:54,代码来源:menu.cpp
示例20: takeScreenshot
void EventRecorder::takeScreenshot() {
if ((_fakeTimer - _lastScreenshotTime) > _screenshotPeriod) {
Graphics::Surface screen;
uint8 md5[16];
if (grabScreenAndComputeMD5(screen, md5)) {
_lastScreenshotTime = _fakeTimer;
_playbackFile->saveScreenShot(screen, md5);
screen.free();
}
}
}
开发者ID:Akz-,项目名称:residual,代码行数:11,代码来源:EventRecorder.cpp
注:本文中的graphics::Surface类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论