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


C++ CGContextTranslateCTM函数代码示例

本文整理汇总了C++中CGContextTranslateCTM函数的典型用法代码示例。如果您正苦于以下问题:C++ CGContextTranslateCTM函数的具体用法?C++ CGContextTranslateCTM怎么用?C++ CGContextTranslateCTM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CGContextTranslateCTM函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GScreenDC

GPrintDC::GPrintDC(void *Handle, const char *PrintJobName, const char *PrinterName) :
	GScreenDC((GPrintDcParams*)Handle)
{
	d = new GPrintDCPrivate;
	d->PrintJobName = PrintJobName;
	d->PrinterName = PrinterName;
	
	GPrintDcParams *Params = (GPrintDcParams*)Handle;
	if (Params)
	{
		int x = Params->Page.right - Params->Page.left;
		int y = Params->Page.bottom - Params->Page.top;
		
		d->Dpi.x = Params->Dpi.hRes;
		d->Dpi.y = Params->Dpi.vRes;
		
		#if 0
		d->x = x * d->Dpi.x;
		d->y = y * d->Dpi.y;
		#else
		d->x = x;
		d->y = y;
		#endif

		d->Ctx = Params->Ctx;

		// Invert the co-ordinate space so 0,0 is the top left corner.
		CGContextTranslateCTM(d->Ctx, 0, y);
		CGContextScaleCTM(d->Ctx, 1.0, -1.0);
	}
}
开发者ID:FEI17N,项目名称:Lgi,代码行数:31,代码来源:GPrintDC.cpp

示例2: CGRectMake

wxBitmap wxScreenDCImpl::DoGetAsBitmap(const wxRect *subrect) const
{
    CGRect srcRect = CGRectMake(0, 0, m_width, m_height);
    if (subrect)
    {
        srcRect.origin.x = subrect->GetX();
        srcRect.origin.y = subrect->GetY();
        srcRect.size.width = subrect->GetWidth();
        srcRect.size.height = subrect->GetHeight();
    }
    wxBitmap bmp = wxBitmap(srcRect.size.width, srcRect.size.height, 32);
#if wxOSX_USE_IPHONE
#else
    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);
    
    CGContextRestoreGState(context);
#endif
    return bmp;
}
开发者ID:jonntd,项目名称:dynamica,代码行数:33,代码来源:dcscreen.cpp

示例3: CGContextWithHDC

static CGContextRef CGContextWithHDC(HDC hdc, bool hasAlpha)
{
    HBITMAP bitmap = static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP));

    DIBPixelData pixelData(bitmap);

    // FIXME: We can get here because we asked for a bitmap that is too big
    // when we have a tiled layer and we're compositing. In that case 
    // bmBitsPixel will be 0. This seems to be benign, so for now we will
    // exit gracefully and look at it later:
    //  https://bugs.webkit.org/show_bug.cgi?id=52041   
    // ASSERT(bitmapBits.bitsPerPixel() == 32);
    if (pixelData.bitsPerPixel() != 32)
        return 0;

    CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Little | (hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst);
    CGContextRef context = CGBitmapContextCreate(pixelData.buffer(), pixelData.size().width(), pixelData.size().height(), 8,
                                                 pixelData.bytesPerRow(), deviceRGBColorSpaceRef(), bitmapInfo);

    // Flip coords
    CGContextTranslateCTM(context, 0, pixelData.size().height());
    CGContextScaleCTM(context, 1, -1);
    
    // Put the HDC In advanced mode so it will honor affine transforms.
    SetGraphicsMode(hdc, GM_ADVANCED);
    
    return context;
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:28,代码来源:GraphicsContextCGWin.cpp

示例4: 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

示例5: 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

示例6: CGContextTranslateCTM

