Mercurial > hg > orthanc
comparison Core/Images/ImageAccessor.h @ 2487:be1dbb1dcdd6
PixelTraits and ImageTraits
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 13 Mar 2018 16:29:20 +0100 |
parents | 878b59270859 |
children | 9b4251721f22 |
comparison
equal
deleted
inserted
replaced
2486:ad8f30fc28d1 | 2487:be1dbb1dcdd6 |
---|---|
41 namespace Orthanc | 41 namespace Orthanc |
42 { | 42 { |
43 class ImageAccessor | 43 class ImageAccessor |
44 { | 44 { |
45 private: | 45 private: |
46 template <Orthanc::PixelFormat Format> | |
47 friend struct ImageTraits; | |
48 | |
46 bool readOnly_; | 49 bool readOnly_; |
47 PixelFormat format_; | 50 PixelFormat format_; |
48 unsigned int width_; | 51 unsigned int width_; |
49 unsigned int height_; | 52 unsigned int height_; |
50 unsigned int pitch_; | 53 unsigned int pitch_; |
51 uint8_t *buffer_; | 54 uint8_t *buffer_; |
55 | |
56 template <typename T> | |
57 const T& GetPixelUnchecked(unsigned int x, | |
58 unsigned int y) const | |
59 { | |
60 const uint8_t* row = reinterpret_cast<const uint8_t*>(buffer_) + y * pitch_; | |
61 return reinterpret_cast<const T*>(row) [x]; | |
62 } | |
63 | |
64 | |
65 template <typename T> | |
66 T& GetPixelUnchecked(unsigned int x, | |
67 unsigned int y) | |
68 { | |
69 uint8_t* row = reinterpret_cast<uint8_t*>(buffer_) + y * pitch_; | |
70 return reinterpret_cast<T*>(row) [x]; | |
71 } | |
52 | 72 |
53 public: | 73 public: |
54 ImageAccessor() | 74 ImageAccessor() |
55 { | 75 { |
56 AssignEmpty(PixelFormat_Grayscale8); | 76 AssignEmpty(PixelFormat_Grayscale8); |