这篇教程C++ CGContextScaleCTM函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CGContextScaleCTM函数的典型用法代码示例。如果您正苦于以下问题:C++ CGContextScaleCTM函数的具体用法?C++ CGContextScaleCTM怎么用?C++ CGContextScaleCTM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CGContextScaleCTM函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: doStrokeWithCTMvoid 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,
示例2: stateSavervoid 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,
示例3: CGContextTranslateCTMvoid 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,
示例4: CGRectMakevoid 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,
示例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,
示例6: Q_Qbool 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,
示例7: CGContextScaleCTMvoid GraphicsContext::scale(const FloatSize& size){ if (paintingDisabled()) return; CGContextScaleCTM(platformContext(), size.width(), size.height()); m_data->scale(size);}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:7,
示例8: wxRectwxBitmap 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,
示例9: paintRepaintRectOverlaystatic 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,
示例10: imageQNativeImage::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,
示例11: HandleViewEventstaticOSStatus 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,
示例12: IndicatorEventHandlerstatic 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,
示例13: _cairo_quartz_surface_release_dest_imagestatic 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,
示例14: QDPictGetBoundsbool 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,
示例15: SkCreateCGImageRefvoid 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,
示例16: CGRectMakewxBitmap 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,
示例17: AddRoundedRectToPathstatic void AddRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight){ float fw, fh; if (ovalWidth == 0 || ovalHeight == 0) { CGContextAddRect(context, rect); return; } CGContextSaveGState(context); CGContextTranslateCTM (context, CGRectGetMinX(rect), CGRectGetMinY(rect)); CGContextScaleCTM (context, ovalWidth, ovalHeight); fw = CGRectGetWidth (rect) / ovalWidth; fh = CGRectGetHeight (rect) / ovalHeight; CGContextMoveToPoint(context, fw, fh / 2); CGContextAddArcToPoint(context, fw, fh, fw / 2, fh, 1); CGContextAddArcToPoint(context, 0, fh, 0, fh / 2, 1); CGContextAddArcToPoint(context, 0, 0, fw / 2, 0, 1); CGContextAddArcToPoint(context, fw, 0, fw, fh / 2, 1); CGContextClosePath(context); CGContextRestoreGState(context);}
开发者ID:AdamDiment,项目名称:CocoaSampleCode,代码行数:28,
示例18: CGColorSpaceCreateDeviceRGBbool GiCanvasIosImpl::createBufferBitmap(float width, float height, float scale){ width *= scale; // 点数宽度转为像素宽度 height *= scale; if (width < 4 || height < 4 || width > 2049 || height > 2049) { return false; } CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); _buffctx = CGBitmapContextCreate(NULL, width, height, 8, width * 4, colorSpace, kCGImageAlphaPremultipliedLast); CGColorSpaceRelease(colorSpace); CGContextClearRect(_buffctx, CGRectMake(0, 0, width, height)); // 坐标系改为Y朝下,原点在左上角,这样除了放大倍数为1外,其余就与 _context 坐标系一致 //if (_buffctx && _context) { CGContextTranslateCTM(_buffctx, 0, height); CGContextScaleCTM(_buffctx, scale, - scale); //} //else if (_buffctx) { // CGContextScaleCTM(_buffctx, scale, scale); //} return !!_buffctx;}
开发者ID:huangzongwu,项目名称:touchvg,代码行数:27,
示例19: wxASSERT_MSGvoid wxOverlayImpl::Init( wxWindowDC* dc, int x , int y , int width , int height ){ wxASSERT_MSG( !IsOk() , _("You cannot Init an overlay twice") ); m_window = dc->GetWindow(); m_x = x ; m_y = y ; if ( dc->IsKindOf( CLASSINFO( wxClientDC ) )) { wxPoint origin = m_window->GetClientAreaOrigin(); m_x += origin.x; m_y += origin.y; } m_width = width ; m_height = height ; OSStatus err = CreateOverlayWindow(); wxASSERT_MSG( err == noErr , _("Couldn't create the overlay window") );#ifndef __LP64__ err = QDBeginCGContext(GetWindowPort(m_overlayWindow), &m_overlayContext);#endif CGContextTranslateCTM( m_overlayContext, 0, m_height ); CGContextScaleCTM( m_overlayContext, 1, -1 ); CGContextTranslateCTM( m_overlayContext, -m_x , -m_y ); wxASSERT_MSG( err == noErr , _("Couldn't init the context on the overlay window") );}
开发者ID:EdgarTx,项目名称:wx,代码行数:26,
示例20: CGContextWithHDCstatic 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,
示例21: Quartz_StrWidthstatic 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,
示例22: createDragImageFromImageDragImageRef createDragImageFromImage(Image* img, ImageOrientationDescription){ HWndDC dc(0); auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc)); if (!workingDC) return 0; CGContextRef drawContext = 0; auto hbmp = allocImage(workingDC.get(), img->size(), &drawContext); if (!hbmp || !drawContext) return 0; CGImageRef srcImage = img->getCGImageRef(); CGRect rect; rect.size = img->size(); rect.origin.x = 0; rect.origin.y = -rect.size.height; static const CGFloat white [] = {1.0, 1.0, 1.0, 1.0}; CGContextScaleCTM(drawContext, 1, -1); CGContextSetFillColor(drawContext, white); CGContextFillRect(drawContext, rect); if (srcImage) { CGContextSetBlendMode(drawContext, kCGBlendModeNormal); CGContextDrawImage(drawContext, rect, srcImage); } CGContextRelease(drawContext); return hbmp.leak();}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:29,
示例23: CGContextSetRGBFillColorvoid TileGrid::drawTileMapContents(CGContextRef context, CGRect layerBounds) const{ CGContextSetRGBFillColor(context, 0.3, 0.3, 0.3, 1); CGContextFillRect(context, layerBounds); CGFloat scaleFactor = layerBounds.size.width / m_controller.bounds().width(); CGFloat contextScale = scaleFactor / m_scale; CGContextScaleCTM(context, contextScale, contextScale); for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) { const TileInfo& tileInfo = it->value; PlatformCALayer* tileLayer = tileInfo.layer.get(); CGFloat red = 1; CGFloat green = 1; CGFloat blue = 1; CGFloat alpha = 1; if (tileInfo.hasStaleContent) { red = 0.25; green = 0.125; blue = 0; } else if (m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort) { red = 0.8; green = 0.8; blue = 0.8; } TileCohort newestCohort = newestTileCohort(); TileCohort oldestCohort = oldestTileCohort(); if (!m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort) alpha = 1 - (static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort)); CGContextSetRGBFillColor(context, red, green, blue, alpha); if (tileLayer->superlayer()) { CGContextSetLineWidth(context, 0.5 / contextScale); CGContextSetRGBStrokeColor(context, 0, 0, 0, 1); } else { CGContextSetLineWidth(context, 1 / contextScale); CGContextSetRGBStrokeColor(context, 0.2, 0.1, 0.9, 1); } CGRect frame = CGRectMake(tileLayer->position().x(), tileLayer->position().y(), tileLayer->bounds().size().width(), tileLayer->bounds().size().height()); CGContextFillRect(context, frame); CGContextStrokeRect(context, frame); CGContextSetRGBFillColor(context, 0, 0, 0, 0.5); String repaintCount = String::number(m_tileRepaintCounts.get(tileLayer)); CGContextSaveGState(context); tileLayer->drawTextAtPoint(context, frame.origin.x + 64, frame.origin.y + 192, CGSizeMake(3, -3), 58, repaintCount.ascii().data(), repaintCount.length()); CGContextRestoreGState(context); }}
开发者ID:hnney,项目名称:webkit,代码行数:60,
示例24: drawRoundedRectvoid drawRoundedRect(CGContextRef context, int x, int y){ struct CGRect cgRect; struct CGPoint cgPoint; cgRect.size.width = 640; cgRect.size.height = y+30; cgPoint.x = 0; cgPoint.y = 5; cgRect.origin = cgPoint; //printf("Drawing %f, %f, %f, %f", cgPoint.x, cgPoint.y, cgRect.size.width, cgRect.size.height); CGContextBeginPath(context); float ovalWidth = 10; float ovalHeight = 10; float fw, fh; // If the width or height of the corner oval is zero, then it reduces to a right angle, // so instead of a rounded rectangle we have an ordinary one. if (ovalWidth == 0 || ovalHeight == 0) { CGContextAddRect(context, cgRect); return; } // Save the context's state so that the translate and scale can be undone with a call // to CGContextRestoreGState. CGContextSaveGState(context); // Translate the origin of the contex to the lower left corner of the rectangle. CGContextTranslateCTM(context, CGRectGetMinX(cgRect), CGRectGetMinY(cgRect)); //Normalize the scale of the context so that the width and height of the arcs are 1.0 CGContextScaleCTM(context, ovalWidth, ovalHeight); // Calculate the width and height of the rectangle in the new coordinate system. fw = CGRectGetWidth(cgRect) / ovalWidth; fh = CGRectGetHeight(cgRect) / ovalHeight; // CGContextAddArcToPoint adds an arc of a circle to the context's path (creating the rounded // corners). It also adds a line from the path's last point to the begining of the arc, making // the sides of the rectangle. CGContextMoveToPoint(context, fw, fh/2); // Start at lower right corner CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1); // Top right corner CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1); // Top left corner CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1); // Lower left corner CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); // Back to lower right // Close the path CGContextClosePath(context); CGContextSetRGBFillColor (context, 1, 1, 1, 0.7); CGContextFillPath(context); CGContextRestoreGState(context); }
开发者ID:BenPorebski,项目名称:QuickLookPDB,代码行数:60,
示例25: addRoundedRectToPathstatic 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,
示例26: GScreenDCGPrintDC::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,
示例27: CGContextScaleCTMvoid GraphicsContext::scale(const FloatSize& size){ if (paintingDisabled()) return; CGContextScaleCTM(platformContext(), size.width(), size.height()); m_data->scale(size); m_data->m_userToDeviceTransformKnownToBeIdentity = false;}
开发者ID:dslab-epfl,项目名称:warr,代码行数:8,
注:本文中的CGContextScaleCTM函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CGContextTranslateCTM函数代码示例 C++ CGContextSaveGState函数代码示例 |