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


C++ CGColorSpaceRelease函数代码示例

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


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

示例1: TIPGradientAxialFillPath

void TIPGradientAxialFillPath( CGContextRef theContext, TIPGradientRef theGradient, CGPathRef thePath, float angle)
{
    CGRect boundingRect = CGPathGetBoundingBox(thePath);
    CGPoint startPoint;
    CGPoint endPoint;

    TIPGradientFindEndpointsForRotation(boundingRect,angle,&startPoint,&endPoint);

    // CoreGraphics Calls
    CGContextSaveGState(theContext);
    CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
    CGShadingRef myCGShading = CGShadingCreateAxial(colorSpace,startPoint,endPoint,theGradient->gradientFunction,FALSE,FALSE);

    CGContextAddPath(theContext,thePath);
    CGContextClip(theContext);
    CGContextDrawShading(theContext,myCGShading);

    CGShadingRelease(myCGShading);
    CGColorSpaceRelease(colorSpace);
    CGContextRestoreGState(theContext);
}
开发者ID:samiamwork,项目名称:Questionable,代码行数:21,代码来源:TIPGradient.c

示例2: drawingContext

void CanvasRenderingContext2D::applyShadow()
{
    GraphicsContext* c = drawingContext();
    if (!c)
        return;
    // FIXME: Do this through platform-independent GraphicsContext API.
#if PLATFORM(CG)
    RGBA32 rgba = state().m_shadowColor.isEmpty() ? 0 : CSSParser::parseColor(state().m_shadowColor);
    const CGFloat components[4] = {
        ((rgba >> 16) & 0xFF) / 255.0f,
        ((rgba >> 8) & 0xFF) / 255.0f,
        (rgba & 0xFF) / 255.0f,
        ((rgba >> 24) & 0xFF) / 255.0f
    };
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef color = CGColorCreate(colorSpace, components);
    CGColorSpaceRelease(colorSpace);
    CGContextSetShadowWithColor(c->platformContext(), state().m_shadowOffset, state().m_shadowBlur, color);
    CGColorRelease(color);
#endif
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:21,代码来源:CanvasRenderingContext2D.cpp

示例3: darwinToCGImageRef

/**
 * Converts a QPixmap to a CGImage.
 *
 * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
 * @param   aPixmap     Pointer to the QPixmap instance to convert.
 */
CGImageRef darwinToCGImageRef(const QImage *pImage)
{
    QImage *imageCopy = new QImage(*pImage);
    /** @todo this code assumes 32-bit image input, the lazy bird convert image to 32-bit method is anything but optimal... */
    if (imageCopy->format() != QImage::Format_ARGB32)
        *imageCopy = imageCopy->convertToFormat(QImage::Format_ARGB32);
    Assert(!imageCopy->isNull());

    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
    CGDataProviderRef dp = CGDataProviderCreateWithData(imageCopy, pImage->bits(), pImage->numBytes(), darwinDataProviderReleaseQImage);

    CGBitmapInfo bmpInfo = kCGImageAlphaFirst | kCGBitmapByteOrder32Host;
    CGImageRef ir = CGImageCreate(imageCopy->width(), imageCopy->height(), 8, 32, imageCopy->bytesPerLine(), cs,
                                   bmpInfo, dp, 0 /*decode */, 0 /* shouldInterpolate */,
                                   kCGRenderingIntentDefault);
    CGColorSpaceRelease(cs);
    CGDataProviderRelease(dp);

    Assert(ir);
    return ir;
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:27,代码来源:VBoxUtils-darwin.cpp

示例4: GetWindowPort

void QuartzWindow::close() {
  if (!is_open())
    return;
  CGrafPtr gp = GetWindowPort(my_window());
  if (gp != NULL) // already closed by std handler
    QDEndCGContext( gp, &myContext );
  CGColorRelease((CGColorRef) _red);
  CGColorRelease((CGColorRef) _yellow);
  CGColorRelease((CGColorRef) _black);
  CGColorRelease((CGColorRef) _gray);
  CGColorRelease((CGColorRef) _white);
  CGColorSpaceRelease(_color_space);
  WindowSet::rm_window(my_window());
  if (gp != NULL)
    DisposeWindow(my_window());
  _is_open = false; 
  DisposeEventHandlerUPP(_my_event_handler_upp);
  DisposeEventHandlerUPP(_my_spy_event_handler_upp);
  _my_event_handler = NULL;
  _my_spy_event_handler = NULL;
  _quartz_win = NULL;
}
开发者ID:ardeujho,项目名称:self,代码行数:22,代码来源:quartzWindow.cpp

示例5: CGFunctionCreate

CGShadingRef CanvasGradient::platformShading()
{
    if (m_shading)
        return m_shading;

    const CGFloat intervalRanges[2] = { 0, 1 };
    const CGFloat colorComponentRanges[4 * 2] = { 0, 1, 0, 1, 0, 1, 0, 1 };
    const CGFunctionCallbacks gradientCallbacks = { 0, gradientCallback, 0 };
    CGFunctionRef colorFunction = CGFunctionCreate(this, 1, intervalRanges, 4, colorComponentRanges, &gradientCallbacks);

    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

    if (m_radial)
        m_shading = CGShadingCreateRadial(colorSpace, m_p0, m_r0, m_p1, m_r1, colorFunction, true, true);
    else
        m_shading = CGShadingCreateAxial(colorSpace, m_p0, m_p1, colorFunction, true, true);

    CGColorSpaceRelease(colorSpace);
    CGFunctionRelease(colorFunction);

    return m_shading;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:22,代码来源:CanvasGradient.cpp

示例6: CGimageResize

CGImageRef CGimageResize(CGImageRef image, CGSize maxSize)
{
    // calcualte size
    CGFloat ratio = MAX(CGImageGetWidth(image)/maxSize.width,CGImageGetHeight(image)/maxSize.height);
    size_t width = CGImageGetWidth(image)/ratio;
    size_t height = CGImageGetHeight(image)/ratio;
    // resize
    CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = CGBitmapContextCreate(NULL, width, height,
                                                 8, width*4, colorspace, kCGImageAlphaPremultipliedLast);
    CGColorSpaceRelease(colorspace);
    
    if(context == NULL) return nil;
    
    // draw image to context (resizing it)
    CGContextDrawImage(context, CGRectMake(0, 0, width, height), image);
    // extract resulting image from context
    CGImageRef imgRef = CGBitmapContextCreateImage(context);
    CGContextRelease(context);
    
    return imgRef;
}
开发者ID:zydeco,项目名称:ottd_preview,代码行数:22,代码来源:GenerateThumbnailForURL.c

示例7: createContextWithBitmap

static CGContextRef createContextWithBitmap(CFX_DIBitmap* pBitmap)
{
    if (!pBitmap || pBitmap->IsCmykImage() || pBitmap->GetBPP() < 32) {
        return NULL;
    }
    CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Little;
    if (pBitmap->HasAlpha()) {
        bitmapInfo |= kCGImageAlphaPremultipliedFirst;
    } else {
        bitmapInfo |= kCGImageAlphaNoneSkipFirst;
    }
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = CGBitmapContextCreate(pBitmap->GetBuffer(),
                           pBitmap->GetWidth(),
                           pBitmap->GetHeight(),
                           8,
                           pBitmap->GetPitch(),
                           colorSpace,
                           bitmapInfo);
    CGColorSpaceRelease(colorSpace);
    return context;
}
开发者ID:151706061,项目名称:PDFium,代码行数:22,代码来源:fx_quartz_device.cpp

示例8: os_image_save_to_file

void os_image_save_to_file(const char* filename, unsigned char* data, int width, int height, int channels) {
  assert((channels == 3) || (channels == 4));

  const int bytesPerRow = (width * channels);
  const int bytesPerImage = (bytesPerRow * height);
  const int bitsPerChannel = 8;
  const int bitsPerPixel = (bitsPerChannel * channels);

  CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
  CFDataRef rgbData = CFDataCreate(NULL, data, bytesPerImage);
  CGDataProviderRef provider = CGDataProviderCreateWithCFData(rgbData);
  CGImageRef imageRef = CGImageCreate(
    width,
    height,
    bitsPerChannel,
    bitsPerPixel,
    bytesPerRow,
    colorspace,
    kCGBitmapByteOrderDefault,
    provider,
    NULL,
    true,
    kCGRenderingIntentDefault);
  CFRelease(rgbData);
  CGDataProviderRelease(provider);
  CGColorSpaceRelease(colorspace);

  CFURLRef url = CFURLCreateFromFileSystemRepresentation(NULL, (const uint8_t*)filename, (CFIndex)strlen(filename), false);
  CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypePNG, 1, NULL);
  CGImageDestinationAddImage(destination, imageRef, nil);

  if (!CGImageDestinationFinalize(destination)) {
    fprintf(stderr, "Failed to write image to %s\n", filename);
  }

  CFRelease(destination);
  CFRelease(url);
  CGImageRelease(imageRef);
}
开发者ID:anshulnsit,项目名称:MDig,代码行数:39,代码来源:os_image_save.cpp

示例9: CGColorSpaceCreateDeviceRGB

bool GiCanvasIosImpl::createBufferBitmap(float width, float height)
{
    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);
    
    // 坐标系改为Y朝下,原点在左上角,这样除了放大倍数为1外,其余就与 _context 坐标系一致
    if (_buffctx) {
        CGContextTranslateCTM(_buffctx, 0, height);
        CGContextScaleCTM(_buffctx, _scale, - _scale);
    }
    
    return !!_buffctx;
}
开发者ID:fanliugen,项目名称:touchvg,代码行数:22,代码来源:ioscanvas.cpp

示例10: ReadInfo

bool nglImageCGCodec::Feed(nglIStream* pIStream)
{
  if (!mpCGImage)
  {
    mpCGImage = ReadInfo(pIStream); ///< shall allocate the buffer
  }
  if (!mpCGImage)
    return false;

  mpIStream = pIStream;
// Use the generic RGB color space.
  CGColorSpaceRef pCGColors = CGColorSpaceCreateDeviceRGB();
  if (pCGColors == NULL)
  {
    NGL_OUT(_T("nglImageCGCodec::Feed Error allocating color space\n"));
    return false;
  }

  nglImageInfo info;
  mpImage->GetInfo(info);
  NGL_ASSERT(info.mpBuffer);

// Create the bitmap context. 
// The image will be converted to the format specified here by CGBitmapContextCreate.
  CGContextRef pCGContext =
    CGBitmapContextCreate(info.mpBuffer, info.mWidth, info.mHeight,
                          info.mBitDepth/4, info.mBytesPerLine,
                          pCGColors, kCGImageAlphaPremultipliedLast);//kCGImageAlphaPremultipliedFirst);

  CGColorSpaceRelease(pCGColors);
  CGRect rect = { {0,0}, {info.mWidth, info.mHeight} };
  CGContextClearRect(pCGContext, rect);
  CGContextDrawImage(pCGContext, rect, mpCGImage);
  CGContextRelease(pCGContext);

  SendData(1.0f);
  return (pIStream->GetState()==eStreamWait) || (pIStream->GetState()==eStreamReady);;
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:38,代码来源:nglImageCGCodec.cpp

示例11: SkCreateCGImageRefWithColorspace

CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm,
                                            CGColorSpaceRef colorSpace) {
    size_t bitsPerComponent SK_INIT_TO_AVOID_WARNING;
    CGBitmapInfo info       SK_INIT_TO_AVOID_WARNING;

    SkBitmap* bitmap = prepareForImageRef(bm, &bitsPerComponent, &info);
    if (NULL == bitmap) {
        return NULL;
    }

    const int w = bitmap->width();
    const int h = bitmap->height();
    const size_t s = bitmap->getSize();

    // our provider "owns" the bitmap*, and will take care of deleting it
    // we initially lock it, so we can access the pixels. The bitmap will be deleted in the release
    // proc, which will in turn unlock the pixels
    bitmap->lockPixels();
    CGDataProviderRef dataRef = CGDataProviderCreateWithData(bitmap, bitmap->getPixels(), s,
                                                             SkBitmap_ReleaseInfo);

    bool releaseColorSpace = false;
    if (NULL == colorSpace) {
        colorSpace = CGColorSpaceCreateDeviceRGB();
        releaseColorSpace = true;
    }

    CGImageRef ref = CGImageCreate(w, h, bitsPerComponent,
                                   bitmap->bytesPerPixel() * 8,
                                   bitmap->rowBytes(), colorSpace, info, dataRef,
                                   NULL, false, kCGRenderingIntentDefault);

    if (releaseColorSpace) {
        CGColorSpaceRelease(colorSpace);
    }
    CGDataProviderRelease(dataRef);
    return ref;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_skia_src,代码行数:38,代码来源:SkCreateCGImageRef.cpp

示例12: main

int main(int argc, const char * argv[])
{
    size_t width = 2000;
    size_t height = 2000;
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = CGBitmapContextCreate(nullptr, width, height, 8, width * 4, colorSpace, kCGImageAlphaNoneSkipLast);
    CGColorSpaceRelease(colorSpace);
    const std::vector<uint8_t> fontVector = generateFont();
    std::ofstream outputFile("/Volumes/Data/home/mmaxfield/tmp/output.otf", std::ios::out | std::ios::binary);
    for (uint8_t b : fontVector)
        outputFile << b;
    outputFile.close();
    
    CFDataRef fontData = CFDataCreate(kCFAllocatorDefault, fontVector.data(), fontVector.size());
    CTFontDescriptorRef fontDescriptor = CTFontManagerCreateFontDescriptorFromData(fontData);
    CFRelease(fontData);

    CFTypeRef featureValues[] = { CFSTR("liga"), CFSTR("clig"), CFSTR("dlig"), CFSTR("hlig"), CFSTR("calt"), CFSTR("subs"), CFSTR("sups"), CFSTR("smcp"), CFSTR("c2sc"), CFSTR("pcap"), CFSTR("c2pc"), CFSTR("unic"), CFSTR("titl"), CFSTR("onum"), CFSTR("pnum"), CFSTR("tnum"), CFSTR("frac"), CFSTR("afrc"), CFSTR("ordn"), CFSTR("zero"), CFSTR("hist"), CFSTR("jp78"), CFSTR("jp83"), CFSTR("jp90"), CFSTR("jp04"), CFSTR("smpl"), CFSTR("trad"), CFSTR("fwid"), CFSTR("pwid"), CFSTR("ruby") };
    CFArrayRef features = CFArrayCreate(kCFAllocatorDefault, featureValues, 30, &kCFTypeArrayCallBacks);

    for (CFIndex i = 0; i < CFArrayGetCount(features); ++i) {
        drawTextWithFeature(context, fontDescriptor, static_cast<CFStringRef>(CFArrayGetValueAtIndex(features, i)), 1, CGPointMake(25, 1950 - 50 * i));
        drawTextWithFeature(context, fontDescriptor, static_cast<CFStringRef>(CFArrayGetValueAtIndex(features, i)), 0, CGPointMake(25, 1925 - 50 * i));
    }

    CFRelease(features);
    CFRelease(fontDescriptor);
    CGImageRef image = CGBitmapContextCreateImage(context);
    CGContextRelease(context);
    CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("/Volumes/Data/home/mmaxfield/tmp/output.png"), kCFURLPOSIXPathStyle, FALSE);
    CGImageDestinationRef imageDestination = CGImageDestinationCreateWithURL(url, kUTTypePNG, 1, nullptr);
    CFRelease(url);
    CGImageDestinationAddImage(imageDestination, image, nullptr);
    CGImageRelease(image);
    CGImageDestinationFinalize(imageDestination);
    CFRelease(imageDestination);
    return 0;
}
开发者ID:rodrigo-speller,项目名称:webkit,代码行数:38,代码来源:main.cpp

示例13: CGContextWithHDC

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

    GetObject(bitmap, sizeof(info), &info);
    ASSERT(info.bmBitsPixel == 32);

    CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Little | (hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst);
    CGContextRef context = CGBitmapContextCreate(info.bmBits, info.bmWidth, info.bmHeight, 8,
                                                 info.bmWidthBytes, deviceRGB, bitmapInfo);
    CGColorSpaceRelease(deviceRGB);

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

示例14: CreateOpBitmapFromIcon

OpBitmap* CreateOpBitmapFromIcon(IconRef iconin, int cx, int cy)
{
	if (iconin)
	{
		OpBitmap* bm;
		if (OpStatus::IsSuccess(OpBitmap::Create(&bm, cx, cy, FALSE, TRUE, 0, 0, TRUE)))
		{
			CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
			void* p = bm->GetPointer(OpBitmap::ACCESS_WRITEONLY);
			memset(p, 0, bm->Height()*bm->GetBytesPerLine());
			CGBitmapInfo alpha = kCGBitmapByteOrderVegaInternal;
			CGContextRef ctx = 	CGBitmapContextCreate(p, bm->Width(), bm->Height(), 8, bm->GetBytesPerLine(), colorSpace, alpha);
			CGColorSpaceRelease(colorSpace);
			CGRect cgrect = CGRectMake(0,0,cx,cy);
			PlotIconRefInContext(ctx, &cgrect, kAlignAbsoluteCenter, kTransformNone, NULL, kPlotIconRefNormalFlags, iconin);
			CGContextFlush(ctx);
			CGContextRelease(ctx);
			bm->ReleasePointer();
			return bm;
		}
	}
	return NULL;
}
开发者ID:prestocore,项目名称:browser,代码行数:23,代码来源:MacIcons.cpp

示例15: CGImageMaskCreateWithImageRef

CGImageRef CGImageMaskCreateWithImageRef(CGImageRef imageRef) {
  size_t maskWidth = CGImageGetWidth(imageRef);
  size_t maskHeight = CGImageGetHeight(imageRef);
  size_t bytesPerRow = maskWidth;
  size_t bufferSize = maskWidth * maskHeight;

  CFMutableDataRef dataBuffer = CFDataCreateMutable(kCFAllocatorDefault, 0);
  CFDataSetLength(dataBuffer, bufferSize);

  CGColorSpaceRef greyColorSpaceRef = CGColorSpaceCreateDeviceGray();
  CGContextRef ctx = CGBitmapContextCreate(CFDataGetMutableBytePtr(dataBuffer),
                                           maskWidth,
                                           maskHeight,
                                           8,
                                           bytesPerRow,
                                           greyColorSpaceRef,
                                           kCGImageAlphaNone);

  CGContextDrawImage(ctx, CGRectMake(0, 0, maskWidth, maskHeight), imageRef);
  CGContextRelease(ctx);

  CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(dataBuffer);
  CGImageRef maskImageRef = CGImageMaskCreate(maskWidth,
                                              maskHeight,
                                              8,
                                              8,
                                              bytesPerRow,
                                              dataProvider,
                                              NULL,
                                              FALSE);

  CGDataProviderRelease(dataProvider);
  CGColorSpaceRelease(greyColorSpaceRef);
  CFRelease(dataBuffer);

  return maskImageRef;
}
开发者ID:Bilue,项目名称:NDVKit,代码行数:37,代码来源:CGImage+NDVAdditions.c


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