本文整理匯總了C++中CGDataProviderCreateWithData函數的典型用法代碼示例。如果您正苦於以下問題:C++ CGDataProviderCreateWithData函數的具體用法?C++ CGDataProviderCreateWithData怎麽用?C++ CGDataProviderCreateWithData使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CGDataProviderCreateWithData函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: MCGImageCreateCGDataProvider
bool MCGImageCreateCGDataProvider(MCGImageRef p_src, const MCGIntegerRectangle &p_src_rect, CGDataProviderRef &r_data_provider)
{
MCAssert(p_src_rect.origin.x >= 0 && p_src_rect.origin.y >= 0);
MCAssert(p_src_rect.origin.x + p_src_rect.size.width <= (uint32_t)MCGImageGetWidth(p_src));
MCAssert(p_src_rect.origin.y + p_src_rect.size.height <= (uint32_t)MCGImageGetHeight(p_src));
bool t_success = true;
MCGRaster t_raster;
if (t_success)
t_success = MCGImageGetRaster(p_src, t_raster);
CGDataProviderRef t_data_provider;
t_data_provider = nil;
if (t_success)
{
const void *t_src_ptr;
t_src_ptr = MCGRasterGetPixelPtr(t_raster, p_src_rect.origin.x, p_src_rect.origin.y);
t_data_provider = CGDataProviderCreateWithData(p_src, t_src_ptr, p_src_rect.size.height * t_raster.stride, MCGImageDataProviderReleaseDataCallback);
t_success = t_data_provider != nil;
}
if (t_success)
{
MCGImageRetain(p_src);
r_data_provider = t_data_provider;
}
return t_success;
}
示例2: 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;
}
示例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;
}
示例4: 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 );
}
示例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;
}
示例6: 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;
}
示例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);
}
示例8: SkStreamToDataProvider
static CGDataProviderRef SkStreamToDataProvider(SkStream* stream) {
// TODO: use callbacks, so we don't have to load all the data into RAM
size_t len = stream->getLength();
void* data = sk_malloc_throw(len);
stream->read(data, len);
return CGDataProviderCreateWithData(data, data, len, malloc_release_proc);
}
示例9: SkStreamToDataProvider
static CGDataProviderRef SkStreamToDataProvider(SkStream* stream) {
// TODO: use callbacks, so we don't have to load all the data into RAM
SkAutoMalloc storage;
const size_t len = CopyStreamToStorage(&storage, stream);
void* data = storage.detach();
return CGDataProviderCreateWithData(data, data, len, malloc_release_proc);
}
示例10: CGDataProviderCreateWithData
void* CQuartz2D::CreateFont(FX_LPCBYTE pFontData, FX_DWORD dwFontSize)
{
CGDataProviderRef pDataProvider = CGDataProviderCreateWithData(NULL, pFontData, (size_t)dwFontSize, NULL);
if (NULL == pDataProvider) {
return NULL;
}
CGFontRef pCGFont = CGFontCreateWithDataProvider(pDataProvider);
CGDataProviderRelease(pDataProvider);
return pCGFont;
}
示例11: data_to_CGImageSrc
static CGImageSourceRef data_to_CGImageSrc(SkData* data) {
CGDataProviderRef cgData = CGDataProviderCreateWithData(data, data->data(), data->size(),
nullptr);
if (!cgData) {
return nullptr;
}
CGImageSourceRef imageSrc = CGImageSourceCreateWithDataProvider(cgData, 0);
CGDataProviderRelease(cgData);
return imageSrc;
}
示例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;
}
示例13: SkPDFDocumentToBitmap
bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output) {
size_t size = stream->getLength();
void* ptr = sk_malloc_throw(size);
stream->read(ptr, size);
CGDataProviderRef data = CGDataProviderCreateWithData(NULL, ptr, size,
CGDataProviderReleaseData_FromMalloc);
if (NULL == data) {
return false;
}
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithProvider(data);
CGDataProviderRelease(data);
if (NULL == pdf) {
return false;
}
SkAutoPDFRelease releaseMe(pdf);
CGPDFPageRef page = CGPDFDocumentGetPage(pdf, 1);
if (NULL == page) {
return false;
}
CGRect bounds = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
int w = (int)CGRectGetWidth(bounds);
int h = (int)CGRectGetHeight(bounds);
SkBitmap bitmap;
if (!bitmap.allocPixels(SkImageInfo::MakeN32Premul(w, h))) {
return false;
}
bitmap.eraseColor(SK_ColorWHITE);
size_t bitsPerComponent;
CGBitmapInfo info;
getBitmapInfo(bitmap, &bitsPerComponent, &info, NULL);
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(bitmap.getPixels(), w, h,
bitsPerComponent, bitmap.rowBytes(),
cs, info);
CGColorSpaceRelease(cs);
if (ctx) {
CGContextDrawPDFPage(ctx, page);
CGContextRelease(ctx);
}
output->swap(bitmap);
return true;
}
示例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);
}
示例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;
}