Last active
February 6, 2018 14:39
-
-
Save przemoc/2991958 to your computer and use it in GitHub Desktop.
How to check whether alpha channel is used in ARGB32 QImage - http://stackoverflow.com/q/6157286/241521
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
// Copyright (C) 2011 Przemyslaw Pawelczyk <przemoc@gmail.com> | |
// | |
// This script is licensed under the terms of the MIT license. | |
// https://opensource.org/licenses/MIT | |
bool useAlpha = false; | |
const uchar* pixelData = image.bits(); | |
int bytes = image.byteCount(); | |
for (const QRgb* pixel = reinterpret_cast<const QRgb*>(pixelData); bytes > 0; pixel++, bytes -= sizeof(QRgb)) { | |
if (qAlpha(*pixel) != UCHAR_MAX) { | |
useAlpha = true; | |
break; | |
} | |
} |
Author
przemoc
commented
Feb 6, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment