[Gdal-dev] (no subject)

alucas at srtec.com alucas at srtec.com
Sun Jan 8 07:38:44 EST 2006


Hello,
I've a problem with fwtools and vc++ 6.0 gdi to show "utm.tif" sample. If
I set Bitcount= 8 the colors are showed incorrectly but if I set
BitCount=24 the colors are showed correctly but the raster is showed very
small and repeatly but the colors are correct. Any idea???

Code: OnDraw
        CPruebaDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// Bitmap Info Header
	    BITMAPINFOHEADER BIH;
	    int iSize = sizeof(BITMAPINFOHEADER);
	    memset(&BIH, 0, iSize); // lo rellenamos con 0's, por eso sale negro...

	    // Fill in the header info.
	    BIH.biSize = iSize;
	    BIH.biWidth = 512;
	    BIH.biHeight = 512;
	    BIH.biPlanes = 1; //bandas?
	    BIH.biBitCount = 24; // bpp
		BIH.biClrUsed = 256;
	    BIH.biCompression = BI_RGB;

		// BITMAPINFO
		BITMAPINFO bmi;
		bmi.bmiHeader = BIH;
/*
		if(pDoc->pData->GetRasterBand(1)->GetColorInterpretation() ==
GCI_GrayIndex)
		{
			for ( UINT i=0 ; i < BIH.biClrUsed ; i++ )
			{
				RGBQUAD q = {i,i,i,0};
				bmi.bmiColors[i] = q;
			}
		}
*/

		void* dBits;
	    GByte* src = pDoc->Buffer;

		// Nuevo DC
	    CDC m_pdc;
		m_pdc.CreateCompatibleDC(pDC);

		// Create the DIB section.
	    HBITMAP m_hbmp = CreateDIBSection(m_pdc.GetSafeHdc(),
								 &bmi,
								 DIB_RGB_COLORS,
								 &dBits,
								 NULL,
								 0);
		if(!dBits)
			MessageBox("error","msg",MB_OK);

		// creo que dBits es NULL
		GByte* dest = (unsigned char*)dBits;

		GByte* ptr_dest;
		GByte* ptr_src;
   		for(int r=0;r<512;r++)
		{
			ptr_dest = dest + r * 512;
			ptr_src = src + r * 512;
			memcpy(ptr_dest,ptr_src,512);
		}

		CRect rect;
		GetClientRect(&rect);
		ASSERT(m_hbmp);
		//m_pdc.SelectObject(m_hbmp);
		SelectObject(m_pdc.GetSafeHdc(),m_hbmp);
		pDC->BitBlt(0,0,rect.Width(),rect.Height(),&m_pdc,0,0,SRCCOPY);

		ReleaseDC(&m_pdc);
Thanks.

Antonio Lucas

Software Engineer
SER&TEC S.L
Phone: +34 96 395 95 13
www.srtec.com
Valencia (Spain)





More information about the Gdal-dev mailing list