0030700: Visualization, TKOpenGl - support PBR Metallic-Roughness shading model
[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
16#ifndef _Image_AlienPixMap_H__
17#define _Image_AlienPixMap_H__
18
19#include <Image_PixMap.hxx>
692613e5 20
21class TCollection_AsciiString;
22struct FIBITMAP;
23
24//! Image class that support file reading/writing operations using auxiliary image library.
3994ec41 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.
dc858f4c 32//! - *.gif - GIF (Graphical Interchange Format), lossy format. Color stored using palette (up to 256 distinct colors).
3994ec41 33//! - *.exr - OpenEXR high dynamic-range format (supports float pixel formats).
692613e5 34class Image_AlienPixMap : public Image_PixMap
35{
dc858f4c 36 DEFINE_STANDARD_RTTIEXT(Image_AlienPixMap, Image_PixMap)
692613e5 37public:
38
88b12b7c 39 //! Return default rows order used by underlying image library.
40 Standard_EXPORT static bool IsTopDownDefault();
41public:
42
692613e5 43 //! Empty constructor.
44 Standard_EXPORT Image_AlienPixMap();
45
46 //! Destructor
47 Standard_EXPORT virtual ~Image_AlienPixMap();
48
49 //! Read image data from file.
88b12b7c 50 bool Load (const TCollection_AsciiString& theFileName)
51 {
52 return Load (NULL, 0, theFileName);
53 }
54
55 //! Read image data from stream.
56 Standard_EXPORT bool Load (std::istream& theStream,
57 const TCollection_AsciiString& theFileName);
58
59 //! Read image data from memory buffer.
60 //! @param theData memory pointer to read from;
61 //! when NULL, function will attempt to open theFileName file
62 //! @param theLength memory buffer length
63 //! @param theFileName optional file name
64 Standard_EXPORT bool Load (const Standard_Byte* theData,
65 Standard_Size theLength,
66 const TCollection_AsciiString& theFileName);
692613e5 67
68 //! Write image data to file using file extension to determine compression format.
69 Standard_EXPORT bool Save (const TCollection_AsciiString& theFileName);
70
71 //! Initialize image plane with required dimensions.
72 //! thePixelFormat - if specified pixel format doesn't supported by image library
73 //! than nearest supported will be used instead!
74 //! theSizeRowBytes - may be ignored by this class and required alignemnt will be used instead!
dc858f4c 75 Standard_EXPORT virtual bool InitTrash (Image_Format thePixelFormat,
692613e5 76 const Standard_Size theSizeX,
77 const Standard_Size theSizeY,
79104795 78 const Standard_Size theSizeRowBytes = 0) Standard_OVERRIDE;
692613e5 79
80 //! Initialize by copying data.
79104795 81 Standard_EXPORT virtual bool InitCopy (const Image_PixMap& theCopy) Standard_OVERRIDE;
692613e5 82
83 //! Method correctly deallocate internal buffer.
79104795 84 Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
692613e5 85
86 //! Performs gamma correction on image.
87 //! theGamma - gamma value to use; a value of 1.0 leaves the image alone
88 Standard_EXPORT bool AdjustGamma (const Standard_Real theGammaCorr);
89
90private:
91
92 FIBITMAP* myLibImage;
93
94private:
95
96 //! Copying allowed only within Handles
97 Image_AlienPixMap (const Image_AlienPixMap& );
98 Image_AlienPixMap& operator= (const Image_AlienPixMap& );
99
100 //! Wrapper initialization is disallowed for this class (will return false in any case)!
101 //! Use only copying and allocation initializers.
dc858f4c 102 Standard_EXPORT virtual bool InitWrapper (Image_Format thePixelFormat,
692613e5 103 Standard_Byte* theDataPtr,
104 const Standard_Size theSizeX,
105 const Standard_Size theSizeY,
79104795 106 const Standard_Size theSizeRowBytes) Standard_OVERRIDE;
692613e5 107
108 //! Built-in PPM export
109 Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const;
110
692613e5 111};
112
113DEFINE_STANDARD_HANDLE(Image_AlienPixMap, Image_PixMap)
114
115#endif // _Image_AlienPixMap_H__