|
||||
File indexing completed on 2025-01-18 10:04:05
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 with quality losses). YUV color space used (automatically converted from/to RGB). 0031 //! - *.tif, *.tiff - TIFF (Tagged Image File Format). 0032 //! - *.tga - TGA (Truevision Targa Graphic), lossless format. 0033 //! - *.gif - GIF (Graphical Interchange Format), lossy format. Color stored using palette (up to 256 distinct colors). 0034 //! - *.exr - OpenEXR high dynamic-range format (supports float pixel formats). 0035 class Image_AlienPixMap : public Image_PixMap 0036 { 0037 DEFINE_STANDARD_RTTIEXT(Image_AlienPixMap, Image_PixMap) 0038 public: 0039 0040 //! Return default rows order used by underlying image library. 0041 Standard_EXPORT static bool IsTopDownDefault(); 0042 public: 0043 0044 //! Empty constructor. 0045 Standard_EXPORT Image_AlienPixMap(); 0046 0047 //! Destructor 0048 Standard_EXPORT virtual ~Image_AlienPixMap(); 0049 0050 //! Read image data from file. 0051 bool Load (const TCollection_AsciiString& theFileName) 0052 { 0053 return Load (NULL, 0, theFileName); 0054 } 0055 0056 //! Read image data from stream. 0057 Standard_EXPORT bool Load (std::istream& theStream, 0058 const TCollection_AsciiString& theFileName); 0059 0060 //! Read image data from memory buffer. 0061 //! @param[in] theData memory pointer to read from; 0062 //! when NULL, function will attempt to open theFileName file 0063 //! @param[in] theLength memory buffer length 0064 //! @param[in] theFileName optional file name 0065 Standard_EXPORT bool Load (const Standard_Byte* theData, 0066 const Standard_Size theLength, 0067 const TCollection_AsciiString& theFileName); 0068 0069 //! Write image data to file. 0070 //! @param[in] theFileName file name to save 0071 bool Save (const TCollection_AsciiString& theFileName) 0072 { 0073 return Save (NULL, 0, theFileName); 0074 } 0075 0076 //! Write image data to stream. 0077 //! @param[out] theStream stream where to write 0078 //! @param[in] theExtension image format 0079 Standard_EXPORT bool Save (std::ostream& theStream, 0080 const TCollection_AsciiString& theExtension); 0081 0082 //! Write image data to file or memory buffer using file extension to determine format. 0083 //! @param[out] theBuffer buffer pointer where to write 0084 //! when NULL, function write image data to theFileName file 0085 //! @param[in] theLength memory buffer length 0086 //! @param[in] theFileName file name to save; 0087 //! when theBuffer isn't NULL used only to determine format 0088 Standard_EXPORT bool Save (Standard_Byte* theBuffer, 0089 const Standard_Size theLength, 0090 const TCollection_AsciiString& theFileName); 0091 0092 //! Initialize image plane with required dimensions. 0093 //! @param[in] thePixelFormat if specified pixel format doesn't supported by image library 0094 //! than nearest supported will be used instead! 0095 //! @param[in] theSizeRowBytes may be ignored by this class and required alignment will be used instead! 0096 Standard_EXPORT virtual bool InitTrash (Image_Format thePixelFormat, 0097 const Standard_Size theSizeX, 0098 const Standard_Size theSizeY, 0099 const Standard_Size theSizeRowBytes = 0) Standard_OVERRIDE; 0100 0101 //! Initialize by copying data. 0102 Standard_EXPORT virtual bool InitCopy (const Image_PixMap& theCopy) Standard_OVERRIDE; 0103 0104 //! Method correctly deallocate internal buffer. 0105 Standard_EXPORT virtual void Clear() Standard_OVERRIDE; 0106 0107 //! Performs gamma correction on image. 0108 //! @param[in] theGamma - gamma value to use; a value of 1.0 leaves the image alone 0109 Standard_EXPORT bool AdjustGamma (const Standard_Real theGammaCorr); 0110 0111 #if !defined(HAVE_FREEIMAGE) && defined(_WIN32) 0112 //! Returns image palette. 0113 IWICPalette* GetPalette() const { return myPalette; } 0114 #endif 0115 0116 private: 0117 0118 //! Copying allowed only within Handles 0119 Image_AlienPixMap (const Image_AlienPixMap& ); 0120 Image_AlienPixMap& operator= (const Image_AlienPixMap& ); 0121 0122 //! Wrapper initialization is disallowed for this class (will return false in any case)! 0123 //! Use only copying and allocation initializers. 0124 Standard_EXPORT virtual bool InitWrapper (Image_Format thePixelFormat, 0125 Standard_Byte* theDataPtr, 0126 const Standard_Size theSizeX, 0127 const Standard_Size theSizeY, 0128 const Standard_Size theSizeRowBytes) Standard_OVERRIDE; 0129 0130 //! Built-in PPM export 0131 Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const; 0132 0133 FIBITMAP* getImageToDump (const Standard_Integer theFormat); 0134 0135 private: 0136 0137 FIBITMAP* myLibImage; 0138 IWICPalette* myPalette; 0139 0140 }; 0141 0142 DEFINE_STANDARD_HANDLE(Image_AlienPixMap, Image_PixMap) 0143 0144 #endif // _Image_AlienPixMap_H__
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |