0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / Image / Image_AlienPixMap.hxx
CommitLineData
6aca4d39 1// Created on: 2012-07-18
692613e5 2// Created by: Kirill GAVRILOV
6aca4d39 3// Copyright (c) 2012-2014 OPEN CASCADE SAS
692613e5 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
692613e5 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
692613e5 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
692613e5 15
5bd54bef 16#ifndef Image_AlienPixMap_HeaderFile
17#define Image_AlienPixMap_HeaderFile
692613e5 18
19#include <Image_PixMap.hxx>
692613e5 20
21class TCollection_AsciiString;
b47b7e69 22struct IWICPalette;
692613e5 23struct FIBITMAP;
24
25//! Image class that support file reading/writing operations using auxiliary image library.
3994ec41 26//! Supported image formats:
27//! - *.bmp - bitmap image, lossless format without compression.
28//! - *.ppm - PPM (Portable Pixmap Format), lossless format without compression.
29//! - *.png - PNG (Portable Network Graphics) lossless format with compression.
30//! - *.jpg, *.jpe, *.jpeg - JPEG/JIFF (Joint Photographic Experts Group) lossy format (compressed with quality losses). YUV color space used (automatically converted from/to RGB).
31//! - *.tif, *.tiff - TIFF (Tagged Image File Format).
32//! - *.tga - TGA (Truevision Targa Graphic), lossless format.
dc858f4c 33//! - *.gif - GIF (Graphical Interchange Format), lossy format. Color stored using palette (up to 256 distinct colors).
3994ec41 34//! - *.exr - OpenEXR high dynamic-range format (supports float pixel formats).
692613e5 35class Image_AlienPixMap : public Image_PixMap
36{
dc858f4c 37 DEFINE_STANDARD_RTTIEXT(Image_AlienPixMap, Image_PixMap)
692613e5 38public:
39
88b12b7c 40 //! Return default rows order used by underlying image library.
41 Standard_EXPORT static bool IsTopDownDefault();
42public:
43
692613e5 44 //! Empty constructor.
45 Standard_EXPORT Image_AlienPixMap();
46
47 //! Destructor
48 Standard_EXPORT virtual ~Image_AlienPixMap();
49
50 //! Read image data from file.
88b12b7c 51 bool Load (const TCollection_AsciiString& theFileName)
52 {
53 return Load (NULL, 0, theFileName);
54 }
55
56 //! Read image data from stream.
57 Standard_EXPORT bool Load (std::istream& theStream,
58 const TCollection_AsciiString& theFileName);
59
60 //! Read image data from memory buffer.
b47b7e69 61 //! @param[in] theData memory pointer to read from;
62 //! when NULL, function will attempt to open theFileName file
63 //! @param[in] theLength memory buffer length
64 //! @param[in] theFileName optional file name
88b12b7c 65 Standard_EXPORT bool Load (const Standard_Byte* theData,
b47b7e69 66 const Standard_Size theLength,
88b12b7c 67 const TCollection_AsciiString& theFileName);
692613e5 68
b47b7e69 69 //! Write image data to file.
70 //! @param[in] theFileName file name to save
71 bool Save (const TCollection_AsciiString& theFileName)
72 {
73 return Save (NULL, 0, theFileName);
74 }
75
76 //! Write image data to stream.
77 //! @param[out] theStream stream where to write
78 //! @param[in] theExtension image format
79 Standard_EXPORT bool Save (std::ostream& theStream,
80 const TCollection_AsciiString& theExtension);
81
82 //! Write image data to file or memory buffer using file extension to determine format.
83 //! @param[out] theBuffer buffer pointer where to write
84 //! when NULL, function write image data to theFileName file
85 //! @param[in] theLength memory buffer length
86 //! @param[in] theFileName file name to save;
87 //! when theBuffer isn't NULL used only to determine format
88 Standard_EXPORT bool Save (Standard_Byte* theBuffer,
89 const Standard_Size theLength,
90 const TCollection_AsciiString& theFileName);
692613e5 91
92 //! Initialize image plane with required dimensions.
b47b7e69 93 //! @param[in] thePixelFormat if specified pixel format doesn't supported by image library
94 //! than nearest supported will be used instead!
95 //! @param[in] theSizeRowBytes may be ignored by this class and required alignment will be used instead!
dc858f4c 96 Standard_EXPORT virtual bool InitTrash (Image_Format thePixelFormat,
692613e5 97 const Standard_Size theSizeX,
98 const Standard_Size theSizeY,
79104795 99 const Standard_Size theSizeRowBytes = 0) Standard_OVERRIDE;
692613e5 100
101 //! Initialize by copying data.
79104795 102 Standard_EXPORT virtual bool InitCopy (const Image_PixMap& theCopy) Standard_OVERRIDE;
692613e5 103
104 //! Method correctly deallocate internal buffer.
79104795 105 Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
692613e5 106
107 //! Performs gamma correction on image.
b47b7e69 108 //! @param[in] theGamma - gamma value to use; a value of 1.0 leaves the image alone
692613e5 109 Standard_EXPORT bool AdjustGamma (const Standard_Real theGammaCorr);
110
b47b7e69 111#if !defined(HAVE_FREEIMAGE) && defined(_WIN32)
112 //! Returns image palette.
113 IWICPalette* GetPalette() const { return myPalette; }
114#endif
692613e5 115
116private:
117
118 //! Copying allowed only within Handles
119 Image_AlienPixMap (const Image_AlienPixMap& );
120 Image_AlienPixMap& operator= (const Image_AlienPixMap& );
121
122 //! Wrapper initialization is disallowed for this class (will return false in any case)!
123 //! Use only copying and allocation initializers.
dc858f4c 124 Standard_EXPORT virtual bool InitWrapper (Image_Format thePixelFormat,
692613e5 125 Standard_Byte* theDataPtr,
126 const Standard_Size theSizeX,
127 const Standard_Size theSizeY,
79104795 128 const Standard_Size theSizeRowBytes) Standard_OVERRIDE;
692613e5 129
130 //! Built-in PPM export
131 Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const;
132
b47b7e69 133 FIBITMAP* getImageToDump (const Standard_Integer theFormat);
134
135private:
136
137 FIBITMAP* myLibImage;
138 IWICPalette* myPalette;
139
692613e5 140};
141
142DEFINE_STANDARD_HANDLE(Image_AlienPixMap, Image_PixMap)
143
144#endif // _Image_AlienPixMap_H__