Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void qtIPR(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t* buffer, void* data)
- {
- qDebug() << "Status:\t" << AiRenderGetStatus();
- // qDebug() << "RENDERING = " << AI_RENDER_STATUS_RENDERING;
- // qDebug() << "FINISHED = " << AI_RENDER_STATUS_FINISHED;
- // qDebug() << "FAILED = " << AI_RENDER_STATUS_FAILED;
- //uint8_t* pixel = (uint8_t*)AiMalloc(x * y * sizeof(uint8_t) * 4);
- uint8_t* pixel = buffer;
- if (AiRenderGetStatus() == 5){
- AiFree(&buffer);
- AiFree(&data);
- AiFree(&pixel);
- }
- else{
- if (buffer != nullptr)
- {
- try{
- qDebug() << "Used Memory:\t" << AiMsgUtilGetUsedMemory() / 1048576 << "MB";
- qDebug() << "X:\t" << x;
- qDebug() << "Y:\t" << y;
- qDebug() << "Width:\t" << width;
- qDebug() << "Height:\t" << height;
- qDebug() << buffer;
- qDebug() << "buffer length" << sizeof (buffer) / sizeof (u_int8_t);
- for(unsigned int i = 0; i < height; ++i) {
- for(unsigned int j = 0; j < width; ++j, pixel += 3) {
- float r = pixel[0];
- float g = pixel[1];
- float b = pixel[2];
- float a = pixel[3];
- qDebug() << "R " << r << "G " << g << "B " << b << "A " << a;
- // Do something with r, g, b
- }
- }
- //delete pixel;
- //qDebug() << "Freeing objects";
- //AiFree(&pixel);
- if (data != nullptr){
- qDebug() << "found data:";
- qDebug() << "Data:\t" << data;
- }
- }
- catch(...){
- qDebug() << "Freeing objects";
- AiFree(&buffer);
- AiFree(&data);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement