CFx SDK Documentation  2022 SP0
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_
OdSmartPtr< OdGiRasterImage > OdGiRasterImagePtr
OdSmartPtr< OdGiRasterImageParam > OdGiRasterImageParamPtr
#define NULL
Definition: GsProperties.h:177
#define ODCOLORREF
Definition: OdPlatform.h:883
unsigned int OdUInt32
unsigned char OdUInt8
wchar_t OdChar
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
virtual Units defaultResolution(double &xPelsPerUnit, double &yPelsPerUnit) const
virtual PixelFormatInfo pixelFormat() const =0
virtual OdUInt32 scanLineSize() const
virtual TransparencyMode transparencyMode() const
virtual ODCOLORREF color(OdUInt32 colorIndex) const =0
static OdUInt32 calcBMPScanLineSize(OdUInt32 pixelWidth, int colorDepth)
virtual OdUInt32 pixelHeight() const =0
virtual OdUInt32 scanLinesAlignment() const =0
OdSmartPtr< OdGiRasterImage > changeTransparencyMode(TransparencyMode mode)
OdSmartPtr< OdGiRasterImage > changeSourceFileName(const OdString &fileName)
ODRX_DECLARE_MEMBERS(OdGiRasterImage)
virtual OdUInt32 paletteDataSize() const =0
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
virtual const OdUInt8 * scanLines() const =0
virtual void * imp() const
virtual void paletteData(OdUInt8 *bytes) const =0
virtual void scanLines(OdUInt8 *scnLines, OdUInt32 firstScanline, OdUInt32 numLines=1) const =0
virtual OdSmartPtr< OdGiRasterImage > crop(OdUInt32 x, OdUInt32 y, OdUInt32 width, OdUInt32 height) const
virtual OdUInt32 colorDepth() const =0
static OdUInt32 calcColorMask(OdUInt8 numColorBits, OdUInt8 colorOffset=0)
virtual ImageSource imageSource() const
virtual const OdString & sourceFileName() const
virtual OdUInt32 numColors() const =0
virtual OdUInt32 pixelWidth() const =0
OdSmartPtr< OdGiRasterImage > changeImageSource(ImageSource source, const OdChar *pFileName=NULL)
virtual int transparentColor() const
virtual void setImageSource(ImageSource source)
virtual void setSourceFileName(const OdString &fileName)
ODRX_DECLARE_MEMBERS(OdGiRasterImageParam)
virtual OdUInt32 supportedParams() const =0
virtual void setTransparencyMode(TransparencyMode mode)
GLint GLenum GLsizei width
Definition: gles2_ext.h:110
GLsizei GLsizei GLchar * source
Definition: gles2_ext.h:282
GLfloat x
Definition: gles2_ext.h:314
GLint GLenum GLsizei GLsizei height
Definition: gles2_ext.h:110
GLfloat GLfloat y
Definition: gles2_ext.h:316
bool DAI_EXPORT operator==(const OdFileDescriptionAuto &left, const OdFileDescriptionAuto &right)
@ kNone
Light mode is inherited from the annotation.