本文整理汇总了C++中DrawingContext::GetDrawingEngine方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawingContext::GetDrawingEngine方法的具体用法?C++ DrawingContext::GetDrawingEngine怎么用?C++ DrawingContext::GetDrawingEngine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawingContext
的用法示例。
在下文中一共展示了DrawingContext::GetDrawingEngine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static void
draw_rect(void* _context, const BRect& _rect, bool fill)
{
DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
BRect rect = _rect;
context->ConvertToScreenForDrawing(&rect);
if (fill)
context->GetDrawingEngine()->FillRect(rect);
else
context->GetDrawingEngine()->StrokeRect(rect);
}
示例2: sizeof
static void
draw_polygon(void* _context, size_t numPoints, const BPoint viewPoints[],
bool isClosed, bool fill)
{
DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
if (numPoints == 0)
return;
const size_t kMaxStackCount = 200;
char stackData[kMaxStackCount * sizeof(BPoint)];
BPoint* points = (BPoint*)stackData;
if (numPoints > kMaxStackCount) {
points = (BPoint*)malloc(numPoints * sizeof(BPoint));
if (points == NULL)
return;
}
context->ConvertToScreenForDrawing(points, viewPoints, numPoints);
BRect polyFrame;
get_polygon_frame(points, numPoints, &polyFrame);
context->GetDrawingEngine()->DrawPolygon(points, numPoints, polyFrame,
fill, isClosed && numPoints > 2);
if (numPoints > kMaxStackCount)
free(points);
}
示例3: p
static void
pop_state(void* _context)
{
DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
context->PopState();
BPoint p(0, 0);
context->ConvertToScreenForDrawing(&p);
context->GetDrawingEngine()->SetDrawState(context->CurrentState(),
(int32)p.x, (int32)p.y);
}
示例4: rect
static void
draw_arc(void* _context, const BPoint& center, const BPoint& radii,
float startTheta, float arcTheta, bool fill)
{
DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
BRect rect(center.x - radii.x, center.y - radii.y,
center.x + radii.x - 1, center.y + radii.y - 1);
context->ConvertToScreenForDrawing(&rect);
context->GetDrawingEngine()->DrawArc(rect, startTheta, arcTheta, fill);
}
示例5: bitmap
static void
draw_pixels(void* _context, const BRect& src, const BRect& _dest, uint32 width,
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 options,
const void* data, size_t length)
{
DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
UtilityBitmap bitmap(BRect(0, 0, width - 1, height - 1),
(color_space)pixelFormat, 0, bytesPerRow);
if (!bitmap.IsValid())
return;
memcpy(bitmap.Bits(), data, std::min(height * bytesPerRow, length));
BRect dest = _dest;
context->ConvertToScreenForDrawing(&dest);
context->GetDrawingEngine()->DrawBitmap(&bitmap, src, dest, options);
}
示例6: offset
void
ShapePainter::Draw(BRect frame, bool filled)
{
// We're going to draw the currently iterated shape.
// TODO: This can be more efficient by skipping the conversion.
int32 opCount = fOpStack.size();
int32 ptCount = fPtStack.size();
if (opCount > 0 && ptCount > 0) {
int32 i;
uint32* opList = new(std::nothrow) uint32[opCount];
if (opList == NULL)
return;
BPoint* ptList = new(std::nothrow) BPoint[ptCount];
if (ptList == NULL) {
delete[] opList;
return;
}
for (i = opCount - 1; i >= 0; i--) {
opList[i] = fOpStack.top();
fOpStack.pop();
}
for (i = ptCount - 1; i >= 0; i--) {
ptList[i] = fPtStack.top();
fPtStack.pop();
}
BPoint offset(fContext->CurrentState()->PenLocation());
fContext->ConvertToScreenForDrawing(&offset);
fContext->GetDrawingEngine()->DrawShape(frame, opCount, opList,
ptCount, ptList, filled, offset, fContext->Scale());
delete[] opList;
delete[] ptList;
}
}