Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/Image_AlienPixMap.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Created on: 2012-07-18
0002 // Created by: Kirill GAVRILOV
0003 // Copyright (c) 2012-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef Image_AlienPixMap_HeaderFile
0017 #define Image_AlienPixMap_HeaderFile
0018 
0019 #include <Image_PixMap.hxx>
0020 
0021 class TCollection_AsciiString;
0022 struct IWICPalette;
0023 struct FIBITMAP;
0024 
0025 //! Image class that support file reading/writing operations using auxiliary image library.
0026 //! Supported image formats:
0027 //! - *.bmp - bitmap image, lossless format without compression.
0028 //! - *.ppm - PPM (Portable Pixmap Format), lossless format without compression.
0029 //! - *.png - PNG (Portable Network Graphics) lossless format with compression.
0030 //! - *.jpg, *.jpe, *.jpeg - JPEG/JIFF (Joint Photographic Experts Group) lossy format (compressed
0031 //! with quality losses). YUV color space used (automatically converted from/to RGB).
0032 //! - *.tif, *.tiff - TIFF (Tagged Image File Format).
0033 //! - *.tga - TGA (Truevision Targa Graphic), lossless format.
0034 //! - *.gif - GIF (Graphical Interchange Format), lossy format. Color stored using palette (up to
0035 //! 256 distinct colors).
0036 //! - *.exr - OpenEXR high dynamic-range format (supports float pixel formats).
0037 class Image_AlienPixMap : public Image_PixMap
0038 {
0039   DEFINE_STANDARD_RTTIEXT(Image_AlienPixMap, Image_PixMap)
0040 public:
0041   //! Return default rows order used by underlying image library.
0042   Standard_EXPORT static bool IsTopDownDefault();
0043 
0044 public:
0045   //! Empty constructor.
0046   Standard_EXPORT Image_AlienPixMap();
0047 
0048   //! Destructor
0049   Standard_EXPORT virtual ~Image_AlienPixMap();
0050 
0051   //! Read image data from file.
0052   bool Load(const TCollection_AsciiString& theFileName) { return Load(NULL, 0, theFileName); }
0053 
0054   //! Read image data from stream.
0055   Standard_EXPORT bool Load(std::istream& theStream, const TCollection_AsciiString& theFileName);
0056 
0057   //! Read image data from memory buffer.
0058   //! @param[in] theData     memory pointer to read from;
0059   //!                        when NULL, function will attempt to open theFileName file
0060   //! @param[in] theLength   memory buffer length
0061   //! @param[in] theFileName optional file name
0062   Standard_EXPORT bool Load(const Standard_Byte*           theData,
0063                             const Standard_Size            theLength,
0064                             const TCollection_AsciiString& theFileName);
0065 
0066   //! Write image data to file.
0067   //! @param[in] theFileName file name to save
0068   bool Save(const TCollection_AsciiString& theFileName) { return Save(NULL, 0, theFileName); }
0069 
0070   //! Write image data to stream.
0071   //! @param[out] theStream   stream where to write
0072   //! @param[in] theExtension image format
0073   Standard_EXPORT bool Save(std::ostream& theStream, const TCollection_AsciiString& theExtension);
0074 
0075   //! Write image data to file or memory buffer using file extension to determine format.
0076   //! @param[out] theBuffer  buffer pointer where to write
0077   //!                        when NULL, function write image data to theFileName file
0078   //! @param[in] theLength   memory buffer length
0079   //! @param[in] theFileName file name to save;
0080   //!                        when theBuffer isn't NULL used only to determine format
0081   Standard_EXPORT bool Save(Standard_Byte*                 theBuffer,
0082                             const Standard_Size            theLength,
0083                             const TCollection_AsciiString& theFileName);
0084 
0085   //! Initialize image plane with required dimensions.
0086   //! @param[in] thePixelFormat  if specified pixel format doesn't supported by image library
0087   //!                            than nearest supported will be used instead!
0088   //! @param[in] theSizeRowBytes may be ignored by this class and required alignment will be used
0089   //! instead!
0090   Standard_EXPORT virtual bool InitTrash(Image_Format        thePixelFormat,
0091                                          const Standard_Size theSizeX,
0092                                          const Standard_Size theSizeY,
0093                                          const Standard_Size theSizeRowBytes = 0) Standard_OVERRIDE;
0094 
0095   //! Initialize by copying data.
0096   Standard_EXPORT virtual bool InitCopy(const Image_PixMap& theCopy) Standard_OVERRIDE;
0097 
0098   //! Method correctly deallocate internal buffer.
0099   Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
0100 
0101   //! Performs gamma correction on image.
0102   //! @param[in] theGamma - gamma value to use; a value of 1.0 leaves the image alone
0103   Standard_EXPORT bool AdjustGamma(const Standard_Real theGammaCorr);
0104 
0105 #if !defined(HAVE_FREEIMAGE) && defined(_WIN32)
0106   //! Returns image palette.
0107   IWICPalette* GetPalette() const { return myPalette; }
0108 #endif
0109 
0110 private:
0111   //! Copying allowed only within Handles
0112   Image_AlienPixMap(const Image_AlienPixMap&);
0113   Image_AlienPixMap& operator=(const Image_AlienPixMap&);
0114 
0115   //! Wrapper initialization is disallowed for this class (will return false in any case)!
0116   //! Use only copying and allocation initializers.
0117   Standard_EXPORT virtual bool InitWrapper(Image_Format        thePixelFormat,
0118                                            Standard_Byte*      theDataPtr,
0119                                            const Standard_Size theSizeX,
0120                                            const Standard_Size theSizeY,
0121                                            const Standard_Size theSizeRowBytes) Standard_OVERRIDE;
0122 
0123   //! Built-in PPM export
0124   Standard_EXPORT bool savePPM(const TCollection_AsciiString& theFileName) const;
0125 
0126   FIBITMAP* getImageToDump(const Standard_Integer theFormat);
0127 
0128 private:
0129   FIBITMAP*    myLibImage;
0130   IWICPalette* myPalette;
0131 };
0132 
0133 DEFINE_STANDARD_HANDLE(Image_AlienPixMap, Image_PixMap)
0134 
0135 #endif // _Image_AlienPixMap_H__