<DIV> hello:</DIV>
<DIV> the following code,can not show tif:</DIV>
<DIV>void CTrans::DrawImage1(void)<BR>{ <BR> m_pMemoryDC->SelectObject(m_pMemoryBitMap);<BR> CRect rc(0,0,m_pViewWidth,m_pViewHeight); <BR> CBrush brush(RGB(255,255,255));<BR> m_pMemoryDC->FillRect(rc,&brush); <BR> if( poDataset != NULL ) <BR> {</DIV>
<DIV> <BR> GDALRasterBand *poBand1; //遥感的一个波段<BR> GDALRasterBand *poBand2;<BR> GDALRasterBand *poBand3;<BR> int nBandCount;<BR> nBandCount=poDataset->GetRasterCount();<BR> poBand1=poDataset->GetRasterBand(1);<BR> poBand2=poDataset->GetRasterBand(2);<BR> poBand3=poDataset->GetRasterBand(3);<BR> <BR> if (poBand1!=NULL && poBand2 != NULL &&poBand3!=NULL) <BR> {<BR> <BR> //获取图像的尺寸<BR> //获取图像窗口尺寸<BR> <BR> <BR> int nImgSizeX=poDataset->GetRasterXSize();<BR> int nImgSizeY=poDataset->GetRasterYSize();<BR> <BR> int nBufferSizeX,nBufferSizeY;<BR> <BR> nBufferSizeX = nImgSizeX;<BR> nBufferSizeY= nImgSizeY;<BR> <BR> <BR> <BR> BYTE *pafScanblock1,*TempLock1;<BR> BYTE *pafScanblock2,*TempLock2;<BR> BYTE *pafScanblock3,*TempLock3;<BR> <BR> pafScanblock1 = (BYTE *) CPLMalloc((nBufferSizeX)*(nBufferSizeY));<BR> pafScanblock2 = (BYTE *) CPLMalloc((nBufferSizeX)*(nBufferSizeY));<BR> pafScanblock3 = (BYTE *) CPLMalloc((nBufferSizeX)*(nBufferSizeY));<BR> <BR> TempLock1 = pafScanblock1;<BR> TempLock2 = pafScanblock2;<BR> TempLock3 = pafScanblock3;<BR> <BR> poBand1->RasterIO( GF_Read, 0, 0,nBufferSizeX,nBufferSizeY, <BR> pafScanblock1,nBufferSizeX,nBufferSizeY, GDT_Byte,0, 0 );<BR> <BR> poBand2->RasterIO( GF_Read, 0, 0,nBufferSizeX,nBufferSizeY, <BR> pafScanblock2,nBufferSizeX,nBufferSizeY, GDT_Byte,0, 0 );<BR> <BR> poBand3->RasterIO( GF_Read, 0, 0,nBufferSizeX,nBufferSizeY, <BR> pafScanblock3,nBufferSizeX,nBufferSizeY, GDT_Byte,0, 0 ); </DIV>
<DIV> //在View逐点显示图像<BR> DWORD dwBytes = (nBufferSizeX * 24) / 8; <BR> while(((DWORD) dwBytes) % 4) <BR> {<BR> dwBytes++;<BR> }<BR> <BR> BYTE *szBuffer = new BYTE[nBufferSizeY*dwBytes];<BR> memset(szBuffer,0,nBufferSizeY*dwBytes);<BR> BYTE *pTemp = szBuffer; <BR> int nIndex = 0;<BR> for (int i=0;i<nBufferSizeY;i++)<BR> {<BR> for (int j=0;j<nBufferSizeX;j++)<BR> {<BR> <BR> BYTE dn1=*pafScanblock1;<BR> BYTE dn2=*pafScanblock2;<BR> BYTE dn3=*pafScanblock3;<BR> <BR> memcpy(szBuffer,(char*)(&dn3),1);<BR> szBuffer+=1;<BR> memcpy(szBuffer,(char*)(&dn2),1);<BR> szBuffer+=1;<BR> memcpy(szBuffer,(char*)(&dn1),1);<BR> szBuffer+=1;</DIV>
<DIV> pafScanblock1++;<BR> pafScanblock2++;<BR> pafScanblock3++;<BR> <BR> }<BR> <BR> szBuffer = pTemp+dwBytes*i;<BR> <BR> }<BR> CPLFree(TempLock1);<BR> CPLFree(TempLock2);<BR> CPLFree(TempLock3); <BR> </DIV>
<DIV> BITMAPINFOHEADER bmiHdr;<BR> BITMAPINFO MapInfo;<BR> memset(&bmiHdr, 0, sizeof(BITMAPINFOHEADER));<BR> bmiHdr.biBitCount = 3*8;<BR> bmiHdr.biClrImportant = 0;<BR> bmiHdr.biClrUsed = 0;<BR> bmiHdr.biCompression = BI_RGB;<BR> bmiHdr.biHeight = -nBufferSizeY;<BR> bmiHdr.biPlanes = 1;<BR> bmiHdr.biSize = sizeof(BITMAPINFOHEADER);<BR> bmiHdr.biSizeImage = 0;<BR> bmiHdr.biWidth = nBufferSizeX;<BR> <BR> bmiHdr.biXPelsPerMeter = 0;<BR> bmiHdr.biYPelsPerMeter = 0;<BR> <BR> MapInfo.bmiHeader = bmiHdr;<BR> MapInfo.bmiColors[0].rgbBlue = 0;<BR> MapInfo.bmiColors[0].rgbGreen = 0;<BR> MapInfo.bmiColors[0].rgbRed = 0;<BR> MapInfo.bmiColors[0].rgbReserved = 0;<BR> <BR> //dc.SetStretchBltMode(COLORONCOLOR);<BR> StretchDIBits(m_pMemoryDC->GetSafeHdc(), 0, 0, nBufferSizeX,nBufferSizeY,//nScrrenWidth, nScrrenHeight,<BR> 0, 0, bmiHdr.biWidth, -bmiHdr.biHeight,<BR> pTemp, (LPBITMAPINFO)(&MapInfo), DIB_RGB_COLORS, SRCCOPY);<BR> <BR> GDALClose(poDataset);<BR> delete []pTemp; <BR> }<BR> }<BR> <BR>} </DIV>
<DIV>where are wrong?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV><br><!-- footer --><br>
<hr>
<font style="font-size:12px;line-height:15px;">[广告] </font><a style="font-size:12px;line-height:15px; color:blue; text-decoration:underline;" href="http://popme.163.com/link/004584_0904_755.html">淘宝史上最创意</a><font style="font-size:12px;line-height:15px;">集市</font>