1 // Created on: 2012-07-18
2 // Created by: Kirill GAVRILOV
3 // Copyright (c) 2012 OPEN CASCADE SAS
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.
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.
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.
20 #ifndef _Image_AlienPixMap_H__
21 #define _Image_AlienPixMap_H__
23 #include <Image_PixMap.hxx>
24 #include <Image_TypeOfImage.hxx>
26 class TCollection_AsciiString;
29 //! Image class that support file reading/writing operations using auxiliary image library.
30 //! Supported image formats:
31 //! - *.bmp - bitmap image, lossless format without compression.
32 //! - *.ppm - PPM (Portable Pixmap Format), lossless format without compression.
33 //! - *.png - PNG (Portable Network Graphics) lossless format with compression.
34 //! - *.jpg, *.jpe, *.jpeg - JPEG/JIFF (Joint Photographic Experts Group) lossy format (compressed with quality losses). YUV color space used (automatically converted from/to RGB).
35 //! - *.tif, *.tiff - TIFF (Tagged Image File Format).
36 //! - *.tga - TGA (Truevision Targa Graphic), lossless format.
37 //! - *.gif - GIF (Graphical Interchange Format), lossy format. Color stored using pallete (up to 256 distinct colors).
38 //! - *.exr - OpenEXR high dynamic-range format (supports float pixel formats).
39 class Image_AlienPixMap : public Image_PixMap
44 //! Empty constructor.
45 Standard_EXPORT Image_AlienPixMap();
48 Standard_EXPORT virtual ~Image_AlienPixMap();
50 //! Read image data from file.
51 Standard_EXPORT bool Load (const TCollection_AsciiString& theFileName);
53 //! Write image data to file using file extension to determine compression format.
54 Standard_EXPORT bool Save (const TCollection_AsciiString& theFileName);
56 //! Initialize image plane with required dimensions.
57 //! thePixelFormat - if specified pixel format doesn't supported by image library
58 //! than nearest supported will be used instead!
59 //! theSizeRowBytes - may be ignored by this class and required alignemnt will be used instead!
60 Standard_EXPORT virtual bool InitTrash (ImgFormat thePixelFormat,
61 const Standard_Size theSizeX,
62 const Standard_Size theSizeY,
63 const Standard_Size theSizeRowBytes = 0);
65 //! Initialize by copying data.
66 Standard_EXPORT virtual bool InitCopy (const Image_PixMap& theCopy);
68 //! Method correctly deallocate internal buffer.
69 Standard_EXPORT virtual void Clear (ImgFormat thePixelFormat = ImgGray);
71 //! Performs gamma correction on image.
72 //! theGamma - gamma value to use; a value of 1.0 leaves the image alone
73 Standard_EXPORT bool AdjustGamma (const Standard_Real theGammaCorr);
81 //! Copying allowed only within Handles
82 Image_AlienPixMap (const Image_AlienPixMap& );
83 Image_AlienPixMap& operator= (const Image_AlienPixMap& );
85 //! Wrapper initialization is disallowed for this class (will return false in any case)!
86 //! Use only copying and allocation initializers.
87 Standard_EXPORT virtual bool InitWrapper (ImgFormat thePixelFormat,
88 Standard_Byte* theDataPtr,
89 const Standard_Size theSizeX,
90 const Standard_Size theSizeY,
91 const Standard_Size theSizeRowBytes);
93 //! Built-in PPM export
94 Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const;
98 DEFINE_STANDARD_RTTI(Image_AlienPixMap) // Type definition
102 DEFINE_STANDARD_HANDLE(Image_AlienPixMap, Image_PixMap)
104 #endif // _Image_AlienPixMap_H__