MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FreedesktopImage

Method FreedesktopImage

src/qt/notificator.cpp:104–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102const int BITS_PER_SAMPLE = 8;
103
104FreedesktopImage::FreedesktopImage(const QImage &img):
105 width(img.width()),
106 height(img.height()),
107 stride(img.width() * BYTES_PER_PIXEL),
108 hasAlpha(true),
109 channels(CHANNELS),
110 bitsPerSample(BITS_PER_SAMPLE)
111{
112 // Convert 00xAARRGGBB to RGBA bytewise (endian-independent) format
113 QImage tmp = img.convertToFormat(QImage::Format_ARGB32);
114 const uint32_t *data = reinterpret_cast<const uint32_t*>(tmp.bits());
115
116 unsigned int num_pixels = width * height;
117 image.resize(num_pixels * BYTES_PER_PIXEL);
118
119 for(unsigned int ptr = 0; ptr < num_pixels; ++ptr)
120 {
121 image[ptr*BYTES_PER_PIXEL+0] = data[ptr] >> 16; // R
122 image[ptr*BYTES_PER_PIXEL+1] = data[ptr] >> 8; // G
123 image[ptr*BYTES_PER_PIXEL+2] = data[ptr]; // B
124 image[ptr*BYTES_PER_PIXEL+3] = data[ptr] >> 24; // A
125 }
126}
127
128QDBusArgument &operator<<(QDBusArgument &a, const FreedesktopImage &i)
129{

Callers

nothing calls this directly

Calls 3

heightMethod · 0.80
bitsMethod · 0.80
resizeMethod · 0.45

Tested by

no test coverage detected