087a3257ea210c46940e352eb4c94c4baa67493d
[occt.git] / src / Image / Image_AlienPixMap.hxx
1 // Created on: 2014-07-18
2 // Created by: Kirill GAVRILOV
3 // Copyright (c) 2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and / or modify it
8 // under the terms of the GNU Lesser General Public version 2.1 as published
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _Image_AlienPixMap_H__
17 #define _Image_AlienPixMap_H__
18
19 #include <Image_PixMap.hxx>
20
21 class TCollection_AsciiString;
22 struct FIBITMAP;
23
24 //! Image class that support file reading/writing operations using auxiliary image library.
25 //! Supported image formats:
26 //! - *.bmp - bitmap image, lossless format without compression.
27 //! - *.ppm - PPM (Portable Pixmap Format), lossless format without compression.
28 //! - *.png - PNG (Portable Network Graphics) lossless format with compression.
29 //! - *.jpg, *.jpe, *.jpeg - JPEG/JIFF (Joint Photographic Experts Group) lossy format (compressed with quality losses). YUV color space used (automatically converted from/to RGB).
30 //! - *.tif, *.tiff - TIFF (Tagged Image File Format).
31 //! - *.tga - TGA (Truevision Targa Graphic), lossless format.
32 //! - *.gif - GIF (Graphical Interchange Format), lossy format. Color stored using pallete (up to 256 distinct colors).
33 //! - *.exr - OpenEXR high dynamic-range format (supports float pixel formats). 
34 class Image_AlienPixMap : public Image_PixMap
35 {
36
37 public:
38
39   //! Empty constructor.
40   Standard_EXPORT Image_AlienPixMap();
41
42   //! Destructor
43   Standard_EXPORT virtual ~Image_AlienPixMap();
44
45   //! Read image data from file.
46   Standard_EXPORT bool Load (const TCollection_AsciiString& theFileName);
47
48   //! Write image data to file using file extension to determine compression format.
49   Standard_EXPORT bool Save (const TCollection_AsciiString& theFileName);
50
51   //! Initialize image plane with required dimensions.
52   //! thePixelFormat - if specified pixel format doesn't supported by image library
53   //!                  than nearest supported will be used instead!
54   //! theSizeRowBytes - may be ignored by this class and required alignemnt will be used instead!
55   Standard_EXPORT virtual bool InitTrash (ImgFormat           thePixelFormat,
56                                           const Standard_Size theSizeX,
57                                           const Standard_Size theSizeY,
58                                           const Standard_Size theSizeRowBytes = 0);
59
60   //! Initialize by copying data.
61   Standard_EXPORT virtual bool InitCopy (const Image_PixMap& theCopy);
62
63   //! Method correctly deallocate internal buffer.
64   Standard_EXPORT virtual void Clear (ImgFormat thePixelFormat = ImgGray);
65
66   //! Performs gamma correction on image.
67   //! theGamma - gamma value to use; a value of 1.0 leaves the image alone
68   Standard_EXPORT bool AdjustGamma (const Standard_Real theGammaCorr);
69
70 private:
71
72   FIBITMAP* myLibImage;
73
74 private:
75
76   //! Copying allowed only within Handles
77   Image_AlienPixMap            (const Image_AlienPixMap& );
78   Image_AlienPixMap& operator= (const Image_AlienPixMap& );
79
80   //! Wrapper initialization is disallowed for this class (will return false in any case)!
81   //! Use only copying and allocation initializers.
82   Standard_EXPORT virtual bool InitWrapper (ImgFormat           thePixelFormat,
83                                             Standard_Byte*      theDataPtr,
84                                             const Standard_Size theSizeX,
85                                             const Standard_Size theSizeY,
86                                             const Standard_Size theSizeRowBytes);
87
88   //! Built-in PPM export
89   Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const;
90
91 public:
92
93   DEFINE_STANDARD_RTTI(Image_AlienPixMap) // Type definition
94
95 };
96
97 DEFINE_STANDARD_HANDLE(Image_AlienPixMap, Image_PixMap)
98
99 #endif // _Image_AlienPixMap_H__