692613e5 |
1 | // Created on: 2012-07-18 |
2 | // Created by: Kirill GAVRILOV |
3 | // Copyright (c) 2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
20 | #ifndef _Image_AlienPixMap_H__ |
21 | #define _Image_AlienPixMap_H__ |
22 | |
23 | #include <Image_PixMap.hxx> |
24 | #include <Image_TypeOfImage.hxx> |
25 | |
26 | class TCollection_AsciiString; |
27 | struct FIBITMAP; |
28 | |
29 | //! Image class that support file reading/writing operations using auxiliary image library. |
30 | //! Notice that supported images format could be limited. |
31 | class Image_AlienPixMap : public Image_PixMap |
32 | { |
33 | |
34 | public: |
35 | |
36 | //! Empty constructor. |
37 | Standard_EXPORT Image_AlienPixMap(); |
38 | |
39 | //! Destructor |
40 | Standard_EXPORT virtual ~Image_AlienPixMap(); |
41 | |
42 | //! Read image data from file. |
43 | Standard_EXPORT bool Load (const TCollection_AsciiString& theFileName); |
44 | |
45 | //! Write image data to file using file extension to determine compression format. |
46 | Standard_EXPORT bool Save (const TCollection_AsciiString& theFileName); |
47 | |
48 | //! Initialize image plane with required dimensions. |
49 | //! thePixelFormat - if specified pixel format doesn't supported by image library |
50 | //! than nearest supported will be used instead! |
51 | //! theSizeRowBytes - may be ignored by this class and required alignemnt will be used instead! |
52 | Standard_EXPORT virtual bool InitTrash (ImgFormat thePixelFormat, |
53 | const Standard_Size theSizeX, |
54 | const Standard_Size theSizeY, |
55 | const Standard_Size theSizeRowBytes = 0); |
56 | |
57 | //! Initialize by copying data. |
58 | Standard_EXPORT virtual bool InitCopy (const Image_PixMap& theCopy); |
59 | |
60 | //! Method correctly deallocate internal buffer. |
61 | Standard_EXPORT virtual void Clear (ImgFormat thePixelFormat = ImgGray); |
62 | |
63 | //! Performs gamma correction on image. |
64 | //! theGamma - gamma value to use; a value of 1.0 leaves the image alone |
65 | Standard_EXPORT bool AdjustGamma (const Standard_Real theGammaCorr); |
66 | |
67 | private: |
68 | |
69 | FIBITMAP* myLibImage; |
70 | |
71 | private: |
72 | |
73 | //! Copying allowed only within Handles |
74 | Image_AlienPixMap (const Image_AlienPixMap& ); |
75 | Image_AlienPixMap& operator= (const Image_AlienPixMap& ); |
76 | |
77 | //! Wrapper initialization is disallowed for this class (will return false in any case)! |
78 | //! Use only copying and allocation initializers. |
79 | Standard_EXPORT virtual bool InitWrapper (ImgFormat thePixelFormat, |
80 | Standard_Byte* theDataPtr, |
81 | const Standard_Size theSizeX, |
82 | const Standard_Size theSizeY, |
83 | const Standard_Size theSizeRowBytes); |
84 | |
85 | //! Built-in PPM export |
86 | Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const; |
87 | |
88 | public: |
89 | |
90 | DEFINE_STANDARD_RTTI(Image_AlienPixMap) // Type definition |
91 | |
92 | }; |
93 | |
94 | DEFINE_STANDARD_HANDLE(Image_AlienPixMap, Image_PixMap) |
95 | |
96 | #endif // _Image_AlienPixMap_H__ |