本文整理匯總了C++中CGContextScaleCTM函數的典型用法代碼示例。如果您正苦於以下問題:C++ CGContextScaleCTM函數的具體用法?C++ CGContextScaleCTM怎麽用?C++ CGContextScaleCTM使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CGContextScaleCTM函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: doStrokeWithCTM
void doStrokeWithCTM(CGContextRef context)
{
CGContextTranslateCTM(context, 150., 180.);
CGContextSetLineWidth(context, 10);
// Draw ellipse 1 with a uniform stroke.
CGContextSaveGState(context);
// Scale the CTM so the circular arc will be elliptical.
CGContextScaleCTM(context, 2, 1);
CGContextBeginPath(context);
// Create an arc that is a circle.
CGContextAddArc(context, 0., 0., 45., 0., 2*M_PI, 0);
// Restore the context parameters prior to stroking the path.
// CGContextRestoreGState does not affect the path in the context.
CGContextRestoreGState(context);
CGContextStrokePath(context);
// *** was 0, -120
CGContextTranslateCTM(context, 220., 0.);
// Draw ellipse 2 with non-uniform stroke.
CGContextSaveGState(context);
// Scale the CTM so the circular arc will be elliptical.
CGContextScaleCTM(context, 2, 1);
CGContextBeginPath(context);
// Create an arc that is a circle.
CGContextAddArc(context, 0., 0., 45., 0., 2*M_PI, 0);
// Stroke the path with the scaled coordinate system in effect.
CGContextStrokePath(context);
CGContextRestoreGState(context);
}
示例2: stateSaver
void PDFDocumentImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator op, BlendMode)
{
if (!m_document || m_currentPage == -1)
return;
{
GraphicsContextStateSaver stateSaver(*context);
context->setCompositeOperation(op);
float hScale = dstRect.width() / srcRect.width();
float vScale = dstRect.height() / srcRect.height();
// Scale and translate so the document is rendered in the correct location,
// including accounting for the fact that a GraphicsContext is always flipped
// and doing appropriate flipping.
CGContextTranslateCTM(context->platformContext(), dstRect.x() - srcRect.x() * hScale, dstRect.y() - srcRect.y() * vScale);
CGContextScaleCTM(context->platformContext(), hScale, vScale);
CGContextScaleCTM(context->platformContext(), 1, -1);
CGContextTranslateCTM(context->platformContext(), 0, -srcRect.height());
CGContextClipToRect(context->platformContext(), CGRectIntegral(srcRect));
// Rotate translate image into position according to doc properties.
adjustCTM(context);
CGContextTranslateCTM(context->platformContext(), -m_mediaBox.x(), -m_mediaBox.y());
CGContextDrawPDFPage(context->platformContext(), CGPDFDocumentGetPage(m_document, m_currentPage + 1));
}
if (imageObserver())
imageObserver()->didDraw(this);
}
示例3: CGContextTranslateCTM
void PDFDocumentImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator op)
{
if (!m_document || m_currentPage == -1)
return;
context->save();
context->setCompositeOperation(op);
float hScale = dstRect.width() / srcRect.width();
float vScale = dstRect.height() / srcRect.height();
// Scale and translate so the document is rendered in the correct location,
// including accounting for the fact that a GraphicsContext is always flipped
// and doing appropriate flipping.
CGContextTranslateCTM(context->platformContext(), dstRect.x() - srcRect.x() * hScale, dstRect.y() - srcRect.y() * vScale);
CGContextScaleCTM(context->platformContext(), hScale, vScale);
CGContextScaleCTM(context->platformContext(), 1, -1);
CGContextTranslateCTM(context->platformContext(), 0, -srcRect.height());
CGContextClipToRect(context->platformContext(), CGRectIntegral(srcRect));
// Rotate translate image into position according to doc properties.
adjustCTM(context);
// Media box may have non-zero origin which we ignore. Pass 1 for the page number.
CGContextDrawPDFDocument(context->platformContext(), FloatRect(FloatPoint(), m_mediaBox.size()),
m_document, m_currentPage + 1);
context->restore();
if (imageObserver())
imageObserver()->didDraw(this);
}
示例4: CGRectMake
void MacVegaPrinterListener::DrawEllipse(const OpRect& rect, UINT32 width)
{
CGRect cgrect = CGRectMake(rect.x, rect.y, rect.width, rect.height);
cgrect.origin.y = m_winHeight - cgrect.origin.y - cgrect.size.height;
float cx = cgrect.origin.x + (cgrect.size.width / 2);
float cy = cgrect.origin.y + (cgrect.size.height / 2);
float radius = cgrect.size.width / 2;
if(width != 1)
{
CGContextSetLineWidth(m_ctx, width);
}
if(cgrect.size.width != cgrect.size.height)
{
cy = cy * cgrect.size.width / cgrect.size.height;
CGContextScaleCTM(m_ctx, 1.0, cgrect.size.height/cgrect.size.width);
}
CGContextAddArc(m_ctx, cx, cy, radius, 0, 2*M_PI, 0);
CGContextStrokePath(m_ctx);
if(width != 1)
{
CGContextSetLineWidth(m_ctx, 1);
}
if(cgrect.size.width != cgrect.size.height)
{
CGContextScaleCTM(m_ctx, 1.0, cgrect.size.width/cgrect.size.height);
}
}
示例5: allocBits
//-----------------------------------------------------------------------------
CGContextRef CGBitmap::createCGContext ()
{
CGContextRef context = 0;
if (bits == 0)
{
allocBits ();
if (imageSource)
getCGImage ();
if (image)
{
context = createCGContext ();
if (context)
{
CGContextScaleCTM (context, 1, -1);
CGContextDrawImage (context, CGRectMake (0, -size.y, size.x, size.y), image);
CGContextScaleCTM (context, 1, -1);
return context;
}
}
}
if (bits)
{
CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Big;
context = CGBitmapContextCreate (bits,
size.x,
size.y,
8,
getBytesPerRow (),
GetCGColorSpace (),
bitmapInfo);
CGContextTranslateCTM (context, 0, (CGFloat)size.y);
CGContextScaleCTM (context, 1, -1);
}
return context;
}
示例6: Q_Q
bool QMacPrintEnginePrivate::newPage_helper()
{
Q_Q(QMacPrintEngine);
Q_ASSERT(state == QPrinter::Active);
if (PMSessionError(session) != noErr) {
q->abort();
return false;
}
OSStatus status = shouldSuppressStatus() ? PMSessionBeginPageNoDialog(session, format, 0)
: PMSessionBeginPage(session, format, 0);
if(status != noErr) {
state = QPrinter::Error;
return false;
}
QRect page = q->property(QPrintEngine::PPK_PageRect).toRect();
QRect paper = q->property(QPrintEngine::PPK_PaperRect).toRect();
CGContextRef cgContext;
OSStatus err = noErr;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
err = PMSessionGetCGGraphicsContext(session, &cgContext);
} else
#endif
{
#ifndef Q_OS_MAC64
err = PMSessionGetGraphicsContext(session, kPMGraphicsContextCoreGraphics,
reinterpret_cast<void **>(&cgContext));
#endif
}
if(err != noErr) {
qWarning("QMacPrintEngine::newPage: Cannot retrieve CoreGraphics context: %ld", long(err));
state = QPrinter::Error;
return false;
}
QCoreGraphicsPaintEngine *cgEngine = static_cast<QCoreGraphicsPaintEngine*>(paintEngine);
cgEngine->d_func()->hd = cgContext;
// Set the resolution as a scaling ration of 72 (the default).
CGContextScaleCTM(cgContext, 72 / resolution.hRes, 72 / resolution.vRes);
CGContextScaleCTM(cgContext, 1, -1);
CGContextTranslateCTM(cgContext, 0, -paper.height());
if (!fullPage)
CGContextTranslateCTM(cgContext, page.x() - paper.x(), page.y() - paper.y());
cgEngine->d_func()->orig_xform = CGContextGetCTM(cgContext);
cgEngine->d_func()->setClip(0);
cgEngine->state->dirtyFlags = QPaintEngine::AllDirty;
cgEngine->syncState();
return true;
}
示例7: CGContextScaleCTM
void GraphicsContext::scale(const FloatSize& size)
{
if (paintingDisabled())
return;
CGContextScaleCTM(platformContext(), size.width(), size.height());
m_data->scale(size);
}
示例8: wxRect
wxBitmap wxScreenDCImpl::DoGetAsBitmap(const wxRect *subrect) const
{
wxRect rect = subrect ? *subrect : wxRect(0, 0, m_width, m_height);
wxBitmap bmp(rect.GetSize(), 32);
#if !wxOSX_USE_IPHONE
CGRect srcRect = CGRectMake(rect.x, rect.y, rect.width, rect.height);
CGContextRef context = (CGContextRef)bmp.GetHBITMAP();
CGContextSaveGState(context);
CGContextTranslateCTM( context, 0, m_height );
CGContextScaleCTM( context, 1, -1 );
if ( subrect )
srcRect = CGRectOffset( srcRect, -subrect->x, -subrect->y ) ;
CGImageRef image = grabViaOpenGL(kCGNullDirectDisplay, srcRect);
wxASSERT_MSG(image, wxT("wxScreenDC::GetAsBitmap - unable to get screenshot."));
CGContextDrawImage(context, srcRect, image);
CGImageRelease(image);
CGContextRestoreGState(context);
#else
// TODO implement using UIGetScreenImage, CGImageCreateWithImageInRect, CGContextDrawImage
#endif
return bmp;
}
示例9: paintRepaintRectOverlay
static void paintRepaintRectOverlay(CGContextRef context, WKImageRef image, WKArrayRef repaintRects)
{
WKSize imageSize = WKImageGetSize(image);
CGContextSaveGState(context);
// Using a transparency layer is easier than futzing with clipping.
CGContextBeginTransparencyLayer(context, 0);
// Flip the context.
CGContextScaleCTM(context, 1, -1);
CGContextTranslateCTM(context, 0, -imageSize.height);
CGContextSetRGBFillColor(context, 0, 0, 0, static_cast<CGFloat>(0.66));
CGContextFillRect(context, CGRectMake(0, 0, imageSize.width, imageSize.height));
// Clear the repaint rects.
size_t count = WKArrayGetSize(repaintRects);
for (size_t i = 0; i < count; ++i) {
WKRect rect = WKRectGetValue(static_cast<WKRectRef>(WKArrayGetItemAtIndex(repaintRects, i)));
CGRect cgRect = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
CGContextClearRect(context, cgRect);
}
CGContextEndTransparencyLayer(context);
CGContextRestoreGState(context);
}
示例10: image
QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWidget *widget)
: image(width, height, format)
{
uint cgflags = kCGImageAlphaNoneSkipFirst;
switch (format) {
case QImage::Format_ARGB32:
cgflags = kCGImageAlphaFirst;
break;
case QImage::Format_ARGB32_Premultiplied:
case QImage::Format_ARGB8565_Premultiplied:
case QImage::Format_ARGB6666_Premultiplied:
case QImage::Format_ARGB8555_Premultiplied:
case QImage::Format_ARGB4444_Premultiplied:
cgflags = kCGImageAlphaPremultipliedFirst;
break;
default:
break;
}
#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
cgflags |= kCGBitmapByteOrder32Host;
#endif
cg = CGBitmapContextCreate(image.bits(), width, height, 8, image.bytesPerLine(),
QCoreGraphicsPaintEngine::macDisplayColorSpace(widget), cgflags);
CGContextTranslateCTM(cg, 0, height);
CGContextScaleCTM(cg, 1, -1);
Q_ASSERT(image.paintEngine()->type() == QPaintEngine::Raster);
static_cast<QRasterPaintEngine *>(image.paintEngine())->setCGContext(cg);
}
示例11: HandleViewEvent
static
OSStatus HandleViewEvent(
EventHandlerCallRef inHandlerCallRef,
EventRef inEvent,
void *inUserData )
{
#pragma unused( inHandlerCallRef )
OSStatus err = eventNotHandledErr;
DrawContextStruct *context = inUserData;
verify_noerr( GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(CGContextRef), NULL, &context->cgContext) );
HIViewGetBounds(context->viewRef, &context->bounds);
CGContextTranslateCTM(context->cgContext, 0, context->bounds.size.height);
CGContextScaleCTM(context->cgContext, 1.0, -1.0);
switch ( GetEventKind( inEvent ) ) {
case kEventControlDraw:
{
// redraw the context
DrawWindow( context->windowRef );
break;
}
default:
break;
};
return err;
}
示例12: IndicatorEventHandler
static pascal OSStatus IndicatorEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *userData)
{
#pragma unused (inHandlerCallRef)
OSStatus err, result = eventNotHandledErr;
HIViewRef view = (HIViewRef) userData;
switch (GetEventClass(inEvent))
{
case kEventClassControl:
switch (GetEventKind(inEvent))
{
case kEventControlDraw:
CGContextRef ctx;
err = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, nil, sizeof(CGContextRef), nil, &ctx);
if (err == noErr)
{
HIRect bounds;
HIViewGetBounds(view, &bounds);
CGContextTranslateCTM(ctx, 0, bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
MusicBoxDrawIndicator(view, ctx);
result = noErr;
}
}
}
return result;
}
示例13: _cairo_quartz_surface_release_dest_image
static void
_cairo_quartz_surface_release_dest_image(void *abstract_surface,
cairo_rectangle_int16_t *intersect_rect,
cairo_image_surface_t *image,
cairo_rectangle_int16_t *image_rect,
void *image_extra)
{
cairo_quartz_surface_t *surface = abstract_surface;
CGImageRef image_ref;
CGRect rect;
image_ref = create_image_from_surface (image, image_extra);
rect = CGRectMake (image_rect->x, image_rect->y, image_rect->width, image_rect->height);
if (surface->y_grows_down) {
CGContextSaveGState (surface->context);
CGContextTranslateCTM (surface->context, 0, image_rect->height + 2 * image_rect->y);
CGContextScaleCTM (surface->context, 1, -1);
}
CGContextDrawImage(surface->context, rect, image_ref);
CFRelease (image_ref);
if (surface->y_grows_down) {
CGContextRestoreGState (surface->context);
}
cairo_surface_destroy ((cairo_surface_t *)image);
free (image_extra);
}
示例14: QDPictGetBounds
bool wxMetaFile::Play(wxDC *dc)
{
if (!m_refData)
return false;
if (!dc->Ok() )
return false;
{
#if wxMAC_USE_CORE_GRAPHICS
QDPictRef cgPictRef = M_METAFILEDATA->m_qdPictRef ;
CGContextRef cg = ((wxMacCGContext*)(dc->GetGraphicContext()))->GetNativeContext() ;
CGRect bounds = QDPictGetBounds( cgPictRef ) ;
CGContextSaveGState(cg);
CGContextTranslateCTM(cg, 0 , bounds.size.width );
CGContextScaleCTM(cg, 1, -1);
QDPictDrawToCGContext( cg , bounds , cgPictRef ) ;
CGContextRestoreGState( cg ) ;
#else
PicHandle pict = (PicHandle) GetHMETAFILE() ;
wxMacPortSetter helper( dc ) ;
DrawPicture( pict , &(**pict).picFrame ) ;
#endif
}
return true;
}
示例15: SkCreateCGImageRef
void SkOSWindow::doPaint(void* ctx)
{
#if 0
this->update(NULL);
const SkBitmap& bm = this->getBitmap();
CGImageRef img = SkCreateCGImageRef(bm);
if (img) {
CGRect r = CGRectMake(0, 0, bm.width(), bm.height());
CGContextRef cg = reinterpret_cast<CGContextRef>(ctx);
CGContextSaveGState(cg);
CGContextTranslateCTM(cg, 0, r.size.height);
CGContextScaleCTM(cg, 1, -1);
CGContextDrawImage(cg, r, img);
CGContextRestoreGState(cg);
CGImageRelease(img);
}
#endif
}