void GraphicsContext::translate(float x, float y)
{
    if (paintingDisabled())
        return;
    CGContextTranslateCTM(platformContext(), x, y);
    m_data->translate(x, y);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:7,代码来源:GraphicsContextCG.cpp

示例7: wxGCDCImpl

wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window )
   : wxGCDCImpl( owner )
{
    m_window = window;

    m_ok = true ;

    m_window->GetSize( &m_width , &m_height);
    if ( !m_window->IsShownOnScreen() )
        m_width = m_height = 0;

    CGContextRef cg = (CGContextRef) window->MacGetCGContextRef();

    m_release = false;
    if ( cg == NULL )
    {
        SetGraphicsContext( wxGraphicsContext::Create( window ) ) ;
    }
    else
    {
        CGContextSaveGState( cg );
        m_release = true ;
        // make sure the context is having its origin at the wx-window coordinates of the
        // view (read at the top of window.cpp about the differences)
        if ( window->MacGetLeftBorderSize() != 0 || window->MacGetTopBorderSize() != 0 )
            CGContextTranslateCTM( cg , -window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize() );

        SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) );
    }
    DoSetClippingRegion( 0 , 0 , m_width , m_height ) ;

    SetBackground(wxBrush(window->GetBackgroundColour(),wxSOLID));

    SetFont( window->GetFont() ) ;
}
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:35,代码来源:dcclient.cpp

示例8: beginCGContext

//-----------------------------------------------------------------------------
void CGDrawContext::lineTo (const CPoint& point)
{
	CGContextRef context = beginCGContext (true, currentState.drawMode.integralMode ());
	if (context)
	{
		applyLineStyle (context);

		if ((((int32_t)currentState.frameWidth) % 2))
			CGContextTranslateCTM (context, 0.5f, -0.5f);

		CGContextBeginPath (context);
		if (currentState.drawMode.integralMode ())
		{
			CGContextMoveToPoint (context, round (currentState.penLoc.h), round (currentState.penLoc.v));
			CGContextAddLineToPoint (context, round (point.h), round (point.v));
		}
		else
		{
			CGContextMoveToPoint (context, currentState.penLoc.h, currentState.penLoc.v);
			CGContextAddLineToPoint (context, point.h, point.v);
		}
		CGContextDrawPath (context, kCGPathStroke);
		releaseCGContext (context);
	}
	currentState.penLoc = point;
}
开发者ID:DaniM,项目名称:lyngo,代码行数:27,代码来源:cgdrawcontext.cpp

示例9: beginCGContext

//-----------------------------------------------------------------------------
void CGDrawContext::drawLines (const LineList& lines)
{
    if (lines.size () == 0)
        return;
    CGContextRef context = beginCGContext (true, getDrawMode ().integralMode ());
    if (context)
    {
        applyLineStyle (context);

        CGPoint* cgPoints = new CGPoint[lines.size () * 2];
        uint32_t index = 0;
        VSTGUI_RANGE_BASED_FOR_LOOP(LineList, lines, LinePair, line)
        cgPoints[index] = CGPointFromCPoint (line.first);
        cgPoints[index+1] = CGPointFromCPoint (line.second);
        if (getDrawMode ().integralMode ())
        {
            cgPoints[index] = pixelAlligned (cgPoints[index]);
            cgPoints[index+1] = pixelAlligned (cgPoints[index+1]);
        }
        index += 2;
        VSTGUI_RANGE_BASED_FOR_LOOP_END

        if (getDrawMode ().integralMode ())
        {
            int32_t frameWidth = static_cast<int32_t> (currentState.frameWidth);
            if (frameWidth % 2)
                CGContextTranslateCTM (context, 0.5, 0.5);
        }

        CGContextStrokeLineSegments (context, cgPoints, lines.size () * 2);
        delete [] cgPoints;

        releaseCGContext (context);
    }
}
开发者ID:UIKit0,项目名称:vstgui,代码行数:36,代码来源:cgdrawcontext.cpp

示例10: 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

示例11: drawSkewedCoordinateSystem

