a577aaab |
1 | // Created on: 2013-06-25 |
2 | // Created by: Dmitry BOBYLEV |
d5f74e42 |
3 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
a577aaab |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
a577aaab |
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. |
a577aaab |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
a577aaab |
15 | |
16 | #ifndef _Graphic3d_MarkerImage_H__ |
17 | #define _Graphic3d_MarkerImage_H__ |
18 | |
cb389a77 |
19 | #include <TColStd_HArray1OfByte.hxx> |
a577aaab |
20 | #include <TCollection_AsciiString.hxx> |
21 | |
c04c30b3 |
22 | class Image_PixMap; |
23 | |
a577aaab |
24 | //! This class is used to store bitmaps and images for markers rendering. |
25 | //! It can convert bitmap texture stored in TColStd_HArray1OfByte to Image_PixMap and vice versa. |
26 | class Graphic3d_MarkerImage : public Standard_Transient |
27 | { |
28 | public: |
29 | |
30 | //! @param theImage - source image |
31 | Standard_EXPORT Graphic3d_MarkerImage (const Handle(Image_PixMap)& theImage); |
32 | |
33 | //! Creates marker image from array of bytes |
34 | //! (method for compatibility with old markers definition). |
35 | //! @param theBitMap - source bitmap stored as array of bytes |
36 | //! @param theWidth - number of bits in a row |
37 | //! @param theHeight - number of bits in a column |
38 | Standard_EXPORT Graphic3d_MarkerImage (const Handle(TColStd_HArray1OfByte)& theBitMap, |
39 | const Standard_Integer& theWidth, |
40 | const Standard_Integer& theHeight); |
41 | |
42 | //! @param theAlphaValue pixels in the image that have alpha value greater than |
43 | //! or equal to this parameter will be stored in bitmap as "1", |
44 | //! others will be stored as "0" |
45 | //! @return marker image as array of bytes. If an instance of the class has been |
46 | //! initialized with image, it will be converted to bitmap based on the parameter theAlphaValue. |
47 | Standard_EXPORT Handle(TColStd_HArray1OfByte) GetBitMapArray (const Standard_Real& theAlphaValue = 0.5) const; |
48 | |
49 | //! @return marker image. If an instance of the class has been initialized with a bitmap, it will be |
50 | //! converted to image. |
51 | Standard_EXPORT const Handle(Image_PixMap)& GetImage(); |
52 | |
53 | //! @return image alpha as grayscale image. Note that if an instance of the class has been initialized |
54 | //! with a bitmap or with grayscale image this method will return exactly the same image as GetImage() |
55 | Standard_EXPORT const Handle(Image_PixMap)& GetImageAlpha(); |
56 | |
57 | //! @return an unique ID. This ID will be used to manage resource in graphic driver. |
58 | Standard_EXPORT const TCollection_AsciiString& GetImageId() const; |
59 | |
60 | //! @return an unique ID. This ID will be used to manage resource in graphic driver. |
61 | Standard_EXPORT const TCollection_AsciiString& GetImageAlphaId() const; |
62 | |
63 | //! @return texture size |
64 | Standard_EXPORT void GetTextureSize (Standard_Integer& theWidth, |
65 | Standard_Integer& theHeight) const; |
66 | |
67 | private: |
68 | |
69 | TCollection_AsciiString myImageId; //!< resource identifier |
70 | TCollection_AsciiString myImageAlphaId; //!< resource identifier |
71 | Handle(TColStd_HArray1OfByte) myBitMap; //!< bytes array with bitmap definition (for compatibility with old code) |
72 | Handle(Image_PixMap) myImage; //!< full-color marker definition |
73 | Handle(Image_PixMap) myImageAlpha; //!< alpha-color marker definition (for dynamic hi-lighting) |
74 | Standard_Integer myMargin; //!< extra margin from boundaries for bitmap -> point sprite conversion, 1 px by default |
75 | Standard_Integer myWidth; //!< marker width |
76 | Standard_Integer myHeight; //!< marker height |
77 | |
78 | public: |
79 | |
92efcf78 |
80 | DEFINE_STANDARD_RTTIEXT(Graphic3d_MarkerImage,Standard_Transient) // Type definition |
a577aaab |
81 | |
82 | }; |
83 | |
494782f6 |
84 | DEFINE_STANDARD_HANDLE (Graphic3d_MarkerImage, Standard_Transient) |
85 | |
a577aaab |
86 | #endif // _Graphic3d_MarkerImage_H__ |