App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

THistogram.cpp
Go to the documentation of this file.
1
6 #include "THistogram.hpp"
7
8 namespace app {
9
10 template class THistogram<px_4x8bit, px_1x8bit>;
11 template class THistogram<px_1x8bit, px_1x8bit>;
12
13 template <typename TPIXEL, typename TCHANNEL>
14 THistogram<TPIXEL, TCHANNEL>::~THistogram() {
15 int i = 0;
16 while (i < 5) {
17 if (data[i] != NULL) {
18 free(data[i]);
19 }
20 i++;
21 }
22 }
23
24 template <typename TPIXEL, typename TCHANNEL>
25 int THistogram<TPIXEL, TCHANNEL>::calculate_4ch(const TBitmap<TPIXEL, TCHANNEL> &bitmap) {
26 if (chCount != 4) { return 1; }
27 int i = 0;
28 while (i < 5) {
29 if (data[i] == NULL) { return 2; }
30 memset(data[i], 0, (unsigned long int)(valsCount * sizeof(unsigned))); // ANDROID_SPECIFIC přetypování v malloc
31 i++;
32 }
33 TCHANNEL * ptr0 = (TCHANNEL *) bitmap.getData();
34 if (ptr0 == NULL) { return 3; }
35 TCHANNEL * ptr1 = ptr0 + 1;
36 TCHANNEL * ptr2 = ptr1 + 1;
37 TCHANNEL * ptr3 = ptr2 + 1;
38 TCHANNEL * ptr0End = (TCHANNEL *) (bitmap.getData() + bitmap.getWidth() * bitmap.getHeight());
39 while (ptr0 < ptr0End) {
40 data[0][(*ptr0 + *ptr1 + *ptr2) / (3 * factor)]++;
41 data[1][*ptr0 / factor]++; ptr0 += 4;
42 data[2][*ptr1 / factor]++; ptr1 += 4;
43 data[3][*ptr2 / factor]++; ptr2 += 4;
44 data[4][*ptr3 / factor]++; ptr3 += 4;
45 }
46 return 0;
47 }
48
49 template <typename TPIXEL, typename TCHANNEL>
50 int THistogram<TPIXEL, TCHANNEL>::calculate_1ch(const TBitmap<TPIXEL, TCHANNEL> &bitmap) {
51 if (chCount != 1) { return 1; }
52 if (data[0] == NULL) { return 2; }
53 memset(data[0], 0, (unsigned long int)(valsCount * sizeof(unsigned))); // ANDROID_SPECIFIC přetypování v malloc
54 TCHANNEL * ptr0 = (TCHANNEL *) bitmap.getData();
55 if (ptr0 == NULL) { return 3; }
56 TCHANNEL * ptr0End = (TCHANNEL *) (bitmap.getData() + bitmap.getWidth() * bitmap.getHeight());
57 while (ptr0 < ptr0End) {
58 data[0][*ptr0 / factor]++; ptr0++;
59 }
60 return 0;
61 }
62
63
64 } /* namespace app */