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

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

1/ Ajout table de couleur RGB32768 , et corrections/optimisation ds picmap.cc
2/ Ajout type LUT Exp (inverse de log) et correction/optimisation ds lut.cc
3/ Codage de lecture/ecriture sur fichier de PIPixRGBArray (pipixutils.cc)
4/ Correction et adaptation ds piimage.cc , picmapview.cc ...

Reza 17 Novembre 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 int SaveToFile(const char * filename);
73 int ReadFrFile(const char * filename);
74
75protected:
76 PIPixRGB * rgbpix_;
77 int sx_, sy_;
78};
79
80
81#endif /* PIPIXUTILS_H_SEEN */
82
83
Note: See TracBrowser for help on using the repository browser.