本文整理匯總了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);
}
示例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
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}