Exemplo n.º 1
0
void Image::BitmapData::setPixelColour (const int x, const int y, const Colour& colour) const noexcept
{
    jassert (isPositiveAndBelow (x, width) && isPositiveAndBelow (y, height));

    uint8* const pixel = getPixelPointer (x, y);
    const PixelARGB col (colour.getPixelARGB());

    switch (pixelFormat)
    {
        case Image::ARGB:           ((PixelARGB*)  pixel)->set (col); break;
        case Image::RGB:            ((PixelRGB*)   pixel)->set (col); break;
        case Image::SingleChannel:  ((PixelAlpha*) pixel)->set (col); break;
        default:                    jassertfalse; break;
    }
}
Exemplo n.º 2
0
//==============================================================================
void Image::clear (const Rectangle<int>& area, const Colour& colourToClearTo)
{
    const Rectangle<int> clipped (area.getIntersection (getBounds()));

    if (! clipped.isEmpty())
    {
        const PixelARGB col (colourToClearTo.getPixelARGB());

        const BitmapData destData (*this, clipped.getX(), clipped.getY(), clipped.getWidth(), clipped.getHeight(), BitmapData::writeOnly);
        uint8* dest = destData.data;
        int dh = clipped.getHeight();

        while (--dh >= 0)
        {
            uint8* line = dest;
            dest += destData.lineStride;

            if (isARGB())
            {
                for (int x = clipped.getWidth(); --x >= 0;)
                {
                    ((PixelARGB*) line)->set (col);
                    line += destData.pixelStride;
                }
            }
            else if (isRGB())
            {
                for (int x = clipped.getWidth(); --x >= 0;)
                {
                    ((PixelRGB*) line)->set (col);
                    line += destData.pixelStride;
                }
            }
            else
            {
                for (int x = clipped.getWidth(); --x >= 0;)
                {
                    *line = col.getAlpha();
                    line += destData.pixelStride;
                }
            }
        }
    }
}