| 
					阅读:2134回复:5
				 [求助]如何在VC(AO) 中实现遍历像元与赋值
					<P>vb中的部分程序:</P>
 <P>Create PixelBlock with defined size<BR>Dim pBlock As IPixelBlock<BR>Set pBlock = pRawPixel.CreatePixelBlock(pSize)<BR> ' Get the SafeArray associated with the first band<BR> Dim pSafeArray As Variant<BR> pSafeArray = pBlock.SafeArray(0)<BR> ' Loop through the SafeArray and set value to each pixel<BR> Dim I, J As Integer<BR> For I = 0 To pSize.X - 1<BR> For J = 0 To pSize.Y - 1<BR> pSafeArray(I, J) = I + J<BR> Next J<BR> Next I</P> <P>这段代码在VC中应该是怎样的呢? </P> | |
| 1楼#发布于:2006-03-29 10:53 
					<P>高手帮下忙吧?</P>				 | |
| 2楼#发布于:2006-03-29 10:55 
					<P>我这样尝试,可是结果是象元值都是0.</P>
 <P> hr=pRawpixel->Read(pPnt,pPixelBlock);<BR>// hr=pPixelBlock->PixelDataRef(0);</P> <P><BR> SAFEARRAY *pa;<BR> hr=SafeArrayAllocDescriptor(2,;pa);//Allocates memory for a safe array descriptor<BR> pa->rgsabound[0].lLbound=0;<BR> pa->rgsabound[1].lLbound=0;<BR> pa->rgsabound[0].cElements=width;<BR> pa->rgsabound[1].cElements=height;<BR> pa->cbElements=sizeof(long); <BR> hr=SafeArrayAllocData(pa);//Allocates memory for a safe array, based on a descriptor created with SafeArrayAllocDescriptor.<BR> <BR> long lDimension[2];<BR> <BR> <BR> VARIANT pPixelData;</P> <P> VariantInit(;pPixelData);<BR> pPixelData.vt=VT_VARIANT|VT_ARRAY;</P> <P> hr=pPixelBlock->get_SafeArray(0,;pPixelData);<BR> <BR> long i,j,x;</P> <P><BR> for(i=0;i<=5;i++)<BR> { for(j=0;j<=5;j++)<BR> {<BR> lDimension[1]=i;//行<BR> lDimension[0]=j;//列<BR> x=(i+j) % 255;<BR> hr=SafeArrayPutElement(pa,lDimension,;x);<BR> }<BR> }<BR> pPixelData.parray=pa;<BR> hr=pPixelBlock->put_SafeArray(0,pPixelData);</P> <P> hr=pRawpixel->Write(pPnt,pPixelBlock); </P> | |
| 3楼#发布于:2006-04-14 09:33 
					<P>现在我有生成栅格文件</P>
 <P>可是在ERDAS 里面打开的时候栅格值为0</P> <P>而LUT却是有值的</P> <P>这是事什么原因啊?</P> | |
| 4楼#发布于:2006-04-14 15:32 
					<P>哎,一直以来就是自己一个人在这个主题下“自言自语”</P>
 <P>不过还好</P> <P>总算弄通了。</P> <P>这个帖子算是结束了吧。说一下,所以没有值,是因为我在createdataset时数据类型不对</P> | |
| 5楼#发布于:2006-06-11 15:43 
					hehe, i will try it following u have said				 | |
 
							
 
				
