Пример #1
0
HDC * CreateImage(long width, long height)
{


	BITMAPINFO bmInfo = {0};
	memset(&bmInfo,0,sizeof(bmInfo));
	bmInfo.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
	bmInfo.bmiHeader.biWidth       = width;
	bmInfo.bmiHeader.biHeight      = height * -1; // Negative gives us a top-down image.
	bmInfo.bmiHeader.biPlanes      = 1;
	bmInfo.bmiHeader.biBitCount    = 24;
	bmInfo.bmiHeader.biCompression = BI_RGB;

	HDC hdc = ::CreateCompatibleDC(NULL);
	ScopeGuard guardDC = MakeGuard(::DeleteDC, hdc);

	unsigned char *pBits = NULL;
	HBITMAP hbm = ::CreateDIBSection(hdc, &bmInfo, DIB_RGB_COLORS, (void **)&pBits, NULL, NULL);

	writeTIFF("C:\\Flake.tif", hdc);
	
	//DeleteObject(SelectObject(hdc, hbm));


	return &hdc;
}
Пример #2
0
/**
 * Write float image as TIFF 32 bits per sample.
 */
int io_tiff_write_f32(const char *fname, const float *data,
                      size_t nx, size_t ny, size_t nc)
{
    int ok;
    TIFF *tif = TIFFOpen(fname, "w");
    if (!tif) {
        fprintf(stderr, "Unable to write TIFF file %s\n", fname);
        return 0;
    }

    ok = writeTIFF(tif, data, nx, ny, nc);
    TIFFClose(tif);
    return (ok ? 0 : -1);
}