Software Archive
Read-only legacy content
17061 Discussions

why IamgeData has no ToBitmap for C++?

iswarmrob
Beginner
260 Views

why IamgeData has no ToBitmap for C++? I want to translate the iamge data to a picture with bitmap or jpg or png after acquireaccess. 

The following is my code:  

 sample = sm->QuerySample();
        cpic = sample->color;
        if (cpic->AcquireAccess(PXCImage::ACCESS_READ,PXCImage::PIXEL_FORMAT_RGB32, &cData)<PXC_STATUS_NO_ERROR) {
            wprintf(L"没能正常获取深度图像!\n");
            break;
        }
        
        info = cpic->QueryInfo();
        wprintf(L"图像的深度值\n");
        unsigned char * cpixels = (unsigned char *)cData.planes[0];
        int dpitches = cData.pitches[0] / sizeof(unsigned char);
        for (int y = 0; y < (int)info.height; y++) {   // R
            for (int x = 0; x < (int)info.width; x++) {
                fprintf(fpDataBmp,"%u ", cpixels[y*dpitches + x*sizeof(unsigned char)*4]);
            }
            
            fprintf(fpDataBmp,"\n");
        }
        fclose(fpDataBmp);

does the for loop get the R values for a picture?

I import these data into matlab and imshow them. but I got a very black gray picture. what mistake did I make?

Sincerely

0 Kudos
1 Reply
Xusheng_L_Intel
Employee
260 Views

There is no tech difficulty to implement this. We will consider this feature. If it’s a common request, we will implement in the future. Thanks!

0 Kudos
Reply