CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GiRasterImage.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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
41{
42public:
43 //DOM-IGNORE-BEGIN
45 //DOM-IGNORE-END
46
50 enum Units
51 {
53 kNone = 0,
93 kParsecs
94 };
95
103 static double millimetersInUnit(Units units)
104 {
105 switch (units)
106 {
107 case kNone:
108 throw OdError(eInvalidInput);
109 case kMillimeter:
110 return 1.0;
111 case kCentimeter:
112 return 10.0;
113 case kMeter:
114 return 1000.0;
115 case kKilometer:
116 return 1000000.0;
117 case kInch:
118 return 25.4;
119 case kFoot:
120 return 25.4 * 12.0;
121 case kYard:
122 return 25.4 * 12.0 * 3.;
123 case kMile:
124 return 25.4 * 12.0 * 3. * 1760.;
125 case kMicroinches:
126 return 25.4 * 0.000001;
127 case kMils:
128 return 25.4 * 0.001;
129 case kAngstroms:
130 return 1000.0 * 1.e-10;
131 case kNanometers:
132 return 0.000001;
133 case kMicrons:
134 return 0.001;
135 case kDecimeters:
136 return 100.0;
137 case kDekameters:
138 return 10000.0;
139 case kHectometers:
140 return 100000.0;
141 case kGigameters:
142 return 1000. * 1.e9;
143 case kAstronomical:
144 return 1000. * 149597870700.; // Approx. the length of the semi-major axis of the Earth's elliptical orbit around the Sun
145 case kLightYears:
146 return 1000. * 9460730472580800.;
147 case kParsecs:
148 return 1000. * 30856775814671900.;
149 }
150 ODA_ASSERT_ONCE(!"Unknown unit");
151 return 1.0;
152 }
153
158 {
160 kUndefinedSource = -1,
162 kFromDwg = 0,
164 kFromOleObject = 1,
166 kFromRender = 2,
167
169 kFromUnderlay = 10,
171 kFromImageBGRA32 = 11,
172
173 // Aliases
175 kFromPdfUnderlay = kFromOleObject,
177 kFromFile = kFromDwg
178 };
179
184 {
186 kTransparencyDef = -1,
188 kTransparencyOff = 0,
190 kTransparency1Bit = 1,
192 kTransparency8Bit = 2
193 };
194
198 typedef struct tagPixelFormatInfo
199 {
218
229 bool operator ==(const struct tagPixelFormatInfo& other) const
230 {
231 return (redOffset == other.redOffset) && (greenOffset == other.greenOffset) &&
232 (blueOffset == other.blueOffset) && (alphaOffset == other.alphaOffset) && (bitsPerPixel == other.bitsPerPixel) &&
233 (numRedBits == other.numRedBits) && (numGreenBits == other.numGreenBits) && (numBlueBits == other.numBlueBits) &&
234 (numAlphaBits == other.numAlphaBits);
235 }
236
242 : redOffset(0)
243 , numRedBits(0)
244 , greenOffset(0)
245 , numGreenBits(0)
246 , blueOffset(0)
247 , numBlueBits(0)
248 , alphaOffset(0)
249 , numAlphaBits(0)
250 , bitsPerPixel(0)
251 {}
252
259 bool isRGB() const
260 {
261 return bitsPerPixel == 24 &&
262 redOffset == 0 && greenOffset == 8 && blueOffset == 16 && numRedBits == 8 && numGreenBits == 8 && numBlueBits == 8;
263 }
264
271 void setRGB()
272 {
273 bitsPerPixel = 24;
274 redOffset = 0;
275 greenOffset = 8;
276 blueOffset = 16;
277 numRedBits = 8;
278 numGreenBits = 8;
279 numBlueBits = 8;
280 }
281
289 bool isBGR() const
290 {
291 return bitsPerPixel == 24 &&
292 redOffset == 16 && greenOffset == 8 && blueOffset == 0 && numRedBits == 8 && numGreenBits == 8 && numBlueBits == 8;
293 }
294
301 void setBGR()
302 {
303 bitsPerPixel = 24;
304 redOffset = 16;
305 greenOffset = 8;
306 blueOffset = 0;
307 numRedBits = 8;
308 numGreenBits = 8;
309 numBlueBits = 8;
310 }
311
319 bool is16bitBGR() const
320 {
321 return bitsPerPixel == 16 &&
322 redOffset == 10 && greenOffset == 5 && blueOffset == 0 && numRedBits == 5 && numGreenBits == 5 && numBlueBits == 5;
323 }
324
332 {
333 bitsPerPixel = 16;
334 redOffset = 10;
335 greenOffset = 5;
336 blueOffset = 0;
337 numRedBits = 5;
338 numGreenBits = 5;
339 numBlueBits = 5;
340 }
341
349 bool isRGBA() const
350 {
351 return bitsPerPixel == 32 && alphaOffset == 24 && numAlphaBits == 8 &&
352 redOffset == 0 && greenOffset == 8 && blueOffset == 16 && numRedBits == 8 && numGreenBits == 8 && numBlueBits == 8;
353 }
354
361 void setRGBA()
362 {
363 bitsPerPixel = 32;
364 alphaOffset = 24;
365 numAlphaBits = 8;
366 redOffset = 0;
367 greenOffset = 8;
368 blueOffset = 16;
369 numRedBits = 8;
370 numGreenBits = 8;
371 numBlueBits = 8;
372 }
373
381 bool isBGRA() const
382 {
383 return bitsPerPixel == 32 && alphaOffset == 24 && numAlphaBits == 8 &&
384 redOffset == 16 && greenOffset == 8 && blueOffset == 0 && numRedBits == 8 && numGreenBits == 8 && numBlueBits == 8;
385 }
386
393 void setBGRA()
394 {
395 bitsPerPixel = 32;
396 alphaOffset = 24;
397 numAlphaBits = 8;
398 redOffset = 16;
399 greenOffset = 8;
400 blueOffset = 0;
401 numRedBits = 8;
402 numGreenBits = 8;
403 numBlueBits = 8;
404 }
405 } PixelFormatInfo; // Represents data for pixel formatting.
406
414 virtual OdUInt32 pixelWidth() const = 0;
415
423 virtual OdUInt32 pixelHeight() const = 0;
424
438 virtual Units defaultResolution(double& xPelsPerUnit, double& yPelsPerUnit) const;
439
447 virtual OdUInt32 colorDepth() const = 0;
448
455 virtual OdUInt32 numColors() const = 0;
456
466 virtual int transparentColor() const;
467
477 virtual ODCOLORREF color(OdUInt32 colorIndex) const = 0;
478
486 virtual OdUInt32 paletteDataSize() const = 0;
487
496 virtual void paletteData(OdUInt8* bytes) const = 0;
497
506 virtual OdUInt32 scanLineSize() const;
507
521 virtual const OdUInt8* scanLines() const = 0;
522
540 virtual void scanLines(OdUInt8* scnLines, OdUInt32 firstScanline, OdUInt32 numLines = 1) const = 0;
541
552 virtual PixelFormatInfo pixelFormat() const = 0;
553
562 virtual OdUInt32 scanLinesAlignment() const = 0;
563
570 virtual ImageSource imageSource() const;
571
577 virtual const OdString &sourceFileName() const;
578
587
598
608
618
629 static OdUInt32 calcBMPScanLineSize(OdUInt32 pixelWidth, int colorDepth);
630
640 static OdUInt32 calcColorMask(OdUInt8 numColorBits, OdUInt8 colorOffset = 0);
641
659 OdSmartPtr<OdGiRasterImage> convert(bool convertPaletteToRGB,
660 double brightness = 50.0, double contrast = 50.0, double fade = 0.0, ODCOLORREF backgroundColor = 0,
661 bool flipX = false, bool flipY = false, bool rotate90 = false,
662 const OdGiRasterImage* pDestDesc = 0,
663 bool transparency = false) const;
664
681
689 virtual void *imp() const;
690};
691
697
708{
709public:
710 //DOM-IGNORE-BEGIN
712 //DOM-IGNORE-END
713
718 {
720 kImageSource = (1 << 0),
722 kTransparencyMode = (1 << 1),
724 kSourceFileName = (1 << 2)
725 };
726
734 virtual OdUInt32 supportedParams() const = 0;
735
742
748 virtual void setSourceFileName(const OdString &fileName) { }
749
756};
757
763
764#include "TD_PackPop.h"
765
766#endif //#ifndef _OD_ODGIRASTERIMAGE_H_
#define ODA_ASSERT_ONCE(exp)
Definition: DebugStuff.h:73
OdSmartPtr< OdGiRasterImage > OdGiRasterImagePtr
OdSmartPtr< OdGiRasterImageParam > OdGiRasterImageParamPtr
bool operator==(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:397
#define ODCOLORREF
Definition: OdPlatform.h:933
unsigned int OdUInt32
unsigned char OdUInt8
wchar_t OdChar
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
OdSmartPtr< OdGiRasterImage > changeImageSource(ImageSource source, const OdChar *pFileName=NULL)
OdSmartPtr< OdGiRasterImage > changeSourceFileName(const OdString &fileName)
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
ODRX_DECLARE_MEMBERS(OdGiRasterImage)
virtual const OdUInt8 * scanLines() const =0
virtual OdUInt32 paletteDataSize() const =0
virtual void paletteData(OdUInt8 *bytes) const =0
virtual void scanLines(OdUInt8 *scnLines, OdUInt32 firstScanline, OdUInt32 numLines=1) const =0
static double millimetersInUnit(Units units)
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 OdUInt32 colorDepth() const =0
static OdUInt32 calcColorMask(OdUInt8 numColorBits, OdUInt8 colorOffset=0)
virtual ImageSource imageSource() const
OdSmartPtr< OdGiRasterImage > changeTransparencyMode(TransparencyMode mode)
virtual OdUInt32 numColors() const =0
virtual void * imp() const
virtual OdUInt32 pixelWidth() const =0
virtual OdSmartPtr< OdGiRasterImage > crop(OdUInt32 x, OdUInt32 y, OdUInt32 width, OdUInt32 height) const
virtual int transparentColor() const
virtual const OdString & sourceFileName() 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