本文整理汇总了C++中GfxSurface::getBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ GfxSurface::getBounds方法的具体用法?C++ GfxSurface::getBounds怎么用?C++ GfxSurface::getBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GfxSurface
的用法示例。
在下文中一共展示了GfxSurface::getBounds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pt
InventoryDialog::InventoryDialog() {
// Determine the maximum size of the image of any item in the player's inventory
int imgWidth = 0, imgHeight = 0;
SynchronizedList<InvObject *>::iterator i;
for (i = RING_INVENTORY._itemList.begin(); i != RING_INVENTORY._itemList.end(); ++i) {
InvObject *invObject = *i;
if (invObject->inInventory()) {
// Get the image for the item
GfxSurface itemSurface = surfaceFromRes(invObject->_displayResNum, invObject->_rlbNum, invObject->_cursorNum);
// Maintain the dimensions of the largest item image
imgWidth = MAX(imgWidth, (int)itemSurface.getBounds().width());
imgHeight = MAX(imgHeight, (int)itemSurface.getBounds().height());
// Add the item to the display list
GfxInvImage *img = new GfxInvImage();
_images.push_back(img);
img->setDetails(invObject->_displayResNum, invObject->_rlbNum, invObject->_cursorNum);
img->_invObject = invObject;
add(img);
}
}
assert(_images.size() > 0);
// Figure out the number of columns/rows to show all the items
int cellsSize = 3;
while ((cellsSize * cellsSize) < (int)_images.size())
++cellsSize;
// Set the position of each inventory item to be displayed
int cellX = 0;
Common::Point pt(0, 0);
for (uint idx = 0; idx < _images.size(); ++idx) {
if (cellX == cellsSize) {
// Move to the start of the next line
pt.x = 0;
pt.y += imgHeight + 2;
cellX = 0;
}
_images[idx]->_bounds.moveTo(pt.x, pt.y);
pt.x += imgWidth + 2;
++cellX;
}
// Set up the buttons
pt.y += imgHeight + 2;
_btnOk.setText(OK_BTN_STRING);
_btnOk._bounds.moveTo((imgWidth + 2) * cellsSize - _btnOk._bounds.width(), pt.y);
_btnLook.setText(LOOK_BTN_STRING);
_btnLook._bounds.moveTo(_btnOk._bounds.left - _btnLook._bounds.width() - 2, _btnOk._bounds.top);
addElements(&_btnLook, &_btnOk, NULL);
frame();
setCenter(SCREEN_CENTER_X, SCREEN_CENTER_Y);
}
示例2: 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;
}
示例3: resize
/**
* Resizes and positions a given rect based on raw image data and a passed scaling percentage
*
* @frame Raw image frame
* @xp New x position
* @yp New y position
* @percent Scaling percentage
*/
void Rect::resize(const GfxSurface &surface, int xp, int yp, int percent) {
int xe = surface.getBounds().width() * percent / 100;
int ye = surface.getBounds().height() * percent / 100;
this->set(0, 0, xe, ye);
if (!right) ++right;
if (!bottom) ++bottom;
this->moveTo(xp, yp);
int xd = surface._centroid.x * percent / 100;
int yd = surface._centroid.y * percent / 100;
this->translate(-xd, -yd);
}
示例4:
void Scene3700::Viewer::draw() {
Region *priorityRegion = _globals->_sceneManager._scene->_priorities.find(1);
for (int idx = 0; idx < 4; ++idx) {
Visage &v = (idx == 0) ? _images1 : _images2;
GfxSurface img = v.getFrame(_frameList[idx]);
Rect destRect = img.getBounds();
destRect.resize(img, (_position.x - _globals->_sceneOffset.x),
(_position.y - _globals->_sceneOffset.y - _yDiff), _percentList[idx]);
destRect.translate(-_globals->_sceneManager._scene->_sceneBounds.left,
-_globals->_sceneManager._scene->_sceneBounds.top);
_globals->gfxManager().copyFrom(img, destRect, priorityRegion);
}
}
示例5: copyFrom
/**
* Copys an area from one GfxSurface to another
*/
void GfxSurface::copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, Region *priorityRegion) {
GfxSurface srcImage;
if (srcBounds.isEmpty())
return;
if (srcBounds == src.getBounds())
srcImage = src;
else {
// Set the source image to be the subset specified by the source bounds
Graphics::Surface srcSurface = src.lockSurface();
srcImage.create(srcBounds.width(), srcBounds.height());
Graphics::Surface destSurface = srcImage.lockSurface();
const byte *srcP = (const byte *)srcSurface.getBasePtr(srcBounds.left, srcBounds.top);
byte *destP = (byte *)destSurface.pixels;
for (int yp = srcBounds.top; yp < srcBounds.bottom; ++yp, srcP += srcSurface.pitch, destP += destSurface.pitch) {
Common::copy(srcP, srcP + srcBounds.width(), destP);
}
srcImage.unlockSurface();
src.unlockSurface();
}
if ((destBounds.width() != srcBounds.width()) || (destBounds.height() != srcBounds.height()))
srcImage = ResizeSurface(srcImage, destBounds.width(), destBounds.height(), src._transColor);
Graphics::Surface srcSurface = srcImage.lockSurface();
Graphics::Surface destSurface = lockSurface();
// Adjust bounds to ensure destination will be on-screen
int srcX = 0, srcY = 0;
if (destBounds.left < 0) {
srcX = -destBounds.left;
destBounds.left = 0;
}
if (destBounds.top < 0) {
srcY = -destBounds.top;
destBounds.top = 0;
}
if (destBounds.right > destSurface.w)
destBounds.right = destSurface.w;
if (destBounds.bottom > destSurface.h)
destBounds.bottom = destSurface.h;
if (destBounds.isValidRect()) {
const byte *pSrc = (const byte *)srcSurface.getBasePtr(srcX, srcY);
byte *pDest = (byte *)destSurface.getBasePtr(destBounds.left, destBounds.top);
for (int y = 0; y < destBounds.height(); ++y, pSrc += srcSurface.pitch, pDest += destSurface.pitch) {
if (!priorityRegion && (src._transColor == -1))
Common::copy(pSrc, pSrc + destBounds.width(), pDest);
else {
const byte *tempSrc = pSrc;
byte *tempDest = pDest;
int xp = destBounds.left;
while (tempSrc < (pSrc + destBounds.width())) {
if (!priorityRegion || !priorityRegion->contains(Common::Point(
xp + _globals->_sceneManager._scene->_sceneBounds.left,
destBounds.top + y + _globals->_sceneManager._scene->_sceneBounds.top))) {
if (*tempSrc != src._transColor)
*tempDest = *tempSrc;
}
++tempSrc;
++tempDest;
++xp;
}
}
}
}
unlockSurface();
srcImage.unlockSurface();
}