MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / drawColorImage

Function drawColorImage

Samples/NiViewer/Draw.cpp:766–895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

764}
765
766void drawColorImage(IntRect* pLocation, IntPair* pPointer, int pointerRed, int pointerGreen, int pointerBlue)
767{
768 if (g_DrawConfig.Streams.bBackground)
769 TextureMapDraw(&g_texBackground, pLocation);
770
771 if (g_DrawConfig.Streams.Image.Coloring == IMAGE_OFF)
772 return;
773
774 if (!isImageOn() && !isIROn())
775 {
776 drawClosedStream(pLocation, "Image");
777 return;
778 }
779
780 const MapMetaData* pImageMD;
781 const XnUInt8* pImage = NULL;
782
783 if (isImageOn())
784 {
785 pImageMD = getImageMetaData();
786 pImage = getImageMetaData()->Data();
787 }
788 else if (isIROn())
789 {
790 pImageMD = getIRMetaData();
791 pImage = (const XnUInt8*)getIRMetaData()->Data();
792 }
793 else
794 return;
795
796 if (pImageMD->FrameID() == 0)
797 {
798 return;
799 }
800
801 const DepthMetaData* pDepthMetaData = getDepthMetaData();
802
803 double grayscale16Factor = 1.0;
804 if (pImageMD->PixelFormat() == XN_PIXEL_FORMAT_GRAYSCALE_16_BIT)
805 {
806 int nPixelsCount = pImageMD->XRes()*pImageMD->YRes();
807 XnUInt16* pPixel = (XnUInt16*)pImage;
808 for (int i = 0; i < nPixelsCount; ++i,++pPixel)
809 {
810 if (*pPixel > g_nMaxGrayscale16Value)
811 g_nMaxGrayscale16Value = *pPixel;
812 }
813
814 if (g_nMaxGrayscale16Value > 0)
815 {
816 grayscale16Factor = 255.0 / g_nMaxGrayscale16Value;
817 }
818 }
819
820 for (XnUInt16 nY = pImageMD->YOffset(); nY < pImageMD->YRes() + pImageMD->YOffset(); nY++)
821 {
822 XnUInt8* pTexture = TextureMapGetLine(&g_texImage, nY) + pImageMD->XOffset()*4;
823

Callers 1

drawFrameFunction · 0.85

Calls 15

TextureMapDrawFunction · 0.85
isImageOnFunction · 0.85
isIROnFunction · 0.85
drawClosedStreamFunction · 0.85
getImageMetaDataFunction · 0.85
getIRMetaDataFunction · 0.85
getDepthMetaDataFunction · 0.85
TextureMapGetLineFunction · 0.85
YUV422ToRGB888Function · 0.85
TextureMapDrawCursorFunction · 0.85
TextureMapUpdateFunction · 0.85
FrameIDMethod · 0.80

Tested by

no test coverage detected