source: Sophya/trunk/SophyaPI/PI/pipixutils.h@ 3519

Last change on this file since 3519 was 3519, checked in by ansari, 17 years ago

1/ Introduction des classes auxiliaires PIPixColIdx , PIPixRGB , PIPixRGBArray
(nouveau fichier pipixutils.cc .h) pour support de tables de couleurs avec > 256 couleurs.
2/ Ajout de tables de couleurs RGB (216/512/4096) pour representation d'image RGB
3/ Extension et modification de la classe P2DArrayAdapter, introduction de la methode P2DArrayAdapter::MeanVal()
4/ Modif de la classe LUT pour introduction typeRGB
5/ Modification et propagation ds PIImage , PIPIxmap ...

Reza , 11/09/2008

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1// This may look like C code, but it is really -*- C++ -*-
2// Classes utilitaires pour representation de pixels et couleurs RGB pour PI
3// R. Ansari 09/2008
4// LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
5
6#ifndef PIPIXUTILS_H_SEEN
7#define PIPIXUTILS_H_SEEN
8
9// ======= Classes utilitaires pour PIPixmap / PIImage =====
10//
11// Definition d'un tableau pour gerer des index de couleurs en 8 bits / 16 bits
12//
13class PIPixColIdx
14{
15public:
16 PIPixColIdx();
17 ~PIPixColIdx();
18 inline int XSize() { return sx_; }
19 inline int YSize() { return sy_; }
20
21 void AllocateByte(int sx, int sy);
22 void AllocateShort(int sx, int sy);
23 inline void DeAlloc() { AllocateByte(0,0); }
24
25 inline unsigned char GetByte(int i, int j) const
26 { return pix8[j*sx_+i]; }
27 inline unsigned char & GetByte(int i, int j)
28 { return pix8[j*sx_+i]; }
29
30 inline unsigned short GetShort(int i, int j) const
31 { return pix16[j*sx_+i]; }
32 inline unsigned short & GetShort(int i, int j)
33 { return pix16[j*sx_+i]; }
34
35 inline unsigned char* BytePointer() { return pix8; }
36 inline unsigned short* ShortPointer() { return pix16; }
37
38protected:
39 unsigned char * pix8;
40 unsigned short * pix16;
41 int sx_, sy_;
42};
43
44
45//
46// Definition de pixel et tableau de pixel RGB de 8 bits (byte)
47//
48
49// Cette structure DOIT avoir la taille d'un entier de 4 bytes
50struct PIPixRGB {
51 unsigned char red;
52 unsigned char green;
53 unsigned char blue;
54 unsigned char alpha; // non utilise pour le moment
55};
56
57class PIPixRGBArray
58{
59public:
60 PIPixRGBArray(int sx, int sy);
61 PIPixRGBArray(const char * filename);
62 ~PIPixRGBArray();
63
64 inline int XSize() { return sx_; }
65 inline int YSize() { return sy_; }
66
67 inline PIPixRGB operator()(int i, int j) const
68 { return rgbpix_[j*sx_+i]; }
69 inline PIPixRGB& operator()(int i, int j)
70 { return rgbpix_[j*sx_+i]; }
71
72 void SaveToFile(const char * filename);
73
74protected:
75 PIPixRGB * rgbpix_;
76 int sx_, sy_;
77};
78
79
80#endif /* PIPIXUTILS_H_SEEN */
81
82
Note: See TracBrowser for help on using the repository browser.