int main(void) { parsercontext p; //size_t size, night, density, touchscreen, keyboard, textinput, navstate, navmethod; // Core-C init phase ParserContext_Init(&p,NULL,NULL,NULL); StdAfx_Init((nodemodule*)&p); //ProjectSettings((nodecontext*)&p); OutputArrayValues(&p, T("size"), Size, sizeof(Size)/sizeof(tchar_t*)); OutputArrayValues(&p, T("night"), Night, sizeof(Night)/sizeof(tchar_t*)); OutputArrayValues(&p, T("density"), Density, sizeof(Density)/sizeof(tchar_t*)); OutputArrayValues(&p, T("touchscreen"), TouchScreen, sizeof(TouchScreen)/sizeof(tchar_t*)); OutputArrayValues(&p, T("keyboard"), Keyboard, sizeof(Keyboard)/sizeof(tchar_t*)); OutputArrayValues(&p, T("textinput"), TextInput, sizeof(TextInput)/sizeof(tchar_t*)); OutputArrayValues(&p, T("navstate"), NavigationState, sizeof(NavigationState)/sizeof(tchar_t*)); OutputArrayValues(&p, T("navmethod"), NavigationMethod, sizeof(NavigationMethod)/sizeof(tchar_t*)); OutputArrayValues(&p, T("aspect"), Aspect, sizeof(Aspect)/sizeof(tchar_t*)); OutputArrayValues(&p, T("orientation"), Orientation, sizeof(Orientation)/sizeof(tchar_t*)); OutputArrayValues(&p, T("uimode"), Mode, sizeof(Mode)/sizeof(tchar_t*)); #if 0 for (size = 0; size < sizeof(Size)/sizeof(tchar_t*); ++size) { for (night = 0; night < sizeof(Night)/sizeof(tchar_t*); ++night) { for (density = 0; density < sizeof(Density)/sizeof(tchar_t*); ++density) { for (touchscreen = 0; touchscreen < sizeof(TouchScreen)/sizeof(tchar_t*); ++touchscreen) { for (keyboard = 0; keyboard < sizeof(Keyboard)/sizeof(tchar_t*); ++keyboard) { for (textinput = 0; textinput < sizeof(TextInput)/sizeof(tchar_t*); ++textinput) { for (navstate = 0; navstate < sizeof(NavigationState)/sizeof(tchar_t*); ++navstate) { for (navmethod = 0; navmethod < sizeof(NavigationMethod)/sizeof(tchar_t*); ++navmethod) { OutputValues(&p, size, night, density, touchscreen, keyboard, textinput, navstate, navmethod); } } } } } } } } #endif // Core-C ending StdAfx_Done((nodemodule*)&p); ParserContext_Done(&p); return 0; }
static HRESULT OutputBitmapPalette(IStream *stream, UINT frameNum, IWICPalette *palette) { HRESULT result = E_INVALIDARG; if (stream && palette) { UINT colorCount = 0; WICColor *colors = NULL; result = S_OK; if (SUCCEEDED(result)) { result = palette->GetColorCount(&colorCount); } if (colorCount > 0) { if (SUCCEEDED(result)) { colors = new WICColor[colorCount]; if (NULL == colors) { result = E_OUTOFMEMORY; } } if (SUCCEEDED(result)) { UINT cActualColors = 0; result = palette->GetColors(colorCount, colors, &cActualColors); } if (SUCCEEDED(result)) { BeginBlock(stream, "PAL", frameNum); OutputValue(stream, colorCount); OutputValues(stream, colors, colorCount); result = EndBlock(stream); } if (colors) { delete[] colors; } } } return result; }
static HRESULT OutputColorContext(IStream *stream, UINT frameNum, UINT colorContextCount, IWICColorContext **colorContext) { HRESULT result = E_INVALIDARG; if (stream && colorContext) { BeginBlock(stream, "COL", frameNum); for(int i = 0; i < colorContextCount; i++) { UINT numBytes = 0; BYTE *bytes = NULL; result = S_OK; if (SUCCEEDED(result)) { result = colorContext[i]->GetProfileBytes(0, NULL, &numBytes); } if (numBytes > 0) { if (SUCCEEDED(result)) { bytes = new BYTE[numBytes]; if (NULL == bytes) { result = E_OUTOFMEMORY; } } if (SUCCEEDED(result)) { result = colorContext[i]->GetProfileBytes(numBytes, bytes, &numBytes); } if (SUCCEEDED(result)) { OutputValue(stream, numBytes); OutputValues(stream, bytes, numBytes); } if (bytes) { delete[] bytes; } } } result = EndBlock(stream); } return result; }
static HRESULT BeginBlock(IStream *stream, LPCSTR name, UINT frameNum) { HRESULT result = S_OK; if (NULL == stream) { result = E_INVALIDARG; } // Remember where we are if (SUCCEEDED(result)) { LARGE_INTEGER zero = { 0 }; result = stream->Seek(zero, STREAM_SEEK_CUR, &lastBlockPos); } // The number of bytes is stored as zero for now. The function EndBlock will write the // correct value later. UINT numBytes = 0; // Output the name if (SUCCEEDED(result)) { result = OutputValues(stream, name, 4); } // Output the frame number if (SUCCEEDED(result)) { result = OutputValue(stream, frameNum); } // Output the size if (SUCCEEDED(result)) { result = OutputValue(stream, numBytes); } return result; }
static HRESULT OutputBitmapSource(IStream *stream, LPCSTR name, UINT frameNum, double dpiX, double dpiY, IWICBitmapSource *source) { HRESULT result = E_INVALIDARG; if (stream && source) { UINT width = 0, height = 0; UINT stride = 0; WICPixelFormatGUID pixelFormat; BYTE *pixels = NULL; result = S_OK; // Retrieve the dimensions of the source if (SUCCEEDED(result)) { result = source->GetSize(&width, &height); } // Optionally retrieve the resolution if (SUCCEEDED(result) && (dpiX == 0 || dpiY == 0)) { result = source->GetResolution(&dpiX, &dpiY); } // Get the pixel format if (SUCCEEDED(result)) { result = source->GetPixelFormat(&pixelFormat); } // Get the stride if (SUCCEEDED(result)) { stride = GetScanlineStride(width, pixelFormat); if (stride < 1) { result = E_UNEXPECTED; } } // Allocate the pixels if (SUCCEEDED(result)) { pixels = new BYTE[stride * height]; if (NULL == pixels) { result = E_OUTOFMEMORY; } } // Get the pixels if (SUCCEEDED(result)) { WICRect rct; rct.X = 0; rct.Y = 0; rct.Width = width; rct.Height = height; result = source->CopyPixels(&rct, stride, stride * height, pixels); } // Output everything if (SUCCEEDED(result)) { BeginBlock(stream, name, frameNum); OutputValue(stream, width); OutputValue(stream, height); OutputValue(stream, dpiX); OutputValue(stream, dpiY); OutputValue(stream, stride); OutputValue(stream, pixelFormat); OutputValues(stream, pixels, stride*height); result = EndBlock(stream); } if (pixels) { delete[] pixels; } } return result; }