initial port for Cevo game in C++ (libs)
This commit is contained in:
commit
8436242032
375 files changed
+46282
No files matched your search
@@ -0,0 +1,75 @@
|
||||
#include "Dpi/DpiPixelPointer.h"
|
||||
|
||||
namespace Dpi {
|
||||
|
||||
PixelPointer::PixelPointer(QImage *image, int baseX, int baseY)
|
||||
: m_image(image)
|
||||
{
|
||||
if (m_image) {
|
||||
m_width = m_image->width();
|
||||
m_height = m_image->height();
|
||||
}
|
||||
setXY(baseX, baseY);
|
||||
}
|
||||
|
||||
void PixelPointer::setXY(int x, int y)
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
}
|
||||
|
||||
void PixelPointer::setX(int x)
|
||||
{
|
||||
m_x = x;
|
||||
}
|
||||
|
||||
void PixelPointer::nextPixel()
|
||||
{
|
||||
++m_x;
|
||||
}
|
||||
|
||||
void PixelPointer::previousPixel()
|
||||
{
|
||||
--m_x;
|
||||
}
|
||||
|
||||
void PixelPointer::nextLine()
|
||||
{
|
||||
++m_y;
|
||||
}
|
||||
|
||||
void PixelPointer::previousLine()
|
||||
{
|
||||
--m_y;
|
||||
}
|
||||
|
||||
bool PixelPointer::posValid() const
|
||||
{
|
||||
return m_image && m_x >= 0 && m_x < m_width && m_y >= 0 && m_y < m_height;
|
||||
}
|
||||
|
||||
QRgb PixelPointer::pixelARGB() const
|
||||
{
|
||||
if (!posValid())
|
||||
return 0;
|
||||
return reinterpret_cast<const QRgb *>(m_image->constScanLine(m_y))[m_x];
|
||||
}
|
||||
|
||||
void PixelPointer::setPixelARGB(QRgb value)
|
||||
{
|
||||
if (!posValid())
|
||||
return;
|
||||
reinterpret_cast<QRgb *>(m_image->scanLine(m_y))[m_x] = value;
|
||||
}
|
||||
|
||||
QRgb PixelPointer::pixelRGB() const
|
||||
{
|
||||
return pixelARGB() | 0xFF000000;
|
||||
}
|
||||
|
||||
void PixelPointer::setPixelRGB(QRgb value)
|
||||
{
|
||||
setPixelARGB(value | 0xFF000000);
|
||||
}
|
||||
|
||||
} // namespace Dpi
|
||||
Reference in new issue
Block a user