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


C++ CGImageCreate函数代码示例

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


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

示例1: quartz_format

static void quartz_format(GVJ_t *job)
{
	/* image destination -> data consumer -> job's gvdevice */
	/* data provider <- job's imagedata */
	CGDataConsumerRef data_consumer = CGDataConsumerCreate(job, &device_data_consumer_callbacks);
	CGImageDestinationRef image_destination = CGImageDestinationCreateWithDataConsumer(data_consumer, format_uti[job->device.id], 1, NULL);
	CGDataProviderRef data_provider = CGDataProviderCreateDirect(job->imagedata, BYTES_PER_PIXEL * job->width * job->height, &memory_data_provider_callbacks);
	
	/* add the bitmap image to the destination and save it */
	CGColorSpaceRef color_space = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
	CGImageRef image = CGImageCreate (
		job->width,							/* width in pixels */
		job->height,						/* height in pixels */
		BITS_PER_COMPONENT,					/* bits per component */
		BYTES_PER_PIXEL * 8,				/* bits per pixel */
		BYTES_PER_PIXEL * job->width,		/* bytes per row: exactly width # of pixels */
		color_space,						/* color space: sRGB */
		kCGImageAlphaPremultipliedFirst,	/* bitmap info: corresponds to CAIRO_FORMAT_ARGB32 */
		data_provider,						/* data provider: from imagedata */
		NULL,								/* decode: don't remap colors */
		FALSE,								/* don't interpolate */
		kCGRenderingIntentDefault			/* rendering intent (what to do with out-of-gamut colors): default */
	);
	CGImageDestinationAddImage(image_destination, image, NULL);
	CGImageDestinationFinalize(image_destination);
	
	/* clean up */
	CGImageRelease(image);
	CGColorSpaceRelease(color_space);
	CGDataProviderRelease(data_provider);
	if (image_destination)
		CFRelease(image_destination);
	CGDataConsumerRelease(data_consumer);
}
开发者ID:nyue,项目名称:graphviz-cmake,代码行数:34,代码来源:gvdevice_quartz.c

示例2: icvPutImage

/* update imageRef */
static void icvPutImage( CvWindow* window )
{
    Assert( window != 0 );
    if( window->image == 0 ) return;
    
    CGColorSpaceRef colorspace = NULL;
    CGDataProviderRef provider = NULL;
    int width = window->imageWidth = window->image->cols;
    int height = window->imageHeight = window->image->rows;
    
    colorspace = CGColorSpaceCreateDeviceRGB();
    
    int size = 8;
    int nbChannels = 3;
    
    provider = CGDataProviderCreateWithData(NULL, window->image->data.ptr, width * height , NULL );
    
    if (window->imageRef != NULL){
        CGImageRelease(window->imageRef);
        window->image == NULL;
    }
    
    window->imageRef = CGImageCreate( width, height, size , size*nbChannels , window->image->step, colorspace,  kCGImageAlphaNone , provider, NULL, true, kCGRenderingIntentDefault );
    icvDrawImage( window );
}
开发者ID:DORARA29,项目名称:AtomManipulator,代码行数:26,代码来源:window_carbon.cpp

示例3: gtkosx_create_cgimage_from_pixbuf

CGImageRef
gtkosx_create_cgimage_from_pixbuf (GdkPixbuf *pixbuf)
{
  CGColorSpaceRef   colorspace;
  CGDataProviderRef data_provider;
  CGImageRef        image;
  void             *data;
  gint              rowstride;
  gint              pixbuf_width, pixbuf_height;
  gboolean          has_alpha;

  pixbuf_width = gdk_pixbuf_get_width (pixbuf);
  pixbuf_height = gdk_pixbuf_get_height (pixbuf);
  rowstride = gdk_pixbuf_get_rowstride (pixbuf);
  has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);

  data = gdk_pixbuf_get_pixels (pixbuf);

  colorspace = CGColorSpaceCreateDeviceRGB ();
  data_provider = CGDataProviderCreateWithData (NULL, data,
                  pixbuf_height * rowstride,
                  NULL);

  image = CGImageCreate (pixbuf_width, pixbuf_height, 8,
                         has_alpha ? 32 : 24, rowstride,
                         colorspace,
                         has_alpha ? kCGImageAlphaLast : 0,
                         data_provider, NULL, FALSE,
                         kCGRenderingIntentDefault);

  CGDataProviderRelease (data_provider);
  CGColorSpaceRelease (colorspace);

  return image;
}
开发者ID:TingPing,项目名称:gtk-mac-integration,代码行数:35,代码来源:gtk-mac-image-utils.c

