您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CGImageCreate函数代码示例

51自学网 2021-06-01 19:59:51
  C++
这篇教程C++ CGImageCreate函数代码示例写得很实用,希望能帮到您。

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

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


示例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,


示例3: gtkosx_create_cgimage_from_pixbuf

CGImageRefgtkosx_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,


示例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,


示例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,


示例6: create_image_from_surface

static CGImageRefcreate_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,


示例7: screeninit

voidscreeninit(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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例16: ACSharedArtImageSourceCreateImageAtIndex

CGImageRef ACSharedArtImageSourceCreateImageAtIndex(ACSharedArtImageSourceRef isrc, size_t index){	if (index >= ACSharedArtImageSourceGetEntryCount(isrc))		return NULL;		struct __ACSharedArtImageHeaderDataInfo dataInfoAtIndex = isrc->header->data_info[index];	CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL,										(const void *) (ACSharedArtGetBytePtr(isrc->owner) + dataInfoAtIndex.relativeOffset + isrc->owner->header->dataOffset), 										dataInfoAtIndex.length,									    0);	CGColorSpaceRef clrSpace = CGColorSpaceCreateDeviceRGB();	CGImageRef imageRef = CGImageCreate(dataInfoAtIndex.width,dataInfoAtIndex.height,8,32,dataInfoAtIndex.width * 4,clrSpace,2,dataProvider,0,1,0);	CGColorSpaceRelease(clrSpace);	CGDataProviderRelease(dataProvider);	return imageRef;}
开发者ID:jlazarow,项目名称:artcore,代码行数:16,


示例17: CGColorSpaceCreateDeviceRGB

void MacVegaPrinterListener::DrawBitmapClipped(const OpBitmap* bitmap, const OpRect& source, OpPoint p){	CGColorSpaceRef device = CGColorSpaceCreateDeviceRGB();	size_t data_size = bitmap->GetBytesPerLine()*bitmap->Height();	void* bitmap_data = malloc(data_size);	const void* source_data = const_cast<OpBitmap*>(bitmap)->GetPointer(OpBitmap::ACCESS_READONLY);	memcpy(bitmap_data, source_data, data_size);	const_cast<OpBitmap*>(bitmap)->ReleasePointer(FALSE);		CGDataProviderRef provider = CGDataProviderCreateWithData(bitmap_data, bitmap_data, data_size, DeleteBuffer);	CGImageRef image = CGImageCreate(bitmap->Width(), bitmap->Height(), 8, 32, bitmap->GetBytesPerLine(), device, kCGBitmapByteOrderVegaInternal, provider, NULL, true, kCGRenderingIntentAbsoluteColorimetric);	CGContextDrawImage(m_ctx, CGRectMake(source.x+p.x, m_winHeight-(source.y+p.y+source.height), source.width, source.height), image);	CFRelease(provider);	CFRelease(device);	CGImageRelease(image);}
开发者ID:prestocore,项目名称:browser,代码行数:16,


示例18: drawGraphic

