Blender V2.61 - r43446
|
00001 /* 00002 * 00003 * This is external code. Converts between rgb32 and avi. 00004 * 00005 * ***** BEGIN GPL LICENSE BLOCK ***** 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software Foundation, 00019 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 * 00021 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00022 * All rights reserved. 00023 * 00024 * The Original Code is: all of this file. 00025 * 00026 * Contributor(s): none yet. 00027 * 00028 * ***** END GPL LICENSE BLOCK ***** 00029 * 00030 */ 00031 00037 #include "AVI_avi.h" 00038 #include <stdlib.h> 00039 #include <string.h> 00040 #include "MEM_guardedalloc.h" 00041 #include "rgb32.h" 00042 00043 void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size) 00044 { 00045 int y, x, rowstridea, rowstrideb; 00046 unsigned char *buf; 00047 00048 (void)stream; /* unused */ 00049 00050 buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromrgb32buf"); 00051 *size = movie->header->Height * movie->header->Width * 3; 00052 00053 rowstridea = movie->header->Width*3; 00054 rowstrideb = movie->header->Width*4; 00055 00056 for (y=0; y < movie->header->Height; y++) { 00057 for (x=0; x < movie->header->Width; x++) { 00058 buf[y*rowstridea + x*3 + 0] = buffer[y*rowstrideb + x*4 + 3]; 00059 buf[y*rowstridea + x*3 + 1] = buffer[y*rowstrideb + x*4 + 2]; 00060 buf[y*rowstridea + x*3 + 2] = buffer[y*rowstrideb + x*4 + 1]; 00061 } 00062 } 00063 00064 MEM_freeN (buffer); 00065 00066 return buf; 00067 } 00068 00069 void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size) 00070 { 00071 int i; 00072 unsigned char *buf; 00073 unsigned char *to, *from; 00074 00075 (void)stream; /* unused */ 00076 00077 buf= MEM_mallocN (movie->header->Height * movie->header->Width * 4, "torgb32buf"); 00078 *size= movie->header->Height * movie->header->Width * 4; 00079 00080 memset(buf, 255, *size); 00081 00082 to= buf; from= buffer; 00083 i=movie->header->Height*movie->header->Width; 00084 00085 while(i--) { 00086 memcpy(to, from, 3); 00087 to+=4; from+=3; 00088 } 00089 00090 MEM_freeN (buffer); 00091 00092 return buf; 00093 }