1 // Created on: 2013-06-25
2 // Created by: Dmitry BOBYLEV
3 // Copyright (c) 2013-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 _Graphic3d_MarkerImage_H__
17 #define _Graphic3d_MarkerImage_H__
19 #include <Graphic3d_MarkerImage_Handle.hxx>
21 #include <Handle_TColStd_HArray1OfByte.hxx>
22 #include <Image_PixMap_Handle.hxx>
23 #include <Quantity_Parameter.hxx>
24 #include <TCollection_AsciiString.hxx>
26 //! This class is used to store bitmaps and images for markers rendering.
27 //! It can convert bitmap texture stored in TColStd_HArray1OfByte to Image_PixMap and vice versa.
28 class Graphic3d_MarkerImage : public Standard_Transient
32 //! @param theImage - source image
33 Standard_EXPORT Graphic3d_MarkerImage (const Handle(Image_PixMap)& theImage);
35 //! Creates marker image from array of bytes
36 //! (method for compatibility with old markers definition).
37 //! @param theBitMap - source bitmap stored as array of bytes
38 //! @param theWidth - number of bits in a row
39 //! @param theHeight - number of bits in a column
40 Standard_EXPORT Graphic3d_MarkerImage (const Handle(TColStd_HArray1OfByte)& theBitMap,
41 const Standard_Integer& theWidth,
42 const Standard_Integer& theHeight);
44 //! @param theAlphaValue pixels in the image that have alpha value greater than
45 //! or equal to this parameter will be stored in bitmap as "1",
46 //! others will be stored as "0"
47 //! @return marker image as array of bytes. If an instance of the class has been
48 //! initialized with image, it will be converted to bitmap based on the parameter theAlphaValue.
49 Standard_EXPORT Handle(TColStd_HArray1OfByte) GetBitMapArray (const Standard_Real& theAlphaValue = 0.5) const;
51 //! @return marker image. If an instance of the class has been initialized with a bitmap, it will be
52 //! converted to image.
53 Standard_EXPORT const Handle(Image_PixMap)& GetImage();
55 //! @return image alpha as grayscale image. Note that if an instance of the class has been initialized
56 //! with a bitmap or with grayscale image this method will return exactly the same image as GetImage()
57 Standard_EXPORT const Handle(Image_PixMap)& GetImageAlpha();
59 //! @return an unique ID. This ID will be used to manage resource in graphic driver.
60 Standard_EXPORT const TCollection_AsciiString& GetImageId() const;
62 //! @return an unique ID. This ID will be used to manage resource in graphic driver.
63 Standard_EXPORT const TCollection_AsciiString& GetImageAlphaId() const;
65 //! @return texture size
66 Standard_EXPORT void GetTextureSize (Standard_Integer& theWidth,
67 Standard_Integer& theHeight) const;
71 TCollection_AsciiString myImageId; //!< resource identifier
72 TCollection_AsciiString myImageAlphaId; //!< resource identifier
73 Handle(TColStd_HArray1OfByte) myBitMap; //!< bytes array with bitmap definition (for compatibility with old code)
74 Handle(Image_PixMap) myImage; //!< full-color marker definition
75 Handle(Image_PixMap) myImageAlpha; //!< alpha-color marker definition (for dynamic hi-lighting)
76 Standard_Integer myMargin; //!< extra margin from boundaries for bitmap -> point sprite conversion, 1 px by default
77 Standard_Integer myWidth; //!< marker width
78 Standard_Integer myHeight; //!< marker height
82 DEFINE_STANDARD_RTTI(Graphic3d_MarkerImage) // Type definition
86 #endif // _Graphic3d_MarkerImage_H__