示例4: qt_mac_image_to_cgimage

CGImageRef qt_mac_image_to_cgimage(const QImage &image)
{
    int bitsPerColor = 8;
    int bitsPerPixel = 32;
    if (image.depth() == 1) {
        bitsPerColor = 1;
        bitsPerPixel = 1;
    }
    QCFType<CGDataProviderRef> provider =
        CGDataProviderCreateWithData(0, image.bits(), image.bytesPerLine() * image.height(),
                                     0);

    uint cgflags = kCGImageAlphaPremultipliedFirst;
#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
    cgflags |= kCGBitmapByteOrder32Host;
#endif

    CGImageRef cgImage = CGImageCreate(image.width(), image.height(), bitsPerColor, bitsPerPixel,
                                       image.bytesPerLine(),
                                       QCoreGraphicsPaintEngine::macGenericColorSpace(),
                                       cgflags, provider,
                                       0,
                                       0,
                                       kCGRenderingIntentDefault);

    return cgImage;
}
开发者ID:jbartolozzi,项目名称:CIS462_HW1,代码行数:27,代码来源:qpixmap_mac.cpp

示例5: CFDictionaryCreate

//-----------------------------------------------------------------------------
CGImageRef CGBitmap::getCGImage ()
{
	if (image == 0 && imageSource)
	{
		const void* keys[] = {kCGImageSourceShouldCache, kCGImageSourceShouldPreferRGB32};
		const void* values[] = {kCFBooleanTrue, kCFBooleanTrue};
		CFDictionaryRef options = CFDictionaryCreate (NULL, keys, values, 2, NULL, NULL);
		image = CGImageSourceCreateImageAtIndex (imageSource, 0, options);
		CFRelease (imageSource);
		CFRelease (options);
		imageSource = 0;
	}
	if ((dirty || image == 0) && bits)
	{
		freeCGImage ();

		size_t rowBytes = getBytesPerRow ();
		size_t byteCount = rowBytes * size.y;
		size_t bitDepth = 32;

		CGDataProviderRef provider = CGDataProviderCreateWithData (NULL, bits, byteCount, NULL);
		CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Big;
		image = CGImageCreate (size.x, size.y, 8, bitDepth, rowBytes, GetCGColorSpace (), bitmapInfo, provider, NULL, false, kCGRenderingIntentDefault);
		CGDataProviderRelease (provider);
		dirty = false;
	}
	return image;
}
开发者ID:DaniM,项目名称:lyngo,代码行数:29,代码来源:cgbitmap.cpp

示例6: create_image_from_surface

static CGImageRef
create_image_from_surface (cairo_image_surface_t *image_surface, void *data)
{
    CGImageRef image;
    CGColorSpaceRef color_space;
    CGDataProviderRef data_provider;
    int width, height;

    width = cairo_image_surface_get_width ((cairo_surface_t *)image_surface);
    height = cairo_image_surface_get_height ((cairo_surface_t *)image_surface);

    color_space = CGColorSpaceCreateDeviceRGB();
    data_provider = CGDataProviderCreateWithData (NULL, data,
                    width * height * 4, NULL);
    image = CGImageCreate (width, height,
                           8, 32,
                           width * 4,
                           color_space,
                           kCGImageAlphaPremultipliedFirst,
                           data_provider,
                           NULL,
                           FALSE, kCGRenderingIntentDefault);

    CGColorSpaceRelease (color_space);
    CGDataProviderRelease (data_provider);

    return image;
}
开发者ID:nihed,项目名称:magnetism,代码行数:28,代码来源:cairo-quartz-surface.c

示例7: screeninit

