CFx SDK Documentation  2020SP3
GiRasterImage.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef _OD_ODGIRASTERIMAGE_H_
25 #define _OD_ODGIRASTERIMAGE_H_
26 
27 #include "RxObject.h"
28 
29 #include "TD_PackPush.h"
30 
37 {
38 public:
40 
41  enum Units
42  {
43  kNone = 0,
63  kParsecs
64  };
65 
67  {
68  kUndefinedSource = -1, // Flag not set (unknown source).
69  kFromDwg = 0, // Raster image loaded from raster image definition.
70  kFromOleObject = 1, // Raster image generated from OLE data source.
71  kFromRender = 2, // Raster image generated from rendering.
72 
73  kFromUnderlay = 10, // Raster image is part of underlay.
74  kFromImageBGRA32 = 11, // Raster image wraps OdGiImageBGRA32 image.
75 
76  // Aliases
77  kFromPdfUnderlay = kFromOleObject, // Raster image generated from PdfUnderlay.
78  kFromFile = kFromDwg // Raster image generated from disk file.
79  };
80 
82  {
83  kTransparencyDef = -1, // Default for native raster image (alpha 0 is transparent, 1-255 is opaque).
84  kTransparencyOff = 0, // Alpha ignored for 32bpp formats.
85  kTransparency1Bit = 1, // Alpha 0-254 is transparent, 255 is opaque.
86  kTransparency8Bit = 2 // Complete alpha level support for 32bpp formats.
87  };
88 
89  typedef struct tagPixelFormatInfo
90  {
100 
101  bool operator ==(const struct tagPixelFormatInfo& other) const
102  {
103  return (redOffset == other.redOffset) && (greenOffset == other.greenOffset) &&
104  (blueOffset == other.blueOffset) && (alphaOffset == other.alphaOffset) && (bitsPerPixel == other.bitsPerPixel) &&
105  (numRedBits == other.numRedBits) && (numGreenBits == other.numGreenBits) && (numBlueBits == other.numBlueBits) &&
106  (numAlphaBits == other.numAlphaBits);
107  }
108 
110  : redOffset(0)
111  , numRedBits(0)
112  , greenOffset(0)
113  , numGreenBits(0)
114  , blueOffset(0)
115  , numBlueBits(0)
116  , alphaOffset(0)
117  , numAlphaBits(0)
118  , bitsPerPixel(0)
119  {}
120 
124  bool isRGB() const
125  {
126  return bitsPerPixel == 24 &&
127  redOffset == 0 && greenOffset == 8 && blueOffset == 16 && numRedBits == 8 && numGreenBits == 8 && numBlueBits == 8;
128  }
129 
135  void setRGB()
136  {
137  bitsPerPixel = 24;
138  redOffset = 0;
139  greenOffset = 8;
140  blueOffset = 16;
141  numRedBits = 8;
142  numGreenBits = 8;
143  numBlueBits = 8;
144  }
145 
149  bool isBGR() const
150  {
151  return bitsPerPixel == 24 &&
152  redOffset == 16 && greenOffset == 8 && blueOffset == 0 && numRedBits == 8 && numGreenBits == 8 && numBlueBits == 8;
153  }
154 
160  void setBGR()
161  {
162  bitsPerPixel = 24;
163  redOffset = 16;
164  greenOffset = 8;
165  blueOffset = 0;
166  numRedBits = 8;
167  numGreenBits = 8;
168  numBlueBits = 8;
169  }
170 
174  bool is16bitBGR() const
175  {
176  return bitsPerPixel == 16 &&
177  redOffset == 10 && greenOffset == 5 && blueOffset == 0 && numRedBits == 5 && numGreenBits == 5 && numBlueBits == 5;
178  }
179 
185  void set16bitBGR()
186  {
187  bitsPerPixel = 16;
188  redOffset = 10;
189  greenOffset = 5;
190  blueOffset = 0;
191  numRedBits = 5;
192  numGreenBits = 5;
193  numBlueBits = 5;
194  }
195 
199  bool isRGBA() const
200  {
201  return bitsPerPixel == 32 && alphaOffset == 24 && numAlphaBits == 8 &&
202  redOffset == 0 && greenOffset == 8 && blueOffset == 16 && numRedBits == 8 && numGreenBits == 8 && numBlueBits == 8;
203  }
204 
210  void setRGBA()
211  {
212  bitsPerPixel = 32;
213  alphaOffset = 24;
214  numAlphaBits = 8;
215  redOffset = 0;
216  greenOffset = 8;
217  blueOffset = 16;
218  numRedBits = 8;
219  numGreenBits = 8;
220  numBlueBits = 8;
221  }
222 
226  bool isBGRA() const
227  {
228  return bitsPerPixel == 32 && alphaOffset == 24 && numAlphaBits == 8 &&
229  redOffset == 16 && greenOffset == 8 && blueOffset == 0 && numRedBits == 8 && numGreenBits == 8 && numBlueBits == 8;
230  }
231 
237  void setBGRA()
238  {
239  bitsPerPixel = 32;
240  alphaOffset = 24;
241  numAlphaBits = 8;
242  redOffset = 16;
243  greenOffset = 8;
244  blueOffset = 0;
245  numRedBits = 8;
246  numGreenBits = 8;
247  numBlueBits = 8;
248  }
249  } PixelFormatInfo;
250 
254  virtual OdUInt32 pixelWidth() const = 0;
255 
259  virtual OdUInt32 pixelHeight() const = 0;
260 
270  virtual Units defaultResolution(double& xPelsPerUnit, double& yPelsPerUnit) const;
271 
275  virtual OdUInt32 colorDepth() const = 0;
276 
280  virtual OdUInt32 numColors() const = 0;
281 
290  virtual int transparentColor() const;
291 
296  virtual ODCOLORREF color(OdUInt32 colorIndex) const = 0;
297 
301  virtual OdUInt32 paletteDataSize() const = 0;
302 
310  virtual void paletteData(OdUInt8* bytes) const = 0;
311 
320  virtual OdUInt32 scanLineSize() const;
321 
333  virtual const OdUInt8* scanLines() const = 0;
334 
352  virtual void scanLines(OdUInt8* scnLines, OdUInt32 firstScanline, OdUInt32 numLines = 1) const = 0;
353 
362  virtual PixelFormatInfo pixelFormat() const = 0;
363 
369  virtual OdUInt32 scanLinesAlignment() const = 0;
370 
374  virtual ImageSource imageSource() const;
375 
379  virtual const OdString &sourceFileName() const;
380 
385 
393 
400 
407 
413  static OdUInt32 calcBMPScanLineSize(OdUInt32 pixelWidth, int colorDepth);
414 
420  static OdUInt32 calcColorMask(OdUInt8 numColorBits, OdUInt8 colorOffset = 0);
421 
437  OdSmartPtr<OdGiRasterImage> convert(bool convertPaletteToRGB,
438  double brightness = 50.0, double contrast = 50.0, double fade = 0.0, ODCOLORREF backgroundColor = 0,
439  bool flipX = false, bool flipY = false, bool rotate90 = false,
440  const OdGiRasterImage* pDestDesc = 0,
441  bool transparency = false) const;
442 
455 
461  virtual void *imp() const;
462 };
463 
465 
474 {
475 public:
477 
479  {
480  kImageSource = (1 << 0),
481  kTransparencyMode = (1 << 1),
482  kSourceFileName = (1 << 2)
483  };
484 
488  virtual OdUInt32 supportedParams() const = 0;
489 
495 
500  virtual void setSourceFileName(const OdString &fileName) { }
501 
506  virtual void setTransparencyMode(TransparencyMode mode) { }
507 };
508 
510 
511 #include "TD_PackPop.h"
512 
513 #endif //#ifndef _OD_ODGIRASTERIMAGE_H_
FIRSTDLL_EXPORT
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
OdGiRasterImage::kDecimeters
@ kDecimeters
Definition: GiRasterImage.h:57
OdGiRasterImage::tagPixelFormatInfo::numGreenBits
OdUInt8 numGreenBits
Definition: GiRasterImage.h:94
OdGiRasterImage::tagPixelFormatInfo::redOffset
OdUInt8 redOffset
Definition: GiRasterImage.h:91
OdGiRasterImage::scanLines
virtual void scanLines(OdUInt8 *scnLines, OdUInt32 firstScanline, OdUInt32 numLines=1) const =0
OdGiRasterImage::tagPixelFormatInfo::bitsPerPixel
OdUInt8 bitsPerPixel
Definition: GiRasterImage.h:99
OdGiRasterImage::pixelWidth
virtual OdUInt32 pixelWidth() const =0
OdString
Definition: OdString.h:95
NULL
#define NULL
Definition: GsProperties.h:177
OdGiRasterImage::kMils
@ kMils
Definition: GiRasterImage.h:53
OdGiRasterImageParam::ParamType
ParamType
Definition: GiRasterImage.h:479
OdUInt8
unsigned char OdUInt8
Definition: OdPlatformSettings.h:759
OdGiRasterImage::tagPixelFormatInfo
Definition: GiRasterImage.h:90
OdGiRasterImageParam::setImageSource
virtual void setImageSource(ImageSource source)
Definition: GiRasterImage.h:494
OdGiRasterImageParamPtr
OdSmartPtr< OdGiRasterImageParam > OdGiRasterImageParamPtr
Definition: GiRasterImage.h:509
OdGiRasterImage::calcColorMask
static OdUInt32 calcColorMask(OdUInt8 numColorBits, OdUInt8 colorOffset=0)
OdGiRasterImagePtr
OdSmartPtr< OdGiRasterImage > OdGiRasterImagePtr
Definition: GiRasterImage.h:464
OdRxObject
Definition: RxObject.h:564
OdGiRasterImage::kNanometers
@ kNanometers
Definition: GiRasterImage.h:55
source
GLsizei GLsizei GLchar * source
Definition: gles2_ext.h:282
OdGiRasterImage::kFoot
@ kFoot
Definition: GiRasterImage.h:49
OdGiRasterImage::calcBMPScanLineSize
static OdUInt32 calcBMPScanLineSize(OdUInt32 pixelWidth, int colorDepth)
OdGiRasterImage::tagPixelFormatInfo::isBGR
bool isBGR() const
Definition: GiRasterImage.h:149
TD_PackPop.h
OdGiRasterImage::kHectometers
@ kHectometers
Definition: GiRasterImage.h:59
OdGiRasterImage::color
virtual ODCOLORREF color(OdUInt32 colorIndex) const =0
OdGiRasterImage::imp
virtual void * imp() const
OdGiRasterImage::tagPixelFormatInfo::isRGB
bool isRGB() const
Definition: GiRasterImage.h:124
x
GLfloat x
Definition: gles2_ext.h:314
OdGiRasterImage::tagPixelFormatInfo::isRGBA
bool isRGBA() const
Definition: GiRasterImage.h:199
OdGiRasterImage::crop
virtual OdSmartPtr< OdGiRasterImage > crop(OdUInt32 x, OdUInt32 y, OdUInt32 width, OdUInt32 height) const
OdGiRasterImage::ODRX_DECLARE_MEMBERS
ODRX_DECLARE_MEMBERS(OdGiRasterImage)
OdGiRasterImage::changeImageSource
OdSmartPtr< OdGiRasterImage > changeImageSource(ImageSource source, const OdChar *pFileName=NULL)
RxObject.h
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdGiRasterImage::changeSourceFileName
OdSmartPtr< OdGiRasterImage > changeSourceFileName(const OdString &fileName)
OdGiRasterImage::tagPixelFormatInfo::tagPixelFormatInfo
tagPixelFormatInfo()
Definition: GiRasterImage.h:109
OdGiRasterImage::transparentColor
virtual int transparentColor() const
OdPdfPublish::Lighting::kNone
@ kNone
Light mode is inherited from the annotation.
Definition: PdfPublishCommon.h:160
OdGiRasterImage::tagPixelFormatInfo::numRedBits
OdUInt8 numRedBits
Definition: GiRasterImage.h:92
OdGiRasterImage::tagPixelFormatInfo::set16bitBGR
void set16bitBGR()
Definition: GiRasterImage.h:185
OdGiRasterImage::tagPixelFormatInfo::numBlueBits
OdUInt8 numBlueBits
Definition: GiRasterImage.h:96
OdGiRasterImage::paletteDataSize
virtual OdUInt32 paletteDataSize() const =0
OdGiRasterImage::kMillimeter
@ kMillimeter
Definition: GiRasterImage.h:44
OdSmartPtr< OdGiRasterImage >
OdGiRasterImageParam::ODRX_DECLARE_MEMBERS
ODRX_DECLARE_MEMBERS(OdGiRasterImageParam)
OdGiRasterImage::sourceFileName
virtual const OdString & sourceFileName() const
OdGiRasterImage::kMeter
@ kMeter
Definition: GiRasterImage.h:46
OdGiRasterImage::kMicroinches
@ kMicroinches
Definition: GiRasterImage.h:52
y
GLfloat GLfloat y
Definition: gles2_ext.h:316
OdGiRasterImage::tagPixelFormatInfo::setBGR
void setBGR()
Definition: GiRasterImage.h:160
OdGiRasterImage::kAstronomical
@ kAstronomical
Definition: GiRasterImage.h:61
OdGiRasterImage::colorDepth
virtual OdUInt32 colorDepth() const =0
OdChar
wchar_t OdChar
Definition: OdPlatformSettings.h:745
OdGiRasterImage::kMicrons
@ kMicrons
Definition: GiRasterImage.h:56
OdGiRasterImageParam::setTransparencyMode
virtual void setTransparencyMode(TransparencyMode mode)
Definition: GiRasterImage.h:506
OdGiRasterImage::kYard
@ kYard
Definition: GiRasterImage.h:50
OdGiRasterImage::imageSource
virtual ImageSource imageSource() const
OdGiRasterImageParam
Definition: GiRasterImage.h:474
height
GLint GLenum GLsizei GLsizei height
Definition: gles2_ext.h:110
width
GLint GLenum GLsizei width
Definition: gles2_ext.h:110
OdGiRasterImage::kLightYears
@ kLightYears
Definition: GiRasterImage.h:62
TD_PackPush.h
OdGiRasterImage::tagPixelFormatInfo::numAlphaBits
OdUInt8 numAlphaBits
Definition: GiRasterImage.h:98
OdGiRasterImage::kMile
@ kMile
Definition: GiRasterImage.h:51
OdGiRasterImage::TransparencyMode
TransparencyMode
Definition: GiRasterImage.h:82
OdGiRasterImage::tagPixelFormatInfo::setBGRA
void setBGRA()
Definition: GiRasterImage.h:237
OdGiRasterImage::convert
OdSmartPtr< OdGiRasterImage > convert(bool convertPaletteToRGB, double brightness=50.0, double contrast=50.0, double fade=0.0, ODCOLORREF backgroundColor=0, bool flipX=false, bool flipY=false, bool rotate90=false, const OdGiRasterImage *pDestDesc=0, bool transparency=false) const
OdGiRasterImage::tagPixelFormatInfo::alphaOffset
OdUInt8 alphaOffset
Definition: GiRasterImage.h:97
OdGiRasterImage::pixelHeight
virtual OdUInt32 pixelHeight() const =0
OdGiRasterImage::Units
Units
Definition: GiRasterImage.h:42
OdGiRasterImage::transparencyMode
virtual TransparencyMode transparencyMode() const
OdGiRasterImage::numColors
virtual OdUInt32 numColors() const =0
OdGiRasterImage::kGigameters
@ kGigameters
Definition: GiRasterImage.h:60
OdGiRasterImage::kCentimeter
@ kCentimeter
Definition: GiRasterImage.h:45
OdGiRasterImage::scanLineSize
virtual OdUInt32 scanLineSize() const
OdGiRasterImage::pixelFormat
virtual PixelFormatInfo pixelFormat() const =0
OdGiRasterImage::scanLinesAlignment
virtual OdUInt32 scanLinesAlignment() const =0
OdDAI::operator==
bool DAI_EXPORT operator==(const OdFileDescriptionAuto &left, const OdFileDescriptionAuto &right)
ODCOLORREF
#define ODCOLORREF
Definition: OdPlatform.h:883
OdGiRasterImage::defaultResolution
virtual Units defaultResolution(double &xPelsPerUnit, double &yPelsPerUnit) const
OdGiRasterImageParam::setSourceFileName
virtual void setSourceFileName(const OdString &fileName)
Definition: GiRasterImage.h:500
OdGiRasterImage::kInch
@ kInch
Definition: GiRasterImage.h:48
OdGiRasterImage::kDekameters
@ kDekameters
Definition: GiRasterImage.h:58
OdGiRasterImage::ImageSource
ImageSource
Definition: GiRasterImage.h:67
OdGiRasterImage::tagPixelFormatInfo::isBGRA
bool isBGRA() const
Definition: GiRasterImage.h:226
OdGiRasterImage::scanLines
virtual const OdUInt8 * scanLines() const =0
OdGiRasterImage::tagPixelFormatInfo::blueOffset
OdUInt8 blueOffset
Definition: GiRasterImage.h:95
OdGiRasterImage::tagPixelFormatInfo::setRGBA
void setRGBA()
Definition: GiRasterImage.h:210
OdGiRasterImage::kAngstroms
@ kAngstroms
Definition: GiRasterImage.h:54
OdGiRasterImageParam::supportedParams
virtual OdUInt32 supportedParams() const =0
OdGiRasterImage::tagPixelFormatInfo::is16bitBGR
bool is16bitBGR() const
Definition: GiRasterImage.h:174
OdGiRasterImage::paletteData
virtual void paletteData(OdUInt8 *bytes) const =0
OdGiRasterImage
Definition: GiRasterImage.h:37
OdGiRasterImage::tagPixelFormatInfo::setRGB
void setRGB()
Definition: GiRasterImage.h:135
OdGiRasterImage::kKilometer
@ kKilometer
Definition: GiRasterImage.h:47
OdGiRasterImage::tagPixelFormatInfo::greenOffset
OdUInt8 greenOffset
Definition: GiRasterImage.h:93
OdGiRasterImage::changeTransparencyMode
OdSmartPtr< OdGiRasterImage > changeTransparencyMode(TransparencyMode mode)