ImageBase.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   This is a class for holding and handling basic image data             *
00004  *                                                                         *
00005  *   Author:    Graeme van der Vlugt                                       *
00006  *   Copyright: Imetric 3D GmbH                                            *
00007  *   Year:      2004                                                       *
00008  *                                                                         *
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU Library General Public License as       *
00012  *   published by the Free Software Foundation; either version 2 of the    *
00013  *   License, or (at your option) any later version.                       *
00014  *   for detail see the LICENCE text file.                                 *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef IMAGEBASE_H
00019 #define IMAGEBASE_H
00020 
00021 namespace Image
00022 {
00023 
00024 #define IB_CF_GREY8     1       // 8-bit grey level images
00025 #define IB_CF_GREY16    2               // 16-bit grey level images
00026 #define IB_CF_GREY32    3               // 32-bit grey level images
00027 #define IB_CF_RGB24     4               // 24-bit (8,8,8) RGB color images
00028 #define IB_CF_RGB48     5               // 48-bit (16,16,16) RGB color images
00029 #define IB_CF_BGR24     6               // 24-bit (8,8,8) BGR color images
00030 #define IB_CF_BGR48     7               // 48-bit (16,16,16) BGR color images
00031 #define IB_CF_RGBA32    8               // 32-bit (8,8,8,8) RGBA color images (A = alpha)
00032 #define IB_CF_RGBA64    9               // 64-bit (16,16,16,16) RGBA color images (A = alpha)
00033 #define IB_CF_BGRA32    10              // 32-bit (8,8,8,8) BGRA color images (A = alpha)
00034 #define IB_CF_BGRA64    11              // 64-bit (16,16,16,16) BGRA color images (A = alpha)
00035 
00036 class ImageExport ImageBase
00037 {
00038 public:
00039 
00040     ImageBase();
00041     virtual ~ImageBase();
00042     ImageBase(const ImageBase &rhs);
00043     ImageBase & operator=(const ImageBase &rhs);
00044 
00045     bool hasValidData() const { return (_pPixelData != 0); }
00046     void* getPixelDataPtr() { return (void *)_pPixelData; }
00047     bool isOwner() const { return _owner; }
00048     unsigned long getWidth() const { return _width; }
00049     unsigned long getHeight() const { return _height; }
00050     int getFormat() const { return _format; }
00051     unsigned short getNumSigBitsPerSample() const { return _numSigBitsPerSample; }
00052     unsigned short getNumSamples() const { return _numSamples; }
00053     unsigned short getNumBitsPerSample() const { return _numBitsPerSample; }
00054     unsigned short getNumBytesPerPixel() const { return _numBytesPerPixel; }
00055     
00056     virtual void clear();
00057     virtual int createCopy(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample);
00058     virtual int pointTo(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, bool takeOwnership);
00059 
00060     virtual int getSample(int x, int y, unsigned short sampleIndex, double &value);
00061 
00062 protected:
00063 
00064     int _setColorFormat(int format, unsigned short numSigBitsPerSample);
00065     int _allocate();
00066 
00067     unsigned char* _pPixelData;                 // pointer to the pixel data
00068     bool _owner;                                                // flag defining if the object owns the pixel data or not
00069     unsigned long _width;                               // width of image (number of pixels in horizontal direction)
00070     unsigned long _height;                              // height of image (number of pixels in vertical direction)
00071     int _format;                                        // colour format of the pixel data
00072     unsigned short _numSigBitsPerSample;// number of significant bits per sample (always <= _numBitsPerSample)
00073 
00074     // Dependant parameters
00075     unsigned short _numSamples;             // number of samples per pixel (e.g. 1 for grey, 3 for rgb, 4 for rgba)
00076     unsigned short _numBitsPerSample;   // number of bits per sample (e.g. 8 for Grey8)
00077     unsigned short _numBytesPerPixel;   // number of bytes per pixel (e.g. 1 for Grey8)
00078 };
00079 
00080 } // namespace ImageApp
00081 
00082 #endif // IMAGEBASE_H

Generated on Wed Nov 23 19:00:18 2011 for FreeCAD by  doxygen 1.6.1