void
screeninit(void)
{
	int fmt;
	int dx, dy;
	ProcessSerialNumber psn = { 0, kCurrentProcess };
	TransformProcessType(&psn, kProcessTransformToForegroundApplication);
	SetFrontProcess(&psn);

	fmt = XBGR32; //XRGB32;
	devRect = max_bounds();
	dx = devRect.size.width;
	dy = devRect.size.height;

	gscreen = allocmemimage(Rect(0,0,dx,dy), fmt);
	dataProviderRef = CGDataProviderCreateWithData(0, gscreen->data->bdata,
					dx * dy * 4, 0);
	fullScreenImage = CGImageCreate(dx, dy, 8, 32, dx * 4,
				CGColorSpaceCreateDeviceRGB(),
				kCGImageAlphaNoneSkipLast,
				dataProviderRef, 0, 0, kCGRenderingIntentDefault);

	devRect = CGDisplayBounds(CGMainDisplayID());

	kproc("osxscreen", winproc, nil, 0);
	kproc("osxflush", flushproc, nil, 0);
	Sleep(&rend, isready, nil);
}
开发者ID:Vykook,项目名称:acme-sac,代码行数:28,代码来源:win.c

示例8: MCGRasterToCGImage

bool MCGRasterToCGImage(const MCGRaster &p_raster, const MCGIntegerRectangle &p_src_rect, CGColorSpaceRef p_colorspace, bool p_copy, bool p_invert, CGImageRef &r_image)
{
	bool t_success = true;
	
	CGImageRef t_image = nil;
	CGDataProviderRef t_data_provider = nil;
	uint32_t t_dst_stride;

	if (t_success)
		t_success = MCGRasterCreateCGDataProvider(p_raster, p_src_rect, p_copy, p_invert, t_data_provider, t_dst_stride);
	
	// IM-2014-05-20: [[ GraphicsPerformance ]] Opaque rasters should indicate no alpha in the bitmap info
	bool t_alpha;
	t_alpha = p_raster.format != kMCGRasterFormat_xRGB;
	
	// IM-2013-08-21: [[ RefactorGraphics ]] Refactor CGImage creation code to be pixel-format independent
	CGBitmapInfo t_bm_info;
	t_bm_info = MCGPixelFormatToCGBitmapInfo(kMCGPixelFormatNative, t_alpha);
	
	if (t_success)
	{
		t_image = CGImageCreate(p_src_rect.size.width, p_src_rect.size.height, 8, 32, t_dst_stride, p_colorspace, t_bm_info, t_data_provider, nil, true, kCGRenderingIntentDefault);
		t_success = t_image != nil;
	}
	
	CGDataProviderRelease(t_data_provider);
	
	if (t_success)
		r_image = t_image;
	
	return t_success;
}
开发者ID:soapdog,项目名称:livecode,代码行数:32,代码来源:cgimageutil.cpp

示例9: MCAlphaToCGImage

static bool MCAlphaToCGImage(uindex_t p_width, uindex_t p_height, uint8_t* p_data, uindex_t p_stride, CGImageRef &r_image)
{
	bool t_success = true;
	
	CGImageRef t_image = nil;
	CGColorSpaceRef t_colorspace = nil;
	CFDataRef t_data = nil;
	CGDataProviderRef t_dp = nil;
	
	if (t_success)
		t_success = nil != (t_data = CFDataCreate(kCFAllocatorDefault, (uint8_t*)p_data, p_stride * p_height));
	
	if (t_success)
		t_success = nil != (t_dp = CGDataProviderCreateWithCFData(t_data));
	
	if (t_success)
		t_success = nil != (t_colorspace = CGColorSpaceCreateDeviceGray());
	
	if (t_success)
		t_success = nil != (t_image = CGImageCreate(p_width, p_height, 8, 8, p_stride, t_colorspace, kCGImageAlphaNone, t_dp, nil, false, kCGRenderingIntentDefault));
	
	CGColorSpaceRelease(t_colorspace);
	CGDataProviderRelease(t_dp);
	CFRelease(t_data);
	
	if (t_success)
		r_image = t_image;
	
	return t_success;
}
开发者ID:soapdog,项目名称:livecode,代码行数:30,代码来源:osximage.cpp

示例10: adoptCF

