SubyuxiCreateRaster()
DimsDirAsString,sFileAsString
sDir="c:\temp"
sFile="yuxi"&;Format(Now(),"hhmmss")&;Int(10000*Rnd)
DimstrFormatAsString
strFormat="GRID"
DimpPointAsIPoint
SetpPoint=NewPoint
pPoint.PutCoords0,0
DimWWAsLong,HHAsLong
DimWCAsDouble,HCAsDouble
DimBCAsLong
WW=128
HH=128
WC=1
HC=1
BC=1
DimpixTypeAsrstPixelType
pixType=PT_UCHAR
DimpSRAsISpatialReference
SetpSR=NewUnknownCoordinateSystem
'--------------------------------------
Debug.Print"starttime="&;Now()
DimpWsAsIRasterWorkspace2
DimpDsAsIRasterDataset
DimpWsFactAsIWorkspaceFactory
SetpWsFact=NewRasterWorkspaceFactory
IfpWsFact.IsWorkspace(sDir)Then
SetpWs=pWsFact.OpenFromFile(sDir,0)
EndIf
SetpDs=pWs.CreateRasterDataset(sFile,strFormat,pPoint,WW,HH,WC,HC,BC,pixType,pSR,True)
DimpRawpixelAsIRawPixels
DimpPixelBlockAsIPixelBlock3
DimpPntAsIPnt,pSizeAsIPnt
DimpPixelData
DimpBandsAsIRasterBandCollection
DimpRasterPropsAsIRasterProps
DimpCache
SetpBands=pDs
SetpRawpixel=pBands.Item(0)
SetpRasterProps=pRawpixel
SetpPnt=NewDblPnt
pPnt.SetCoords0,0
SetpSize=NewDblPnt
pSize.SetCoordspRasterProps.Width,pRasterProps.Height
SetpPixelBlock=pRawpixel.CreatePixelBlock(pSize)
pRawpixel.ReadpPnt,pPixelBlock
pPixelData=pPixelBlock.PixelDataByRef(0)
DimiAsLong,jAsLong
Fori=0TopRasterProps.Width-1
Forj=0TopRasterProps.Height-1
pPixelData(i,j)=(i+j)Mod255
Nextj
Nexti
SetpCache=pRawpixel.AcquireCache
pRawpixel.WritepPnt,pPixelBlock
pRawpixel.ReturnCachepCache
'----------------------------------------------
SetpWs=Nothing
SetpDs=Nothing
SetpPoint=Nothing
SetpRawpixel=Nothing
SetpPixelBlock=Nothing
SetpPnt=Nothing
SetpSize=Nothing
SetpRasterProps=Nothing
SetpBands=Nothing
SetpCache=Nothing
Debug.Print"finishtime="&;Now()
EndSub