Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: grahamboree/cppimage
base: 58d4661287
...
head fork: grahamboree/cppimage
compare: fe449cceb9
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 21 additions and 2 deletions.
  1. +20 −2 Source/cppimage/CxDefines.h
  2. +1 −0  cppimage_tests/TestCxDefines.h
View
22 Source/cppimage/CxDefines.h
@@ -175,7 +175,7 @@ namespace CppImage
#ifdef CPPIMAGE_TESTING
# define MACRO_GetRValue(rgb) ((uint8_t)(rgb))
# define MACRO_GetGValue(rgb) ((uint8_t)(((uint16_t)(rgb)) >> 8))
-# define MACRO_GetBValue(rgb) ((uint8_t)(((uint16_t)(rgb)) >> 16))
+# define MACRO_GetBValue(rgb) ((uint8_t)((rgb) >> 16))
# define MACRO_RGB(r,g,b) ((COLORREF)(((uint8_t)(r) | ((uint16_t)((uint8_t)(g)) << 8)) | (((uint32_t)(uint8_t)(b)) << 16)))
@@ -203,6 +203,8 @@ namespace CppImage
inline operator uint16_t() { return static_cast<uint16_t>(mValue); }
inline operator uint32_t() { return mValue; }
inline bool operator==(const COLORREF& color) { return color.mValue == mValue; }
+ inline uint32_t operator >>(int inShift) const { return mValue >> inShift; }
+ inline uint32_t operator <<(int inShift) const { return mValue << inShift; }
private:
uint32_t mValue;
};
@@ -233,7 +235,22 @@ namespace CppImage
{
return (b * 117 + g * 601 + r * 306) >> 10;
}
-
+
+#if 1
+ class Complex
+ {
+ public:
+ inline Complex(double inX, double inY) : mX(inX), mY(inY) {}
+ inline double Abs() const { return sqrt(mX * mX + mY * mY); }
+ private:
+ double mX;
+ double mY;
+ };
+
+ // Compatibility...
+ typedef Complex _complex;
+ static inline double _cabs(const _complex& c) { return c.Abs(); }
+#else
struct _complex
{
double x;
@@ -244,6 +261,7 @@ namespace CppImage
# define MACRO__cabs(c) sqrt(c.x*c.x+c.y*c.y)
#endif
static inline double _cabs(const _complex& c) { return sqrt(c.x * c.x + c.y * c.y); }
+#endif
}
using namespace CppImage;
View
1  cppimage_tests/TestCxDefines.h
@@ -39,6 +39,7 @@ inline void TestCxDefines::testRGB()
TEST_ASSERT(GetRValue(red) == 255);
TEST_ASSERT(GetGValue(green) == 255);
TEST_ASSERT(GetBValue(blue) == 255);
+ std::cout << "blue = " << (unsigned short)(MACRO_GetBValue(blue)) << std::endl;
COLORREF someColor = RGB(1,2,3);
TEST_ASSERT(GetRValue(someColor) == MACRO_GetRValue(someColor));

No commit comments for this range

Something went wrong with that request. Please try again.