<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-2">
<META content="MSHTML 6.00.2900.2627" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff><FONT face=Arial size=2>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="mso-ansi-language: EN-US"><FONT size=3><FONT face="Times New Roman">Hi
All,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office"
/><o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="mso-ansi-language: EN-US"><o:p><FONT face="Times New Roman"
size=3> </FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="mso-ansi-language: EN-US"><FONT size=3><FONT face="Times New Roman">At
first thanks a lot for yours replies. It helps a lot. I have been finished my
C++ library and I would show you my code that createcopy sub window
of image into memory. I know it is simple, but for GDAL beginners like I am it
is very useful see some example. </FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="mso-ansi-language: EN-US"><FONT size=3><FONT
face="Times New Roman"></FONT></FONT></SPAN> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="mso-ansi-language: EN-US"><FONT face="Times New Roman" size=3>this part
of unmanage c++ dll code</FONT></SPAN></P><SPAN lang=EN-US
style="mso-ansi-language: EN-US"><FONT><FONT face="Times New Roman">
<P>BASICGDAL_API GByte* createSubImageMemory(<FONT color=#0000ff>char</FONT>
*pszSrcFilename,<FONT color=#0000ff>int</FONT> x, <FONT color=#0000ff>int</FONT>
y,<FONT color=#0000ff>int</FONT> xsize,<FONT color=#0000ff>int</FONT>
ysize,<FONT color=#0000ff>int</FONT> *Length){<BR>
vsi_l_offset nBigLength; <FONT color=#0000ff><BR> </FONT><FONT
color=#0000ff>int</FONT> t;<BR> GByte*
pabyOUTData;<BR> <FONT color=#0000ff>char</FONT>
**papszCreateOptions = NULL;<BR> GDALDatasetH
hDataset,hOutDS;<BR> GDALDriverH
hDriver;<BR> VRTDataset *poVDS;<BR> <FONT
color=#0000ff>int</FONT> nBandCount = 0;<BR> <FONT
color=#0000ff>int</FONT> i;<BR><BR>
GDALAllRegister();<BR> <BR> hDriver =
GetGDALDriverManager()->GetDriverByName("BMP");<BR>
hDataset = GDALOpenShared( pszSrcFilename, GA_ReadOnly
);<BR><BR> poVDS = <FONT color=#0000ff>new</FONT>
VRTDataset(xsize, ysize);</P>
<P> nBandCount = GDALGetRasterCount( hDataset );</P>
<P><FONT color=#0000ff> for</FONT>( i = 0; i < nBandCount;
i++ )<BR> {<BR>
VRTSourcedRasterBand *poVRTBand;<BR>
GDALRasterBand *poSrcBand;<BR> GDALDataType
eBandType;<BR> poSrcBand = ((GDALDataset
*)hDataset)->GetRasterBand(i+1);<BR>
eBandType = poSrcBand->GetRasterDataType();<BR>
poVDS->AddBand( eBandType, NULL );<BR>
poVRTBand = (VRTSourcedRasterBand *) poVDS->GetRasterBand(
i+1 );<BR> poVRTBand->AddSimpleSource(
poSrcBand,x, y, xsize, ysize,0, 0, xsize, ysize );<BR>
poVRTBand->CopyCommonInfoFrom( poSrcBand
);<BR> }<BR><BR>
VSIInstallMemFileHandler();<BR> hOutDS = GDALCreateCopy(
hDriver,"/vsimem/out.bmp", (GDALDatasetH) poVDS,<BR> FALSE,
NULL, <BR> NULL, NULL );<BR>
<BR> <FONT color=#0000ff>if</FONT>( hOutDS != NULL
)<BR> {<BR> GDALClose(
hOutDS );<BR> }<BR> <BR>
GDALClose( (GDALDatasetH) poVDS );<BR> GDALClose( hDataset
);<BR> <BR> pabyOUTData=VSIGetMemFileBuffer(
"/vsimem/out.bmp",&nBigLength, TRUE );<BR>
VSIUnlink("/vsimem/out.bmp"); <BR> VSICleanupFileManager
();<BR> *Length=(<FONT
color=#0000ff>int</FONT>)nBigLength;<BR> <FONT
color=#0000ff>return</FONT> pabyOUTData; <BR>}</P>
<DIV><o:p><FONT size=3>and this is part of C# mange code
</FONT></o:p></DIV>
<DIV><o:p><FONT size=3></FONT></o:p> </DIV>
<DIV><o:p><FONT size=2>
<P>[DllImport("BasicGdal.dll")]<BR></FONT><FONT color=#0000ff
size=2>internal</FONT><FONT size=2> </FONT><FONT color=#0000ff
size=2>static</FONT><FONT size=2> </FONT><FONT color=#0000ff
size=2>extern</FONT><FONT size=2> IntPtr createSubImageMemory(</FONT><FONT
color=#0000ff size=2>string</FONT><FONT size=2> pszSrcFilename,</FONT><FONT
color=#0000ff size=2>int</FONT><FONT size=2> x, </FONT><FONT color=#0000ff
size=2>int</FONT><FONT size=2> y,</FONT><FONT color=#0000ff
size=2>int</FONT><FONT size=2> xsize,</FONT><FONT color=#0000ff
size=2>int</FONT><FONT size=2> ysize,</FONT><FONT color=#0000ff
size=2>ref</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>int</FONT><FONT
size=2> size);<BR><BR><FONT color=#0000ff size=2>int</FONT><FONT size=2>
size=0;<BR><FONT size=2><BR>IntPtr zacatek; </FONT><BR>zacatek =
BasicGdal.createSubImageMemory2(</FONT><FONT color=#0000ff
size=2>this</FONT><FONT size=2>.testFile,5000,5000,3000,3000,</FONT><FONT
color=#0000ff size=2>ref</FONT><FONT size=2> size);</P>
<P></FONT><FONT color=#0000ff size=2>byte</FONT><FONT size=2>[] buf=</FONT><FONT
color=#0000ff size=2>new</FONT><FONT size=2> </FONT><FONT color=#0000ff
size=2>byte</FONT><FONT size=2>[size];</P>
<P></P>
<P>Marshal.Copy(zacatek,buf,0,size);<BR></FONT><FONT
size=2><BR>System.IO.FileStream fs;<BR>fs = </FONT><FONT color=#0000ff
size=2>new</FONT><FONT size=2>
System.IO.FileStream("c:\\Projects\\GDAL\\CsharpTest\\CsharpTest\\bin\\Debug\\test.bmp",System.IO.FileMode.Create);<BR>fs.Write(buf,0,buf.Length);<BR>fs.Close();<BR>Marshal.FreeCoTaskMem(zacatek);<BR><BR><FONT
face=Arial>Ivan</FONT></P></FONT></FONT></o:p></FONT></FONT></SPAN></FONT></DIV></BODY></HTML>