/* ----------------------------------------------------------------------------- GSFramework Copyright 2001-2013 Emmanuel Julien. All Rights Reserved. ----------------------------------------------------------------------------- */ #include "picture/pict.h" #include "math/nmath.h" using namespace GS; //------------------------------------------------------------------------------ void Picture::DrawPlot(float x, float y, float r, float g, float b, float a, const Rect *clip_rect) { // Output validity. if (!data || (pxformat.GetBpp() != 32) || pxformat.IsReal()) return; // Clip primitive. if (clip_rect && ((x < clip_rect->sx) || (x >= clip_rect->ex) || (y < clip_rect->sy) || (y >= clip_rect->ey))) return; // Draw. AlphaCompositePixel(GetDataOffset((uint)x, (uint)y), uchar(r * 255.f), uchar(g * 255.f), uchar(b * 255.f), uchar(a * 255.f)); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void Picture::DrawPlotHQ(float x, float y, float r, float g, float b, float a, const Rect *clip_rect) { // Output validity. if (!data || (pxformat.GetBpp() != 32) || pxformat.IsReal()) return; // Clip primitive. if (clip_rect && ((x < clip_rect->sx) || (x >= (clip_rect->ex - 1)) || (y < clip_rect->sy) || (y >= (clip_rect->ey - 1)))) return; // Draw. uchar ir = uchar(r * 255.f), ig = uchar(g * 255.f), ib = uchar(b * 255.f), ia = uchar(a * 255.f); float xm = Math::Floor(x), ym = Math::Floor(y); float a0 = (xm + 1 - x) * (ym + 1 - y), a1 = (x - xm) * (ym + 1 - y), a2 = (xm + 1 - x) * (y - ym), a3 = (x - xm) * (y - ym); uchar *output = GetDataOffset((uint)x, (uint)y); AlphaCompositePixel(output, ir, ig, ib, uchar(ia * a0)); AlphaCompositePixel(output + 4, ir, ig, ib, uchar(ia * a1)); AlphaCompositePixel(output + width * 4, ir, ig, ib, uchar(ia * a2)); AlphaCompositePixel(output + (width + 1) * 4, ir, ig, ib, uchar(ia * a3)); } //------------------------------------------------------------------------------