void drawGraphic( CGContextRef context, float x, float y ){    static GWorldPtr imageGW = NULL;    static CGImageRef imageRef = NULL;    static CGDataProviderRef dataProviderRef = NULL;    Rect bounds;    static size_t width;    static size_t height;    size_t bitsPerComponent;    size_t bitsPerPixel;    size_t bytesPerRow;    PixMapHandle pmh;            //	Load the image if we haven't already    if ( NULL == imageGW )    {        //	Load and create the GWorld        imageGW = OpenImage();                if ( imageGW != NULL )        {                        GetPortBounds( imageGW, &bounds );            width = bounds.right - bounds.left;            height = bounds.bottom - bounds.top;                        pmh = GetPortPixMap( imageGW );            bitsPerComponent = (**pmh).cmpSize;            bitsPerPixel = (**pmh).pixelSize;            bytesPerRow = GetPixRowBytes( pmh );                        LockPixels( pmh );                        dataProviderRef = CGDataProviderCreateWithData( NULL, GetPixBaseAddr( pmh ), height * bytesPerRow, releaseData );                                    //	Create the imageRef for that GWorld            imageRef = CGImageCreate( width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedFirst/*kCGImageAlphaNone*/, dataProviderRef, NULL, 0, kCGRenderingIntentDefault );        }    }            //	Draw the image at 0,0    CGContextDrawImage( context, CGRectMake( x - 20, y, 40, 40 * height / width ), imageRef );    }
开发者ID:fruitsamples,项目名称:CTMDemo,代码行数:47,


示例19: createImageFromBitmapContext

/*	createImageFromBitmapContext creates a CGImageRef	from a bitmap context. Calling this routine	transfers 'ownership' of the raster data	in the bitmap context, to the image. If the	image can't be created, this routine frees	the memory associated with the raster. */CGImageRef createImageFromBitmapContext(CGContextRef c){    CGImageRef image;	unsigned char *rasterData = CGBitmapContextGetData(c);    size_t imageDataSize = 		CGBitmapContextGetBytesPerRow(c)*CGBitmapContextGetHeight(c);		if(rasterData == NULL){		fprintf(stderr, "Context is not a bitmap context!/n");		return NULL;	}	    // Create the data provider from the image data, using	// the image releaser function releaseBitmapContextImageData.    CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL,					    rasterData,					    imageDataSize,					    releaseBitmapContextImageData);    if(dataProvider == NULL){		// Since this routine owns the raster memory, it must		// free it if it can't create the data provider.		free(rasterData);		fprintf(stderr, "Couldn't create data provider!/n");		return NULL;    }	// Now create the image. The parameters for the image closely match	// the parameters of the bitmap context. This code uses a NULL	// decode array and shouldInterpolate is true.    image = CGImageCreate(CGBitmapContextGetWidth(c), 			  CGBitmapContextGetHeight(c), 			  CGBitmapContextGetBitsPerComponent(c), 			  CGBitmapContextGetBitsPerPixel(c), 			  CGBitmapContextGetBytesPerRow(c), 			  CGBitmapContextGetColorSpace(c),			  myCGContextGetBitmapInfo(c),			  dataProvider,			  NULL,			  true,			  kCGRenderingIntentDefault);    // Release the data provider since the image retains it.    CGDataProviderRelease(dataProvider);    if(image == NULL){		fprintf(stderr, "Couldn't create image!/n");		return NULL;    }    return image;}
开发者ID:yarshure,项目名称:ProgrammingWithQuartz-Code,代码行数:54,


示例20: create_surface_image

/*********************************************************************** *              create_surface_image * * Caller must hold the surface lock.  On input, *rect is the requested * image rect, relative to the window whole_rect, a.k.a. visible_rect. * On output, it's been intersected with that part backed by the surface * and is the actual size of the returned image.  copy_data indicates if * the caller will keep the returned image beyond the point where the * surface bits can be guaranteed to remain valid and unchanged.  If so, * the bits are copied instead of merely referenced by the image. * * IMPORTANT: This function is called from non-Wine threads, so it *            must not use Win32 or Wine functions, including debug *            logging. */CGImageRef create_surface_image(void *window_surface, CGRect *rect, int copy_data){    CGImageRef cgimage = NULL;    struct macdrv_window_surface *surface = get_mac_surface(window_surface);    int width, height;    width  = surface->header.rect.right - surface->header.rect.left;    height = surface->header.rect.bottom - surface->header.rect.top;    *rect = CGRectIntersection(cgrect_from_rect(surface->header.rect), *rect);    if (!CGRectIsEmpty(*rect))    {        CGRect visrect;        CGColorSpaceRef colorspace;        CGDataProviderRef provider;        int bytes_per_row, offset, size;        CGImageAlphaInfo alphaInfo;        visrect = CGRectOffset(*rect, -surface->header.rect.left, -surface->header.rect.top);        colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);        bytes_per_row = get_dib_stride(width, 32);        offset = CGRectGetMinX(visrect) * 4 + (height - CGRectGetMaxY(visrect)) * bytes_per_row;        size = min(CGRectGetHeight(visrect) * bytes_per_row,                   surface->info.bmiHeader.biSizeImage - offset);        if (copy_data)        {            CFDataRef data = CFDataCreate(NULL, (UInt8*)surface->bits + offset, size);            provider = CGDataProviderCreateWithCFData(data);            CFRelease(data);        }        else            provider = CGDataProviderCreateWithData(NULL, surface->bits + offset, size, NULL);        alphaInfo = surface->use_alpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst;        cgimage = CGImageCreate(CGRectGetWidth(visrect), CGRectGetHeight(visrect),                                8, 32, bytes_per_row, colorspace,                                alphaInfo | kCGBitmapByteOrder32Little,                                provider, NULL, FALSE, kCGRenderingIntentDefault);        CGDataProviderRelease(provider);        CGColorSpaceRelease(colorspace);    }    return cgimage;}
开发者ID:AlexSteel,项目名称:wine,代码行数:60,


示例21: ASSERT

String ImageBuffer::toDataURL(const String& mimeType, const double* quality, CoordinateSystem) const{    ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));    if (context().isAcceleratedContext())        flushContext();    RetainPtr<CFStringRef> uti = utiFromMIMEType(mimeType);    ASSERT(uti);    RefPtr<Uint8ClampedArray> premultipliedData;    RetainPtr<CGImageRef> image;    if (CFEqual(uti.get(), jpegUTI())) {        // JPEGs don't have an alpha channel, so we have to manually composite on top of black.        premultipliedData = getPremultipliedImageData(IntRect(IntPoint(0, 0), logicalSize()));        if (!premultipliedData)            return "data:,";        RetainPtr<CGDataProviderRef> dataProvider;        dataProvider = adoptCF(CGDataProviderCreateWithData(0, premultipliedData->data(), 4 * logicalSize().width() * logicalSize().height(), 0));        if (!dataProvider)            return "data:,";        image = adoptCF(CGImageCreate(logicalSize().width(), logicalSize().height(), 8, 32, 4 * logicalSize().width(),                                    deviceRGBColorSpaceRef(), kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast,                                    dataProvider.get(), 0, false, kCGRenderingIntentDefault));    } else if (m_resolutionScale == 1) {        image = copyNativeImage(CopyBackingStore);        image = createCroppedImageIfNecessary(image.get(), internalSize());    } else {        image = copyNativeImage(DontCopyBackingStore);        RetainPtr<CGContextRef> context = adoptCF(CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), deviceRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));        CGContextSetBlendMode(context.get(), kCGBlendModeCopy);        CGContextClipToRect(context.get(), CGRectMake(0, 0, logicalSize().width(), logicalSize().height()));        FloatSize imageSizeInUserSpace = scaleSizeToUserSpace(logicalSize(), m_data.backingStoreSize, internalSize());        CGContextDrawImage(context.get(), CGRectMake(0, 0, imageSizeInUserSpace.width(), imageSizeInUserSpace.height()), image.get());        image = adoptCF(CGBitmapContextCreateImage(context.get()));    }    return CGImageToDataURL(image.get(), mimeType, quality);}
开发者ID:TigerLau1985,项目名称:webkit,代码行数:42,


示例22: 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,


示例23: MCGImageToCGImage

bool MCGImageToCGImage(MCGImageRef p_src, const MCGIntegerRectangle &p_src_rect, CGColorSpaceRef p_colorspace, bool p_invert, CGImageRef &r_image){	MCGRaster t_raster;	if (!MCGImageGetRaster(p_src, t_raster))		return false;		if (p_invert)	{		return MCGRasterToCGImage(t_raster, p_src_rect, p_colorspace, true, true, r_image);	}		// If we don't need to modify the data then create image with data provider that references the MCGImageRef	bool t_success = true;		CGImageRef t_image = nil;	CGDataProviderRef t_data_provider = nil;		if (t_success)		t_success = MCGImageCreateCGDataProvider(p_src, p_src_rect, t_data_provider);		bool t_alpha;	t_alpha = !MCGImageIsOpaque(p_src);		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_raster.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,代码行数:39,


示例24: 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,



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


C++ CGImageGetHeight函数代码示例
C++ CGEventPost函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。