void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& point)
{
    // FIXME: Creating CFData is non-optimal, but needed to avoid crashing when printing.  Ideally we should 
    // make a custom CGDataProvider that controls the WindowsBitmap lifetime.  see <rdar://6394455>
    RetainPtr<CFDataRef> imageData = adoptCF(CFDataCreate(kCFAllocatorDefault, image->buffer(), image->bufferLength()));
    RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(imageData.get()));
    RetainPtr<CGImageRef> cgImage = adoptCF(CGImageCreate(image->size().width(), image->size().height(), 8, 32, image->bytesPerRow(), deviceRGBColorSpaceRef(),
                                                         kCGBitmapByteOrder32Little | kCGImageAlphaFirst, dataProvider.get(), 0, true, kCGRenderingIntentDefault));
    CGContextDrawImage(m_data->m_cgContext.get(), CGRectMake(point.x(), point.y(), image->size().width(), image->size().height()), cgImage.get());   
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:10,代码来源:GraphicsContextCGWin.cpp

示例11: CGImageCreate_wrap

CGImageRef CGImageCreate_wrap( float w, float h, 
                               uint32 bitsPerComponent, uint32 bitsPerPixel,
                               uint32 bytesPerRow, 
                               CGColorSpaceRef colorSpace,
                               uint32 bitmapInfo,
                               CGDataProviderRef provider,
                               bool shouldInterpolate,
                               uint32 colorRenderingIntent) {
  return CGImageCreate(w, h, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpace,
                       bitmapInfo, provider, NULL, shouldInterpolate,
                       CGColorRenderingIntent(colorRenderingIntent));;
}
开发者ID:AaronNGray,项目名称:self,代码行数:12,代码来源:quartzPrims.cpp

示例12: createCGImageFromGradient

CGImageRef createCGImageFromGradient(int                 width,
                                     int                 height,
                                     pixelfmt_rgbx8888_t start,
                                     pixelfmt_rgbx8888_t end,
                                     int                 direction)
{
  int                bpp;
  size_t             bytesPerRow;
  size_t             bytesPerImage;
  void              *base;
  void             (*drawGradient)(uint32_t *base,
                                   int       width,
                                   size_t    bytesPerRow,
                                   int       height);
  CGColorSpaceRef    rgbColourSpace;
  CGDataProviderRef  dataProvider;
  CGImageRef         image;

  bpp           = 32;
  bytesPerRow   = ROWBYTES16ALIGNED(width, bpp);
  bytesPerImage = bytesPerRow * height;

  base = malloc(bytesPerImage);
  if (base == NULL)
    return NULL;

  setupGradient32bpp(start, end);
  drawGradient = (direction == 0) ? drawXGradient32bpp : drawYGradient32bpp;
  drawGradient(base, width, bytesPerRow, height);

  rgbColourSpace = CGColorSpaceCreateDeviceRGB();

  dataProvider = CGDataProviderCreateWithData(NULL,
                                              base,
                                              bytesPerImage,
                                              releaseDataCallback);

  image = CGImageCreate(width, height,
                        8, bpp,
                        bytesPerRow,
                        rgbColourSpace,
                        kCGImageAlphaNoneSkipLast,
                        dataProvider,
                        NULL, // decode array
                        false, // should interpolate
                        kCGRenderingIntentDefault);

  CGDataProviderRelease(dataProvider);

  CGColorSpaceRelease(rgbColourSpace);

  return image;
}
开发者ID:dpt,项目名称:MotionMasks,代码行数:53,代码来源:ImageGenerators.c

示例13: NZCGImageCreateUsingWebPData

