Everything related to SDK.
#387223
I'm trying read RenderPreviewBuffer from existing mxi file, but I get incorrect image
First image is a real render preview,
second image what i get
Image
Image
Used files
Can anyone help? What I doing wrong?
Code: Select all
CmaxwellMxi mxi;
    mxi.read("D:/test.mxi");
    dword xRes, yRes;
    dword xPrevRes = xRes, yPrevRes = yRes;
    mxi.getPreviewResolution(xRes, yRes, xPrevRes, yPrevRes);
    mxi.updateDisplay();
    mxi.updatePreview();

    Crgb8 *pRgb8 = mxi.getRenderPreviewBuffer();;

    QImage image(xPrevRes, yPrevRes, QImage::Format_RGB888);
    for(int y = 0; y < yPrevRes; y++)
    {
        for(int x = 0; x < xPrevRes; x++)
        {
            Crgb pRgb;
            pRgb8->toRGB(pRgb);

            QColor color;
            color.setRgbF(pRgb.r, pRgb.g, pRgb.b);

            image.setPixel(x,y, color.rgb());

            pRgb8++;
        }
    }
    m_graphicsScene->addPixmap(QPixmap::fromImage(image));
    image.save("D:/test.png", "PNG");
#387225
Hi,

The beginning of your code is not correct. Is not importat to your problem but it can be confusing for other users ;)
Code: Select all
dword xRes, yRes;
dword xPrevRes = xRes, yPrevRes = yRes;
mxi.getPreviewResolution(xRes, yRes, xPrevRes, yPrevRes);
should be something like
Code: Select all
dword xRes = mxi.xRes(), yRes = mxi.yRes();
dword xPrevRes, yPrevRes;
mxi.getPreviewResolution(xRes, yRes, xPrevRes, yPrevRes);

Regarding the blue image, it seems that it is a RGB/BGR issue, try this
Code: Select all
color.setRgbF(pRgb.b, pRgb.g, pRgb.r);

...and 3 Days later, 82.528 Views !!! ...NL, every[…]

Hello dear customers, We have just released a new[…]

grass generator extension

Just downloaded MWR5 for Rhino 6 and want to use g[…]

Hello everyone, I have a new bug with the latest M[…]