本文整理汇总了C++中DocumentApi::cropSprite方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentApi::cropSprite方法的具体用法?C++ DocumentApi::cropSprite怎么用?C++ DocumentApi::cropSprite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentApi
的用法示例。
在下文中一共展示了DocumentApi::cropSprite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onExecute
void CanvasSizeCommand::onExecute(Context* context)
{
const ContextReader reader(context);
const Sprite* sprite(reader.sprite());
if (context->isUiAvailable()) {
// load the window widget
base::UniquePtr<CanvasSizeWindow> window(new CanvasSizeWindow(0, 0, 0, 0));
window->remapWindow();
window->centerWindow();
load_window_pos(window, "CanvasSize");
window->setVisible(true);
window->openWindowInForeground();
save_window_pos(window, "CanvasSize");
if (!window->pressedOk())
return;
m_left = window->getLeft();
m_right = window->getRight();
m_top = window->getTop();
m_bottom = window->getBottom();
}
// Resize canvas
int x1 = -m_left;
int y1 = -m_top;
int x2 = sprite->width() + m_right;
int y2 = sprite->height() + m_bottom;
if (x2 <= x1) x2 = x1+1;
if (y2 <= y1) y2 = y1+1;
{
ContextWriter writer(reader);
Document* document = writer.document();
Sprite* sprite = writer.sprite();
UndoTransaction undoTransaction(writer.context(), "Canvas Size");
DocumentApi api = document->getApi();
raster::color_t bgcolor = color_utils::color_for_target(
context->settings()->getBgColor(),
ColorTarget(
ColorTarget::BackgroundLayer,
sprite->pixelFormat(),
sprite->transparentColor()));
api.cropSprite(sprite, gfx::Rect(x1, y1, x2-x1, y2-y1), bgcolor);
undoTransaction.commit();
document->generateMaskBoundaries();
update_screen_for_document(document);
}
}