~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Mod/Image/App/ImageBase.h

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *                                                                         *
 
3
 *   This is a class for holding and handling basic image data             *
 
4
 *                                                                         *
 
5
 *   Author:    Graeme van der Vlugt                                       *
 
6
 *   Copyright: Imetric 3D GmbH                                            *
 
7
 *   Year:      2004                                                       *
 
8
 *                                                                         *
 
9
 *                                                                         *
 
10
 *   This program is free software; you can redistribute it and/or modify  *
 
11
 *   it under the terms of the GNU Library General Public License as       *
 
12
 *   published by the Free Software Foundation; either version 2 of the    *
 
13
 *   License, or (at your option) any later version.                       *
 
14
 *   for detail see the LICENCE text file.                                 *
 
15
 *                                                                         *
 
16
 ***************************************************************************/
 
17
 
 
18
#ifndef IMAGEBASE_H
 
19
#define IMAGEBASE_H
 
20
 
 
21
namespace Image
 
22
{
 
23
 
 
24
#define IB_CF_GREY8     1       // 8-bit grey level images
 
25
#define IB_CF_GREY16    2               // 16-bit grey level images
 
26
#define IB_CF_GREY32    3               // 32-bit grey level images
 
27
#define IB_CF_RGB24     4               // 24-bit (8,8,8) RGB color images
 
28
#define IB_CF_RGB48     5               // 48-bit (16,16,16) RGB color images
 
29
#define IB_CF_BGR24     6               // 24-bit (8,8,8) BGR color images
 
30
#define IB_CF_BGR48     7               // 48-bit (16,16,16) BGR color images
 
31
#define IB_CF_RGBA32    8               // 32-bit (8,8,8,8) RGBA color images (A = alpha)
 
32
#define IB_CF_RGBA64    9               // 64-bit (16,16,16,16) RGBA color images (A = alpha)
 
33
#define IB_CF_BGRA32    10              // 32-bit (8,8,8,8) BGRA color images (A = alpha)
 
34
#define IB_CF_BGRA64    11              // 64-bit (16,16,16,16) BGRA color images (A = alpha)
 
35
 
 
36
class ImageAppExport ImageBase
 
37
{
 
38
public:
 
39
 
 
40
    ImageBase();
 
41
    virtual ~ImageBase();
 
42
    ImageBase(const ImageBase &rhs);
 
43
    ImageBase & operator=(const ImageBase &rhs);
 
44
 
 
45
    bool hasValidData() const { return (_pPixelData != 0); }
 
46
    void* getPixelDataPtr() { return (void *)_pPixelData; }
 
47
    bool isOwner() const { return _owner; }
 
48
    unsigned long getWidth() const { return _width; }
 
49
    unsigned long getHeight() const { return _height; }
 
50
    int getFormat() const { return _format; }
 
51
    unsigned short getNumSigBitsPerSample() const { return _numSigBitsPerSample; }
 
52
    unsigned short getNumSamples() const { return _numSamples; }
 
53
    unsigned short getNumBitsPerSample() const { return _numBitsPerSample; }
 
54
    unsigned short getNumBytesPerPixel() const { return _numBytesPerPixel; }
 
55
    
 
56
    virtual void clear();
 
57
    virtual int createCopy(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample);
 
58
    virtual int pointTo(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, bool takeOwnership);
 
59
 
 
60
    virtual int getSample(int x, int y, unsigned short sampleIndex, double &value);
 
61
 
 
62
protected:
 
63
 
 
64
    int _setColorFormat(int format, unsigned short numSigBitsPerSample);
 
65
    int _allocate();
 
66
 
 
67
    unsigned char* _pPixelData;                 // pointer to the pixel data
 
68
    bool _owner;                                                // flag defining if the object owns the pixel data or not
 
69
    unsigned long _width;                               // width of image (number of pixels in horizontal direction)
 
70
    unsigned long _height;                              // height of image (number of pixels in vertical direction)
 
71
    int _format;                                        // colour format of the pixel data
 
72
    unsigned short _numSigBitsPerSample;// number of significant bits per sample (always <= _numBitsPerSample)
 
73
 
 
74
    // Dependant parameters
 
75
    unsigned short _numSamples;             // number of samples per pixel (e.g. 1 for grey, 3 for rgb, 4 for rgba)
 
76
    unsigned short _numBitsPerSample;   // number of bits per sample (e.g. 8 for Grey8)
 
77
    unsigned short _numBytesPerPixel;   // number of bytes per pixel (e.g. 1 for Grey8)
 
78
};
 
79
 
 
80
} // namespace ImageApp
 
81
 
 
82
#endif // IMAGEBASE_H