From a2930c634f5debf2dc25cc2b80e7c91f84eae833 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 20 Jan 2014 16:52:06 +0100 Subject: Code cleanup: remove quicktime image loading code (not animation loading). This code has been broken for a few years and no one noticed, it's also less useful now that we support PSD image loading ourselves which was the original motivation to have this. --- source/blender/quicktime/apple/qtkit_import.m | 164 +------------------------- source/blender/quicktime/quicktime_import.h | 10 +- 2 files changed, 5 insertions(+), 169 deletions(-) (limited to 'source/blender/quicktime') diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m index fbe4733c3b1..d0bf7a30e6d 100644 --- a/source/blender/quicktime/apple/qtkit_import.m +++ b/source/blender/quicktime/apple/qtkit_import.m @@ -66,10 +66,9 @@ typedef struct _QuicktimeMovie { void quicktime_init(void) { - G.have_quicktime = TRUE; + G.have_quicktime = TRUE; } - void quicktime_exit(void) { if (G.have_quicktime) { @@ -392,166 +391,5 @@ int startquicktime(struct anim *anim) return 0; } -int imb_is_a_quicktime(char *name) -{ - NSImage *image; - int result; - NSAutoreleasePool *pool; - - if (!G.have_quicktime) return 0; - - pool = [[NSAutoreleasePool alloc] init]; - - // don't let quicktime image import handle these - if (BLI_testextensie(name, ".swf") || - BLI_testextensie(name, ".txt") || - BLI_testextensie(name, ".mpg") || - BLI_testextensie(name, ".wav") || - BLI_testextensie(name, ".mov") || // not as image, doesn't work - BLI_testextensie(name, ".avi") || - BLI_testextensie(name, ".mp3")) return 0; - - - image = [[NSImage alloc] initWithContentsOfFile:[NSString stringWithUTF8String:name]]; - if (image) { - [image release]; - result = true; - } - else - result = false; - - [pool drain]; - return result; -} - -ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags) -{ - struct ImBuf *ibuf = NULL; - NSSize bitmapSize; - uchar *rasterRGB = NULL; - uchar *rasterRGBA = NULL; - uchar *toIBuf = NULL; - int x, y, to_i, from_i; - NSData *data; - NSBitmapImageRep *bitmapImage; - NSBitmapImageRep *blBitmapFormatImageRGB,*blBitmapFormatImageRGBA; - NSAutoreleasePool *pool; - - if (!G.have_quicktime) - return NULL; - - pool = [[NSAutoreleasePool alloc] init]; - - data = [NSData dataWithBytes:mem length:size]; - bitmapImage = [[NSBitmapImageRep alloc] initWithData:data]; - - if (!bitmapImage) { - fprintf(stderr, "imb_cocoaLoadImage: error loading image\n"); - [pool drain]; - return NULL; - } - - bitmapSize.width = [bitmapImage pixelsWide]; - bitmapSize.height = [bitmapImage pixelsHigh]; - - /* Tell cocoa image resolution is same as current system one */ - [bitmapImage setSize:bitmapSize]; - - /* allocate the image buffer */ - ibuf = IMB_allocImBuf(bitmapSize.width, bitmapSize.height, 32/*RGBA*/, 0); - if (!ibuf) { - fprintf(stderr, - "imb_cocoaLoadImage: could not allocate memory for the image.\n"); - [bitmapImage release]; - [pool drain]; - return NULL; - } - - /* read in the image data */ - if (!(flags & IB_test)) { - - /* allocate memory for the ibuf->rect */ - imb_addrectImBuf(ibuf); - - /* Convert the image in a RGBA 32bit format */ - /* As Core Graphics does not support contextes with non premutliplied alpha, - we need to get alpha key values in a separate batch */ - - /* First get RGB values w/o Alpha to avoid pre-multiplication, 32bit but last byte is unused */ - blBitmapFormatImageRGB = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL - pixelsWide:bitmapSize.width - pixelsHigh:bitmapSize.height - bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO - colorSpaceName:NSCalibratedRGBColorSpace - bitmapFormat:0 - bytesPerRow:4*bitmapSize.width - bitsPerPixel:32/*RGB format padded to 32bits*/]; - - [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:blBitmapFormatImageRGB]]; - [bitmapImage draw]; - [NSGraphicsContext restoreGraphicsState]; - - rasterRGB = (uchar *)[blBitmapFormatImageRGB bitmapData]; - if (rasterRGB == NULL) { - [bitmapImage release]; - [blBitmapFormatImageRGB release]; - [pool drain]; - return NULL; - } - - /* Then get Alpha values by getting the RGBA image (that is premultiplied btw) */ - blBitmapFormatImageRGBA = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL - pixelsWide:bitmapSize.width - pixelsHigh:bitmapSize.height - bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO - colorSpaceName:NSCalibratedRGBColorSpace - bitmapFormat:0 - bytesPerRow:4*bitmapSize.width - bitsPerPixel:32/* RGBA */]; - - [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:blBitmapFormatImageRGBA]]; - [bitmapImage draw]; - [NSGraphicsContext restoreGraphicsState]; - - rasterRGBA = (uchar *)[blBitmapFormatImageRGBA bitmapData]; - if (rasterRGBA == NULL) { - [bitmapImage release]; - [blBitmapFormatImageRGB release]; - [blBitmapFormatImageRGBA release]; - [pool drain]; - return NULL; - } - - /*Copy the image to ibuf, flipping it vertically*/ - toIBuf = (uchar *)ibuf->rect; - for (x = 0; x < bitmapSize.width; x++) { - for (y = 0; y < bitmapSize.height; y++) { - to_i = (bitmapSize.height-y-1)*bitmapSize.width + x; - from_i = y*bitmapSize.width + x; - - toIBuf[4*to_i] = rasterRGB[4*from_i]; /* R */ - toIBuf[4*to_i+1] = rasterRGB[4*from_i+1]; /* G */ - toIBuf[4*to_i+2] = rasterRGB[4*from_i+2]; /* B */ - toIBuf[4*to_i+3] = rasterRGBA[4*from_i+3]; /* A */ - } - } - - [blBitmapFormatImageRGB release]; - [blBitmapFormatImageRGBA release]; - } - - /* release the cocoa objects */ - [bitmapImage release]; - [pool drain]; - - if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); - - /* return successfully */ - return (ibuf); -} - - #endif /* WITH_QUICKTIME */ diff --git a/source/blender/quicktime/quicktime_import.h b/source/blender/quicktime/quicktime_import.h index e45720496cc..3c6b2028031 100644 --- a/source/blender/quicktime/quicktime_import.h +++ b/source/blender/quicktime/quicktime_import.h @@ -48,7 +48,10 @@ # endif /* __FIXMATH__ */ #endif /* _WIN32 _ */ -char *get_valid_qtname(const char *name); +/* init/exit */ + +void quicktime_init(void); +void quicktime_exit(void); /* quicktime movie import functions */ @@ -57,9 +60,4 @@ int startquicktime(struct anim *anim); void free_anim_quicktime(struct anim *anim); ImBuf *qtime_fetchibuf(struct anim *anim, int position); -/* quicktime image import functions */ - -int imb_is_a_quicktime(char *name); -ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags); - #endif /* __QUICKTIME_IMPORT_H__ */ -- cgit v1.2.3