예제 #1
0
void	oImgBitmap::setContents(EXTfldval &pContents) {
	if (mImage == NULL) {
		// really?
	} else {
		// We get the binary as is, we assume the contents is raw picture data in any format supported by STB
		qlong bitmapLen = pContents.getBinLen();
		if (bitmapLen > 0) {
			qbyte * bitmapData = (qbyte *)MEMmalloc(sizeof(qbyte) * (bitmapLen+1));
			if (bitmapData != NULL) {
				qlong	reallen;
				pContents.getBinary(bitmapLen, bitmapData, reallen);

				// and assign it to our image
				mImage->copy(bitmapData, reallen);

				// and free our memory
				MEMfree(bitmapData);
			} else {
				oBaseComponent::addToTraceLog("setContents: Couldn't allocate memory for pixel buffer");
			};
		} else {
			oBaseComponent::addToTraceLog("setContents: No image specified");
		};
	};
};
예제 #2
0
// Return a C++ std::vector of unsigned char from an EXTfldval
std::vector<unsigned char> OmnisTools::getBinaryVectorFromEXTFldVal(EXTfldval& fVal) {
    std::vector<unsigned char> v;
    qlong realLength, bufferSize;
    
    bufferSize = fVal.getBinLen();
    v.resize(bufferSize);
    
    fVal.getBinary(v.size(), &v[0], realLength);
    
    return v;
}