! \internal Allocates the internal alpha map with the current data map key/value size and, if \a initializeOpaque is true, initializes all values to 255. If \a initializeOpaque is false, the values are not initialized at all. In this case, the alpha map should be initialized manually, e.g. with \ref fillAlpha. If an alpha map exists already, it is deleted first. If this color map is em
| 26289 | true if the data map isn't empty and an alpha map was successfully allocated. |
| 26290 | */ |
| 26291 | bool QCPColorMapData::createAlpha(bool initializeOpaque) |
| 26292 | { |
| 26293 | clearAlpha(); |
| 26294 | if (isEmpty()) |
| 26295 | return false; |
| 26296 | |
| 26297 | #ifdef __EXCEPTIONS |
| 26298 | try { // 2D arrays get memory intensive fast. So if the allocation fails, at least output debug message |
| 26299 | #endif |
| 26300 | mAlpha = new unsigned char[size_t(mKeySize*mValueSize)]; |
| 26301 | #ifdef __EXCEPTIONS |
| 26302 | } catch (...) { mAlpha = nullptr; } |
| 26303 | #endif |
| 26304 | if (mAlpha) |
| 26305 | { |
| 26306 | if (initializeOpaque) |
| 26307 | fillAlpha(255); |
| 26308 | return true; |
| 26309 | } else |
| 26310 | { |
| 26311 | qDebug() << Q_FUNC_INFO << "out of memory for data dimensions "<< mKeySize << "*" << mValueSize; |
| 26312 | return false; |
| 26313 | } |
| 26314 | } |
| 26315 | |
| 26316 | |
| 26317 | //////////////////////////////////////////////////////////////////////////////////////////////////// |