Files
c-evo-evo/widget/include/Dpi/DpiPixelPointer.h
T

41 lines
1001 B
C++

#pragma once
#include <QImage>
namespace Dpi {
// Mirrors Dpi.PixelPointer.pas / NativePixelPointer.pas: a cursor for fast
// pixel-by-pixel iteration over a 32-bit ARGB QImage, addressing native
// (physical) pixels directly. The image must use QImage::Format_ARGB32 (or
// Format_ARGB32_Premultiplied) for the scanline arithmetic below to be valid.
class PixelPointer {
public:
PixelPointer() = default;
PixelPointer(QImage *image, int baseX, int baseY);
void setXY(int x, int y);
void setX(int x);
void nextPixel();
void previousPixel();
void nextLine();
void previousLine();
bool posValid() const;
QRgb pixelARGB() const;
void setPixelARGB(QRgb value);
QRgb pixelRGB() const; // alpha forced to 0xFF
void setPixelRGB(QRgb value);
int x() const { return m_x; }
int y() const { return m_y; }
private:
QImage *m_image = nullptr;
int m_x = 0;
int m_y = 0;
int m_width = 0;
int m_height = 0;
};
} // namespace Dpi