CGImageRef NZCGImageCreateUsingWebPData(CFDataRef webPData)
{
	uint8 *y = NULL, *u = NULL, *v = NULL;
	int32_t width, height;
	
	if (CFDataGetLength(webPData) > INT_MAX)	// highly unlikely to happen; just checking anyway
		return NULL;
	
	// Step 1: Decode the data.
	if (WebPDecode(CFDataGetBytePtr(webPData), (int)CFDataGetLength(webPData), &y, &u, &v, &width, &height) == webp_success)
	{
		const int32_t depth = 32;
		const int wordsPerLine = (width*depth+31)/32;
		size_t pixelBytesLength = 4*height*wordsPerLine;	// Google's documentation is incorrect here; the length has to be quadrupled or we'll have an overrun
		uint32 *pixelBytes = malloc(pixelBytesLength);
		CFDataRef pixelData;
		CGDataProviderRef dataProvider;
		CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
		CGImageRef theImage;
		
		// Step 2: Convert the YUV data into RGB.
		YUV420toRGBA(y, u, v, wordsPerLine, width, height, pixelBytes);
		
		// Step 3: Convert the RGB data into a CGImageRef.
		pixelData = CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)pixelBytes, pixelBytesLength, NULL);
		dataProvider = CGDataProviderCreateWithCFData(pixelData);
		theImage = CGImageCreate(width,
								 height,
								 8,		// each component is one byte or 8 bits large
								 32,	// our data has four components
								 wordsPerLine*4,	// there are 32 bits or 4 bytes in a word
								 colorSpace,
								 kCGBitmapByteOrder32Host,	// our data is in host-endian format
								 dataProvider,
								 NULL,	// we don't care about decode arrays
								 true,	// sure, why not interpolate?
								 kCGRenderingIntentDefault);
		
		// Finally, clean up memory.
		CGColorSpaceRelease(colorSpace);
		CGDataProviderRelease(dataProvider);
		CFRelease(pixelData);
		free(y);
		return theImage;
	}
	fprintf(stderr, "NZCGWebPFunctions: The data provided is not in WebP format.\n");
	return NULL;
}
开发者ID:Web5design,项目名称:weppy,代码行数:48,代码来源:NZCGWebPFunctions.c

示例14: ImageDataToDataURL

String ImageDataToDataURL(const ImageData& source, const String& mimeType, const double* quality)
{
    ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));

    RetainPtr<CFStringRef> uti = utiFromMIMEType(mimeType);
    ASSERT(uti);

    CGImageAlphaInfo dataAlphaInfo = kCGImageAlphaLast;
    unsigned char* data = source.data()->data();
    Vector<uint8_t> premultipliedData;

    if (CFEqual(uti.get(), jpegUTI())) {
        // JPEGs don't have an alpha channel, so we have to manually composite on top of black.
        size_t size = 4 * source.width() * source.height();
        if (!premultipliedData.tryReserveCapacity(size))
            return "data:,";

        premultipliedData.resize(size);
        unsigned char *buffer = premultipliedData.data();
        for (size_t i = 0; i < size; i += 4) {
            unsigned alpha = data[i + 3];
            if (alpha != 255) {
                buffer[i + 0] = data[i + 0] * alpha / 255;
                buffer[i + 1] = data[i + 1] * alpha / 255;
                buffer[i + 2] = data[i + 2] * alpha / 255;
            } else {
                buffer[i + 0] = data[i + 0];
                buffer[i + 1] = data[i + 1];
                buffer[i + 2] = data[i + 2];
            }
        }

        dataAlphaInfo = kCGImageAlphaNoneSkipLast; // Ignore the alpha channel.
        data = premultipliedData.data();
    }

    RetainPtr<CGDataProviderRef> dataProvider;
    dataProvider = adoptCF(CGDataProviderCreateWithData(0, data, 4 * source.width() * source.height(), 0));
    if (!dataProvider)
        return "data:,";

    RetainPtr<CGImageRef> image;
    image = adoptCF(CGImageCreate(source.width(), source.height(), 8, 32, 4 * source.width(),
                                deviceRGBColorSpaceRef(), kCGBitmapByteOrderDefault | dataAlphaInfo,
                                dataProvider.get(), 0, false, kCGRenderingIntentDefault));

    return CGImageToDataURL(image.get(), mimeType, quality);
}
开发者ID:TigerLau1985,项目名称:webkit,代码行数:48,代码来源:ImageBufferCG.cpp

示例15: CGColorSpaceCreateDeviceRGB

CGImageRef UIMachineView::frameBuffertoCGImageRef(UIFrameBuffer *pFrameBuffer)
{
    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
    Assert(cs);
    /* Create the image copy of the framebuffer */
    CGDataProviderRef dp = CGDataProviderCreateWithData(pFrameBuffer, pFrameBuffer->address(), pFrameBuffer->bitsPerPixel() / 8 * pFrameBuffer->width() * pFrameBuffer->height(), NULL);
    Assert(dp);
    CGImageRef ir = CGImageCreate(pFrameBuffer->width(), pFrameBuffer->height(), 8, 32, pFrameBuffer->bytesPerLine(), cs,
                                  kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0, false,
                                  kCGRenderingIntentDefault);
    Assert(ir);
    CGDataProviderRelease(dp);
    CGColorSpaceRelease(cs);

    return ir;
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:16,代码来源:UIMachineView.cpp


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