1 // Created on: 2012-07-18
2 // Created by: Kirill GAVRILOV
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Image_AlienPixMap_H__
17 #define _Image_AlienPixMap_H__
19 #include <Image_PixMap.hxx>
21 class TCollection_AsciiString;
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 palette (up to 256 distinct colors).
33 //! - *.exr - OpenEXR high dynamic-range format (supports float pixel formats).
34 class Image_AlienPixMap : public Image_PixMap
36 DEFINE_STANDARD_RTTIEXT(Image_AlienPixMap, Image_PixMap)
39 //! Return default rows order used by underlying image library.
40 Standard_EXPORT static bool IsTopDownDefault();
43 //! Empty constructor.
44 Standard_EXPORT Image_AlienPixMap();
47 Standard_EXPORT virtual ~Image_AlienPixMap();
49 //! Read image data from file.
50 bool Load (const TCollection_AsciiString& theFileName)
52 return Load (NULL, 0, theFileName);
55 //! Read image data from stream.
56 Standard_EXPORT bool Load (std::istream& theStream,
57 const TCollection_AsciiString& theFileName);
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);
68 //! Write image data to file using file extension to determine compression format.
69 Standard_EXPORT bool Save (const TCollection_AsciiString& theFileName);
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!
75 Standard_EXPORT virtual bool InitTrash (Image_Format thePixelFormat,
76 const Standard_Size theSizeX,
77 const Standard_Size theSizeY,
78 const Standard_Size theSizeRowBytes = 0) Standard_OVERRIDE;
80 //! Initialize by copying data.
81 Standard_EXPORT virtual bool InitCopy (const Image_PixMap& theCopy) Standard_OVERRIDE;
83 //! Method correctly deallocate internal buffer.
84 Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
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);
96 //! Copying allowed only within Handles
97 Image_AlienPixMap (const Image_AlienPixMap& );
98 Image_AlienPixMap& operator= (const Image_AlienPixMap& );
100 //! Wrapper initialization is disallowed for this class (will return false in any case)!
101 //! Use only copying and allocation initializers.
102 Standard_EXPORT virtual bool InitWrapper (Image_Format thePixelFormat,
103 Standard_Byte* theDataPtr,
104 const Standard_Size theSizeX,
105 const Standard_Size theSizeY,
106 const Standard_Size theSizeRowBytes) Standard_OVERRIDE;
108 //! Built-in PPM export
109 Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const;
113 DEFINE_STANDARD_HANDLE(Image_AlienPixMap, Image_PixMap)
115 #endif // _Image_AlienPixMap_H__