summaryrefslogtreecommitdiff
path: root/tests/imageutils-macosx.cc
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-01-24 03:01:34 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-01-24 03:01:34 (GMT)
commit1bec7aad09631d3f86874ead2c26335bc897fde5 (patch)
tree018b0ecc4d199c955be6553e56a306d1411ab728 /tests/imageutils-macosx.cc
parente82b056e811f7a72e7fb94ecbc1683420831b05e (diff)
modify qmake buildfile, move offscreen rendering to main src directory
Diffstat (limited to 'tests/imageutils-macosx.cc')
-rw-r--r--tests/imageutils-macosx.cc64
1 files changed, 0 insertions, 64 deletions
diff --git a/tests/imageutils-macosx.cc b/tests/imageutils-macosx.cc
deleted file mode 100644
index 404052f..0000000
--- a/tests/imageutils-macosx.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-#include <ApplicationServices/ApplicationServices.h>
-#include <iostream>
-
-bool write_png(const char *filename, unsigned char *pixels, int width, int height)
-{
- size_t rowBytes = width * 4;
-// CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
- CGBitmapInfo bitmapInfo = kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Big; // BGRA
- int bitsPerComponent = 8;
- CGContextRef contextRef = CGBitmapContextCreate(pixels, width, height,
- bitsPerComponent, rowBytes,
- colorSpace, bitmapInfo);
- if (!contextRef) {
- std::cerr << "Unable to create CGContextRef.";
- return false;
- }
-
- CGImageRef imageRef = CGBitmapContextCreateImage(contextRef);
- if (!imageRef) {
- std::cerr << "Unable to create CGImageRef.";
- return false;
- }
-
- CFStringRef fname = CFStringCreateWithCString(kCFAllocatorDefault, filename, kCFStringEncodingUTF8);
- CFURLRef fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
- fname, kCFURLPOSIXPathStyle, false);
- if (!fileURL) {
- std::cerr << "Unable to create file URL ref.";
- return false;
- }
-
- CGDataConsumerRef dataconsumer = CGDataConsumerCreateWithURL(fileURL);
- CFIndex fileImageIndex = 1;
- CFMutableDictionaryRef fileDict = NULL;
- CFStringRef fileUTType = kUTTypePNG;
- // Create an image destination opaque reference for authoring an image file
- CGImageDestinationRef imageDest = CGImageDestinationCreateWithDataConsumer(dataconsumer,
- fileUTType,
- fileImageIndex,
- fileDict);
- if (!imageDest) {
- std::cerr << "Unable to create CGImageDestinationRef.";
- return false;
- }
-
- CFIndex capacity = 1;
- CFMutableDictionaryRef imageProps =
- CFDictionaryCreateMutable(kCFAllocatorDefault,
- capacity,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- CGImageDestinationAddImage(imageDest, imageRef, imageProps);
- CGImageDestinationFinalize(imageDest);
-
- CFRelease(imageDest);
- CFRelease(dataconsumer);
- CFRelease(fileURL);
- CFRelease(fname);
- CFRelease(imageProps);
- CGColorSpaceRelease(colorSpace);
- CGImageRelease(imageRef);
- return true;
-}
contact: Jan Huwald // Impressum