void drawInit() { g_DepthColoring[DEPTH_OFF] = "Off"; g_DepthColoring[LINEAR_HISTOGRAM] = "Linear Histogram"; g_DepthColoring[PSYCHEDELIC] = "Psychedelic"; g_DepthColoring[PSYCHEDELIC_SHADES] = "Psychedelic (Millimeters)"; g_DepthColoring[RAINBOW] = "Rainbow"; g_DepthColoring[CYCLIC_RAINBOW] = "Cyclic Rainbow"; g_DepthColoring[CYCLIC_RAINBOW_HISTOGRAM] = "Cyclic Rainbow Histogram"; g_DepthColoring[STANDARD_DEVIATION] = "Standard Deviation"; g_ImageColoring[IMAGE_OFF] = "Off"; g_ImageColoring[IMAGE_NORMAL] = "Normal"; g_ImageColoring[DEPTH_MASKED_IMAGE] = "Depth Masked Image"; CreateRainbowPallet(); setPreset(7); TextureMapInit(&g_texBackground, 1024, 1024, 3, 1024, 1024); // load background image xnOSLoadFile("..\\..\\..\\..\\Data\\RGBViewer\\back.raw", TextureMapGetLine(&g_texBackground, 0), 1024*1024*3); TextureMapUpdate(&g_texBackground); mouseInputRegisterForSelectionRectangle(drawSelectionChanged); mouseInputRegisterForCursorMovement(drawCursorMoved); }
//--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- XnStatus FindEntry(const XnChar* cpINIFile, const XnChar* cpSection, const XnChar* cpKey, XnChar* cpDest) { XnStatus nRetVal = XN_STATUS_OK; // get file size XnUInt32 nFileSize; nRetVal = xnOSGetFileSize(cpINIFile, &nFileSize); XN_IS_STATUS_OK(nRetVal); // read entire file to memory XnChar* csFileData = (XnChar*)xnOSMalloc(sizeof(XnChar)*nFileSize + 1); XN_VALIDATE_ALLOC_PTR(csFileData); nRetVal = xnOSLoadFile(cpINIFile, csFileData, nFileSize); if (nRetVal != XN_STATUS_OK) { xnOSFree(csFileData); return nRetVal; } // place NULL at the end csFileData[nFileSize] = '\0'; // now parse file XnChar* pCurPos = csFileData; XnBool bIsInRequestedSection = FALSE; XnChar csTempString[XN_INI_MAX_LEN]; XnUInt32 nTempStringLength = 0; while (TRUE) { // ignore spaces while (*pCurPos && XN_IS_SPACE(pCurPos)) { pCurPos++; } // check we haven't reached the end if (!*pCurPos) { break; } if (*pCurPos == ';' || *pCurPos == '#') // comment { XN_SKIP_LINE(pCurPos); continue; } if (*pCurPos == '[') // start of section { pCurPos++; XN_READ_TILL(pCurPos, *pCurPos == ']' || XN_IS_NEWLINE(pCurPos), csTempString, nTempStringLength); if (*pCurPos == ']') // valid section name { if (bIsInRequestedSection) { // we're leaving the requested section, and string wasn't found xnOSFree(csFileData); return XN_STATUS_OS_INI_READ_FAILED; } if (strcmp(csTempString, cpSection) == 0) { bIsInRequestedSection = TRUE; } } // in any case, move to the next line XN_SKIP_LINE(pCurPos); continue; } // section // if we're not in the right section, we don't really care what's written in this line. Just skip it. if (!bIsInRequestedSection) { XN_SKIP_LINE(pCurPos); continue; } // regular line. check if this is a key (look for the '=' sign) XN_READ_TILL(pCurPos, *pCurPos == '=' || XN_IS_NEWLINE(pCurPos), csTempString, nTempStringLength); if (*pCurPos == '=') // we found a key { if (strcmp(csTempString, cpKey) == 0) { // we found our key. The value is the rest of the line pCurPos++; XN_READ_TILL(pCurPos, XN_IS_NEWLINE(pCurPos), cpDest, nTempStringLength); xnOSFree(csFileData); return XN_STATUS_OK; } } // if we got here, skip to the next line XN_SKIP_LINE(pCurPos); } // while loop xnOSFree(csFileData); return (XN_STATUS_OS_INI_READ_FAILED); }