Das ist mein Code bisher, ich bin ziemlich nutzlos und kann nicht viel Hilfe im Web finden. Ich schaue, um die Pixel des Wertes 0xff7a2080 aus dem Bild zu zählen und dann den Betrag in Haupt anzuzeigen, bevor Sie es als einen bestimmten Dateinamen speichern. Jede Hilfe würde sehr geschätzt werden.Wie man die Pixel in einem Bild mit Qimage zählt
unsigned TotalPixels (int width, int height)
{
int pixelcount;
int QImage:: width (QCoreApplication) const;
int QImage:: height (QCoreApplication) const;
{
pixelcount = width * height;
}
return pixelcount;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
const char LogoFile[] = "RGUMoodleLogo.png";
unsigned PixelGrid[WIDTH][HEIGHT]; // Image loaded from file
// If the file cannot be loaded ...
if (!loadImage(PixelGrid, LogoFile))
{
// Display an error message
cout << "Error loading file \"" << LogoFile << "\"" << endl;
}
else
{
cout << "File \"" << LogoFile << "\" opened successfully" << endl;
if (saveImage(PixelGrid, "RGUMoodleLogoCopy.png"))
{
cout << "File \"RGUMoodleLogoCopy.png\" saved successfully" << endl;
}
else
{
cout << "Could not save \"RGUMoodleLogoCopy.png\"" << endl;
}
}
return a.exec();
}
Wo genau Sie QImage verwenden? – alex
Ich bin mir nicht sicher, wie QImage im Moment verwendet wird. Gibt es eine einfachere Möglichkeit, Pixel zu zählen, ohne diese Funktion zu verwenden? – Owenb11
Sie möchten also die Anzahl der Pixel in PixelGrid zählen, die den Wert 0xff7a2080 haben? – alex