2828#include " gfx/rgb.h"
2929#include " raster/image.h"
3030#include " raster/palette.h"
31+ #include " raster/primitives.h"
3132
3233#include < cstdlib>
3334#include < iomanip>
@@ -83,23 +84,23 @@ Color Color::fromIndex(int index)
8384}
8485
8586// static
86- Color Color::fromImage (PixelFormat pixelFormat, int c)
87+ Color Color::fromImage (PixelFormat pixelFormat, color_t c)
8788{
8889 Color color = Color::fromMask ();
8990
9091 switch (pixelFormat) {
9192
9293 case IMAGE_RGB :
93- if (_rgba_geta (c) > 0 ) {
94- color = Color::fromRgb (_rgba_getr (c),
95- _rgba_getg (c),
96- _rgba_getb (c));
94+ if (rgba_geta (c) > 0 ) {
95+ color = Color::fromRgb (rgba_getr (c),
96+ rgba_getg (c),
97+ rgba_getb (c));
9798 }
9899 break ;
99100
100101 case IMAGE_GRAYSCALE :
101- if (_graya_geta (c) > 0 ) {
102- color = Color::fromGray (_graya_getv (c));
102+ if (graya_geta (c) > 0 ) {
103+ color = Color::fromGray (graya_getv (c));
103104 }
104105 break ;
105106
@@ -114,8 +115,8 @@ Color Color::fromImage(PixelFormat pixelFormat, int c)
114115// static
115116Color Color::fromImageGetPixel (Image *image, int x, int y)
116117{
117- if ((x >= 0 ) && (y >= 0 ) && (x < image->w ) && (y < image->h ))
118- return Color::fromImage (image->getPixelFormat (), image_getpixel (image, x, y));
118+ if ((x >= 0 ) && (y >= 0 ) && (x < image->getWidth ()) && (y < image->getHeight () ))
119+ return Color::fromImage (image->getPixelFormat (), raster::get_pixel (image, x, y));
119120 else
120121 return Color::fromMask ();
121122}
@@ -245,9 +246,9 @@ std::string Color::toHumanReadableString(PixelFormat pixelFormat, HumanReadableS
245246 uint32_t _c = get_current_palette ()->getEntry (i);
246247 result << " Index " << i
247248 << " (RGB "
248- << (int )_rgba_getr (_c) << " "
249- << (int )_rgba_getg (_c) << " "
250- << (int )_rgba_getb (_c) << " )" ;
249+ << (int )rgba_getr (_c) << " "
250+ << (int )rgba_getg (_c) << " "
251+ << (int )rgba_getb (_c) << " )" ;
251252 }
252253 else {
253254 result << " Index "
@@ -381,7 +382,7 @@ int Color::getRed() const
381382 int i = m_value.index ;
382383 ASSERT (i >= 0 && i < get_current_palette ()->size ());
383384
384- return _rgba_getr (get_current_palette ()->getEntry (i));
385+ return rgba_getr (get_current_palette ()->getEntry (i));
385386 }
386387
387388 }
@@ -412,7 +413,7 @@ int Color::getGreen() const
412413 int i = m_value.index ;
413414 ASSERT (i >= 0 && i < get_current_palette ()->size ());
414415
415- return _rgba_getg (get_current_palette ()->getEntry (i));
416+ return rgba_getg (get_current_palette ()->getEntry (i));
416417 }
417418
418419 }
@@ -443,7 +444,7 @@ int Color::getBlue() const
443444 int i = m_value.index ;
444445 ASSERT (i >= 0 && i < get_current_palette ()->size ());
445446
446- return _rgba_getb (get_current_palette ()->getEntry (i));
447+ return rgba_getb (get_current_palette ()->getEntry (i));
447448 }
448449
449450 }
@@ -476,9 +477,9 @@ int Color::getHue() const
476477
477478 uint32_t c = get_current_palette ()->getEntry (i);
478479
479- return Hsv (Rgb (_rgba_getr (c),
480- _rgba_getg (c),
481- _rgba_getb (c))).hueInt ();
480+ return Hsv (Rgb (rgba_getr (c),
481+ rgba_getg (c),
482+ rgba_getb (c))).hueInt ();
482483 }
483484
484485 }
@@ -511,9 +512,9 @@ int Color::getSaturation() const
511512
512513 uint32_t c = get_current_palette ()->getEntry (i);
513514
514- return Hsv (Rgb (_rgba_getr (c),
515- _rgba_getg (c),
516- _rgba_getb (c))).saturationInt ();
515+ return Hsv (Rgb (rgba_getr (c),
516+ rgba_getg (c),
517+ rgba_getb (c))).saturationInt ();
517518 }
518519
519520 }
@@ -546,9 +547,9 @@ int Color::getValue() const
546547
547548 uint32_t c = get_current_palette ()->getEntry (i);
548549
549- return Hsv (Rgb (_rgba_getr (c),
550- _rgba_getg (c),
551- _rgba_getb (c))).valueInt ();
550+ return Hsv (Rgb (rgba_getr (c),
551+ rgba_getg (c),
552+ rgba_getb (c))).valueInt ();
552553 }
553554
554555 }
@@ -581,9 +582,9 @@ int Color::getGray() const
581582
582583 uint32_t c = get_current_palette ()->getEntry (i);
583584
584- return 255 * Hsv (Rgb (_rgba_getr (c),
585- _rgba_getg (c),
586- _rgba_getb (c))).valueInt () / 100 ;
585+ return 255 * Hsv (Rgb (rgba_getr (c),
586+ rgba_getg (c),
587+ rgba_getb (c))).valueInt () / 100 ;
587588 }
588589
589590 }
0 commit comments