X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftags%2Fsynfig_0_61_04%2Fsynfig-core%2Fsrc%2Fmodules%2Fmod_bmp%2Fmptr_bmp.cpp;fp=synfig-core%2Ftags%2Fsynfig_0_61_04%2Fsynfig-core%2Fsrc%2Fmodules%2Fmod_bmp%2Fmptr_bmp.cpp;h=0000000000000000000000000000000000000000;hb=6fa8f2f38d4b0b35f8539bf94e27ae27015c7689;hp=63a277e8ceec7da24fa2f32c50f2cd0eb08e6703;hpb=47fce282611fbba1044921d22ca887f9b53ad91a;p=synfig.git diff --git a/synfig-core/tags/synfig_0_61_04/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp b/synfig-core/tags/synfig_0_61_04/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp deleted file mode 100644 index 63a277e..0000000 --- a/synfig-core/tags/synfig_0_61_04/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/*! ======================================================================== -** Synfig -** bmp Target Module -** $Id: mptr_bmp.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $ -** -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** -** This package 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 package 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. -** -** === N O T E S =========================================================== -** -** ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#define SYNFIG_NO_ANGLE - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "mptr_bmp.h" -#include -#include - -#include -#include -#endif - -/* === U S I N G =========================================================== */ - -using namespace synfig; -using namespace std; -using namespace etl; - -/* === G L O B A L S ======================================================= */ - -SYNFIG_IMPORTER_INIT(bmp_mptr); -SYNFIG_IMPORTER_SET_NAME(bmp_mptr,"bmp_mptr"); -SYNFIG_IMPORTER_SET_EXT(bmp_mptr,"bmp"); -SYNFIG_IMPORTER_SET_VERSION(bmp_mptr,"0.1"); -SYNFIG_IMPORTER_SET_CVS_ID(bmp_mptr,"$Id: mptr_bmp.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $"); - -/* === M E T H O D S ======================================================= */ - -struct BITMAPFILEHEADER -{ - unsigned char bfType[2]; - unsigned long bfSize; - unsigned short bfReserved1; - unsigned short bfReserved2; - unsigned long bfOffsetBits; -}; - -struct BITMAPINFOHEADER -{ - unsigned long biSize; - long biWidth; - long biHeight; - unsigned short biPlanes; - unsigned short biBitCount; - unsigned long biCompression; - unsigned long biSizeImage; - long biXPelsPerMeter; - long biYPelsPerMeter; - unsigned long biClrUsed; - unsigned long biClrImportant; -}; - -#ifdef WORDS_BIGENDIAN -inline long little_endian(const long &x) -{ - long ret; - char *big_e=(char *)&ret; - char *lit_e=(char *)&x; - big_e[0]=lit_e[3]; - big_e[1]=lit_e[2]; - big_e[2]=lit_e[1]; - big_e[3]=lit_e[0]; - return ret; -} -inline short little_endian_short(const short &x) -{ - short ret; - char *big_e=(char *)&ret; - char *lit_e=(char *)&x; - big_e[0]=lit_e[1]; - big_e[1]=lit_e[0]; - return ret; -} -#else -#define little_endian(x) (x) -#define little_endian_short(x) (x) -#endif - - - - - - -bmp_mptr::bmp_mptr(const char *file) -{ - filename=file; -} - -bmp_mptr::~bmp_mptr() -{ -} - -bool -bmp_mptr::get_frame(synfig::Surface &surface,Time, synfig::ProgressCallback *cb) -{ - FILE *file=fopen(filename.c_str(),"rb"); - if(!file) - { - if(cb)cb->error("bmp_mptr::GetFrame(): "+strprintf(_("Unable to open %s"),filename.c_str())); - else synfig::error("bmp_mptr::GetFrame(): "+strprintf(_("Unable to open %s"),filename.c_str())); - return false; - } - - BITMAPFILEHEADER fileheader; - BITMAPINFOHEADER infoheader; - char b_char=fgetc(file); - char m_char=fgetc(file); - - if(b_char!='B' || m_char!='M') - { - if(cb)cb->error("bmp_mptr::GetFrame(): "+strprintf(_("%s is not in BMP format"),filename.c_str())); - else synfig::error("bmp_mptr::GetFrame(): "+strprintf(_("%s is not in BMP format"),filename.c_str())); - return false; - } - - if(fread(&fileheader.bfSize, 1, sizeof(BITMAPFILEHEADER)-4, file)!=sizeof(BITMAPFILEHEADER)-4) - { - String str("bmp_mptr::get_frame(): "+strprintf(_("Failure while reading BITMAPFILEHEADER from %s"),filename.c_str())); - if(cb)cb->error(str); - else synfig::error(str); - return false; - } - - if(fread(&infoheader, 1, sizeof(BITMAPINFOHEADER), file)!=sizeof(BITMAPINFOHEADER)) - { - String str("bmp_mptr::get_frame(): "+strprintf(_("Failure while reading BITMAPINFOHEADER from %s"),filename.c_str())); - if(cb)cb->error(str); - else synfig::error(str); - return false; - } - - int offset=little_endian(fileheader.bfOffsetBits); - - if(offset!=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)-2) - { - String str("bmp_mptr::get_frame(): "+strprintf(_("Bad BITMAPFILEHEADER in %s. (bfOffsetBits=%d, should be %d)"),filename.c_str(),offset,sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)-2)); - if(cb)cb->error(str); - else synfig::error(str); - return false; - } - - if(little_endian(infoheader.biSize)!=little_endian(40)) - { - String str("bmp_mptr::get_frame(): "+strprintf(_("Bad BITMAPINFOHEADER in %s. (biSize=%d, should be 40)"),filename.c_str(),little_endian(infoheader.biSize))); - if(cb)cb->error(str); - else synfig::error(str); - return false; - } - - int w,h,bit_count; - - w=little_endian(infoheader.biWidth); - h=little_endian(infoheader.biHeight); - bit_count=little_endian_short(infoheader.biBitCount); - - synfig::warning("w:%d\n",w); - synfig::warning("h:%d\n",h); - synfig::warning("bit_count:%d\n",bit_count); - - if(little_endian(infoheader.biCompression)) - { - if(cb)cb->error("bmp_mptr::GetFrame(): "+string(_("Reading compressed bitmaps is not supported"))); - else synfig::error("bmp_mptr::GetFrame(): "+string(_("Reading compressed bitmaps is not supported"))); - return false; - } - - if(bit_count!=24 && bit_count!=32) - { - if(cb)cb->error("bmp_mptr::GetFrame(): "+strprintf(_("Unsupported bit depth (bit_count=%d, should be 24 or 32)"),bit_count)); - else synfig::error("bmp_mptr::GetFrame(): "+strprintf(_("Unsupported bit depth (bit_count=%d, should be 24 or 32)"),bit_count)); - return false; - } - - int x; - int y; - surface.set_wh(w,h); - for(y=0;y