void drawSkewedCoordinateSystem(CGContextRef context)
{
    // alpha is 22.5 degrees and beta is 15 degrees.
    float alpha = M_PI/8, beta = M_PI/12;
    CGAffineTransform skew;
    // Create a rectangle that is 72 units on a side
    // with its origin at (0,0).
    CGRect r = CGRectMake(0, 0, 72, 72);
    
    CGContextTranslateCTM(context, 144, 144);
    // Draw the coordinate axes untransformed.
    drawCoordinateAxes(context);
    // Fill the rectangle.
    CGContextFillRect(context, r);

    // Create an affine transform that skews the coordinate system,
    // skewing the x-axis by alpha radians and the y-axis by beta radians. 
    skew = CGAffineTransformMake(1, tan(alpha), tan(beta), 1, 0, 0);
    // Apply that transform to the context coordinate system.
    CGContextConcatCTM(context, skew);

    // Set the fill and stroke color to a dark blue.
    CGContextSetRGBStrokeColor(context, 0.11, 0.208, 0.451, 1);
    CGContextSetRGBFillColor(context, 0.11, 0.208, 0.451, 1);
    
    // Draw the coordinate axes again, now transformed.
    drawCoordinateAxes(context);
    // Set the fill color again but with a partially transparent alpha.
    CGContextSetRGBFillColor(context, 0.11, 0.208, 0.451, 0.7);
    // Fill the rectangle in the transformed coordinate system.
    CGContextFillRect(context, r);
}
开发者ID:yarshure,项目名称:ProgrammingWithQuartz-Code,代码行数:32,代码来源:CoordinateSystem.c

示例12: Quartz_StrWidth

static double 	Quartz_StrWidth(char *str, 
				R_GE_gcontext *gc,
				NewDevDesc *dd)
{
    QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
    CGPoint position;

    CGContextSaveGState( GetContext(xd) );
    CGContextTranslateCTM( GetContext(xd), 0, 0 );

    CGContextScaleCTM( GetContext(xd), -1, 1);

    CGContextRotateCTM( GetContext(xd), -1.0 * 3.1416);

    CGContextSetTextDrawingMode( GetContext(xd), kCGTextInvisible );

    Quartz_SetFont(gc->fontfamily, gc->fontface, gc->cex,  gc->ps, dd);

    CGContextShowTextAtPoint( GetContext(xd), 0, 0, str, strlen(str) );

    position = CGContextGetTextPosition( GetContext(xd) );

    CGContextRestoreGState( GetContext(xd) );
    return(position.x);
}
开发者ID:Vladimir84,项目名称:rcc,代码行数:25,代码来源:devQuartz.c

示例13: 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

示例14: addRoundedRectToPath

static void addRoundedRectToPath(CGContextRef context, CGRect rect,
										float ovalWidth,
										float ovalHeight)
{
	float fw, fh;
	// If either ovalWidth or ovalHeight is 0, draw a regular rectangle.
	if (ovalWidth == 0 || ovalHeight == 0) {
		CGContextAddRect(context, rect);
	}else{
        CGContextSaveGState(context);
		// Translate to lower-left corner of rectangle.
        CGContextTranslateCTM(context, CGRectGetMinX(rect),
										 CGRectGetMinY(rect));
		// Scale by the oval width and height so that
		// each rounded corner is 0.5 units in radius.
		CGContextScaleCTM(context, ovalWidth, ovalHeight);
		// Unscale the rectangle width by the amount of the X scaling.
		fw = CGRectGetWidth(rect) / ovalWidth;
		// Unscale the rectangle height by the amount of the Y scaling.
		fh = CGRectGetHeight(rect) / ovalHeight;
		// Start at the right edge of the rect, at the midpoint in Y.
		CGContextMoveToPoint(context, fw, fh/2);
		// Segment 1
		CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 0.5);
		// Segment 2
		CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 0.5);
		// Segment 3
		CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 0.5);
		// Segment 4
		CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 0.5);
		// Closing the path adds the last segment.
		CGContextClosePath(context);
		CGContextRestoreGState(context);
	}
}
开发者ID:yarshure,项目名称:ProgrammingWithQuartz-Code,代码行数:35,代码来源:PathDrawing.c

示例15: 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


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