当前位置: 首页>>代码示例>>C++>>正文


C++ CGContextScaleCTM函数代码示例

本文整理汇总了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);
}
开发者ID:yarshure,项目名称:ProgrammingWithQuartz-Code,代码行数:29,代码来源:PathDrawing.c

示例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);
}
开发者ID:harlanlewis,项目名称:webkit,代码行数:32,代码来源:PDFDocumentImage.cpp

示例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);
}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:33,代码来源:PDFDocumentImage.cpp

示例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);
	}
}
开发者ID:prestocore,项目名称:browser,代码行数:32,代码来源:MacVEGAPrinterListener.cpp

示例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;
}
开发者ID:DaniM,项目名称:lyngo,代码行数:36,代码来源:cgbitmap.cpp

示例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;
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:54,代码来源:qprintengine_mac.cpp

示例7: CGContextScaleCTM

void GraphicsContext::scale(const FloatSize& size)
{
    if (paintingDisabled())
        return;
    CGContextScaleCTM(platformContext(), size.width(), size.height());
    m_data->scale(size);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:7,代码来源:GraphicsContextCG.cpp

示例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;
}
开发者ID:erwincoumans,项目名称:wxWidgets,代码行数:33,代码来源:dcscreen.cpp

示例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);
}
开发者ID:ZeusbaseWeb,项目名称:webkit,代码行数:27,代码来源:TestInvocationCG.cpp

示例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);
}
开发者ID:AlekSi,项目名称:phantomjs,代码行数:32,代码来源:qnativeimage.cpp

示例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;
			
}
开发者ID:fruitsamples,项目名称:ATSUIDirectAccessDemo,代码行数:30,代码来源:Window.c

示例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;
}
开发者ID:BruceJawn,项目名称:flashsnes,代码行数:32,代码来源:mac-musicbox.cpp

示例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);
}
开发者ID:nihed,项目名称:magnetism,代码行数:31,代码来源:cairo-quartz-surface.c

示例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;
}
开发者ID:HackLinux,项目名称:chandler-1,代码行数:27,代码来源:metafile.cpp

示例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
}
开发者ID:AliFarahnak,项目名称:XobotOS,代码行数:25,代码来源:SkOSWindow_Mac.cpp


注:本文中的CGContextScaleCTM函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。