[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50586] trunk/blender/source/blender/imbuf /intern: Code cleanup: removed unused Cocoa image load/save code.

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Sep 14 13:42:05 CEST 2012


Revision: 50586
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50586
Author:   blendix
Date:     2012-09-14 11:42:05 +0000 (Fri, 14 Sep 2012)
Log Message:
-----------
Code cleanup: removed unused Cocoa image load/save code.

Modified Paths:
--------------
    trunk/blender/source/blender/imbuf/intern/filetype.c

Removed Paths:
-------------
    trunk/blender/source/blender/imbuf/intern/imbuf_cocoa.m

Modified: trunk/blender/source/blender/imbuf/intern/filetype.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/filetype.c	2012-09-14 11:10:03 UTC (rev 50585)
+++ trunk/blender/source/blender/imbuf/intern/filetype.c	2012-09-14 11:42:05 UTC (rev 50586)
@@ -48,12 +48,6 @@
 {
 	return (ibuf->ftype & type->filetype);
 }
-#if defined(__APPLE__) && defined(IMBUF_COCOA)
-static int imb_ftype_cocoa(ImFileType *type, ImBuf *ibuf)
-{
-	return (ibuf->ftype & TIF);
-}
-#endif
 static int imb_ftype_iris(ImFileType *type, ImBuf *ibuf)
 {
 	(void)type;
@@ -83,8 +77,6 @@
 #endif
 #ifdef WITH_TIFF
 	{imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF},
-#elif defined(__APPLE__) && defined(IMBUF_COCOA)
-	{NULL, NULL, imb_is_a_cocoa, imb_ftype_cocoa, imb_imb_cocoaLoadImage, imb_savecocoa, NULL, 0, TIF},
 #endif
 #ifdef WITH_HDR
 	{NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR},

Deleted: trunk/blender/source/blender/imbuf/intern/imbuf_cocoa.m
===================================================================
--- trunk/blender/source/blender/imbuf/intern/imbuf_cocoa.m	2012-09-14 11:10:03 UTC (rev 50585)
+++ trunk/blender/source/blender/imbuf/intern/imbuf_cocoa.m	2012-09-14 11:42:05 UTC (rev 50586)
@@ -1,384 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Damien Plisson 10/2009
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/imbuf/intern/imbuf_cocoa.m
- *  \ingroup imbuf
- *
- * Provides image file loading and saving for Blender, via Cocoa.
- */
-
-#include <stdint.h>
-#include <string.h>
-#import <Cocoa/Cocoa.h>
-
-#include "imbuf.h"
-
-#include "IMB_cocoa.h"
-
-#include "BKE_global.h"
-#include "BKE_colortools.h"
-
-#include "IMB_imbuf_types.h"
-#include "IMB_imbuf.h"
-
-#include "IMB_allocimbuf.h"
-
-
-
-#pragma mark load/save functions
-
-/**
- * Loads an image from the supplied buffer
- *
- * Loads any Core Graphics supported type
- * Currently is : TIFF, BMP, JPEG, GIF, PNG, DIB, ICO, and various RAW formats
- *
- * \param mem:   Memory containing the bitmap image
- * \param size:  Size of the mem buffer.
- * \param flags: If flags has IB_test set then the file is not actually loaded,
- *                but all other operations take place.
- *
- * \return: A newly allocated ImBuf structure if successful, otherwise NULL.
- */
-struct ImBuf *imb_cocoaLoadImage(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;
-	
-	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);
-
-	ibuf->ftype = TIF;
-	ibuf->profile = IB_PROFILE_SRGB;
-
-	/* return successfully */
-	return (ibuf);
-}
-
-/**
- * Saves an image to a file.
- *
- * ImBuf structures with 1, 3 or 4 bytes per pixel (GRAY, RGB, RGBA 
- * respectively) are accepted, and interpreted correctly. 
- *
- * Accepted formats: TIFF, GIF, BMP, PNG, JPEG, JPEG2000
- *
- * \param ibuf:  Image buffer.
- * \param name:  Name of the image file to create.
- * \param flags: Currently largely ignored.
- *
- * \return: 1 if the function is successful, 0 on failure.
- */
-
-#define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f))
-
-short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags)
-{
-	uint16_t samplesperpixel, bitspersample;
-	unsigned char *from = NULL, *to = NULL;
-	unsigned short *to16 = NULL;
-	float *fromf = NULL;
-	int x, y, from_i, to_i, i;
-	int success;
-	BOOL hasAlpha;
-	NSString* colorSpace;
-	NSBitmapImageRep *blBitmapFormatImage;
-	NSData *dataToWrite;
-	NSDictionary *imageProperties;
-	
-	NSAutoreleasePool *pool;
-	
-	if (!ibuf) return FALSE;
-	if (!name) return FALSE;
-	
-	/* check for a valid number of bytes per pixel.  Like the PNG writer,
-	 * the TIFF writer supports 1, 3 or 4 bytes per pixel, corresponding
-	 * to gray, RGB, RGBA respectively. */
-	samplesperpixel = (uint16_t)((ibuf->planes + 7) >> 3);
-	switch (samplesperpixel) {
-		case 4: /*RGBA type*/
-			hasAlpha = YES;
-			colorSpace = NSCalibratedRGBColorSpace;
-			break;
-		case 3: /*RGB type*/
-			hasAlpha = NO;
-			colorSpace = NSCalibratedRGBColorSpace;
-			break;
-		case 1:
-			hasAlpha = NO;
-			colorSpace = NSCalibratedWhiteColorSpace;
-			break;
-		default:
-			fprintf(stderr,
-			        "imb_cocoaSaveImage: unsupported number of bytes per "
-			        "pixel: %d\n", samplesperpixel);
-			return (0);
-	}
-
-	if((ibuf->ftype & TIF_16BIT) && ibuf->rect_float)
-		bitspersample = 16;
-	else
-		bitspersample = 8;
-
-	pool = [[NSAutoreleasePool alloc] init];
-	
-	/* Create bitmap image rep in blender format */
-	blBitmapFormatImage = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
-	                                                              pixelsWide:ibuf->x
-	                                                              pixelsHigh:ibuf->y
-	                                                           bitsPerSample:bitspersample samplesPerPixel:samplesperpixel hasAlpha:hasAlpha isPlanar:NO
-	                                                          colorSpaceName:colorSpace
-	                                                            bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
-	                                                             bytesPerRow:(ibuf->x*bitspersample*samplesperpixel/8)
-	                                                            bitsPerPixel:(bitspersample*samplesperpixel)];
-	if (!blBitmapFormatImage) {
-	    [pool drain];
-	    return FALSE;
-	}
-	
-	/* setup pointers */
-	if(bitspersample == 16) {
-		fromf = ibuf->rect_float;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list