llpngwrapper.h

Go to the documentation of this file.
00001 /*
00002  * @file llpngwrapper.h
00003  *
00004  * $LicenseInfo:firstyear=2007&license=viewergpl$
00005  * 
00006  * Copyright (c) 2007, Linden Research, Inc.
00007  * 
00008  * Second Life Viewer Source Code
00009  * The source code in this file ("Source Code") is provided by Linden Lab
00010  * to you under the terms of the GNU General Public License, version 2.0
00011  * ("GPL"), unless you have obtained a separate licensing agreement
00012  * ("Other License"), formally executed by you and Linden Lab.  Terms of
00013  * the GPL can be found in doc/GPL-license.txt in this distribution, or
00014  * online at http://secondlife.com/developers/opensource/gplv2
00015  * 
00016  * There are special exceptions to the terms and conditions of the GPL as
00017  * it is applied to this Source Code. View the full text of the exception
00018  * in the file doc/FLOSS-exception.txt in this software distribution, or
00019  * online at http://secondlife.com/developers/opensource/flossexception
00020  * 
00021  * By copying, modifying or distributing this software, you acknowledge
00022  * that you have read and understood your obligations described above,
00023  * and agree to abide by those obligations.
00024  * 
00025  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
00026  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
00027  * COMPLETENESS OR PERFORMANCE.
00028  * $/LicenseInfo$
00029  */
00030 
00031 #ifndef LL_LLPNGWRAPPER_H
00032 #define LL_LLPNGWRAPPER_H
00033 
00034 #include "libpng12/png.h"
00035 #include "llimage.h"
00036 
00037 class LLPngWrapper
00038 {
00039 public:
00040         LLPngWrapper();
00041         virtual ~LLPngWrapper();
00042 
00043 public:
00044         struct ImageInfo
00045         {
00046                 U16 mWidth;
00047                 U16 mHeight;
00048                 S8  mComponents;
00049         };
00050 
00051         BOOL isValidPng(U8* src);
00052         BOOL readPng(U8* src, LLImageRaw* rawImage, ImageInfo *infop = NULL);
00053         BOOL writePng(const LLImageRaw* rawImage, U8* dst);
00054         U32  getFinalSize();
00055         LLString getErrorMessage();
00056 
00057 protected:
00058         void normalizeImage();
00059         void updateMetaData();
00060 
00061 private:
00062 
00063         // Structure for writing/reading PNG data to/from memory
00064         // as opposed to using a file.
00065         struct PngDataInfo
00066         {
00067                 U8 *mData;
00068                 U32 mOffset;
00069         };
00070 
00071         static void writeFlush(png_structp png_ptr);
00072         static void errorHandler(png_structp png_ptr, png_const_charp msg);
00073         static void readDataCallback(png_structp png_ptr, png_bytep dest, png_size_t length);
00074         static void writeDataCallback(png_structp png_ptr, png_bytep src, png_size_t length);
00075 
00076         void releaseResources();
00077 
00078         png_structp mReadPngPtr;
00079         png_infop mReadInfoPtr;
00080         png_structp mWritePngPtr;
00081         png_infop mWriteInfoPtr;
00082 
00083         U8 **mRowPointers;
00084 
00085         png_uint_32 mWidth;
00086         png_uint_32 mHeight;
00087         S32 mBitDepth;
00088         S32 mColorType;
00089         S32 mChannels;
00090         S32 mInterlaceType;
00091         S32 mCompressionType;
00092         S32 mFilterMethod;
00093 
00094         U32 mFinalSize;
00095 
00096         BOOL mHasBKGD;
00097         png_color_16p mBackgroundColor;
00098 
00099         F64 mGamma;
00100 
00101         LLString mErrorMessage;
00102 };
00103 
00104 #endif

Generated on Thu Jul 1 06:09:00 2010 for Second Life Viewer by  doxygen 1.4.7