<!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>
<DIV><FONT face=Arial size=2>Hi list,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><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">I am
writing function in C++ witch on input get large raster and return small sub
window of the input raster in BitMap (*.BMP file). The sub window is never
larger then 1000*1000px.<?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">The
code looks like:<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; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US">hDriver
= GetGDALDriverManager()->GetDriverByName("BMP");<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><o:p> </o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US">hDataset
= GDALOpenShared( pszSrcFilename, GA_ReadOnly );<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-tab-count: 1">
</SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US">poVDS
= <SPAN style="COLOR: blue">new</SPAN> VRTDataset(xsize,
ysize);<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><o:p> </o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US">nBandCount
= GDALGetRasterCount( hDataset );<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-spacerun: yes"> </SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><o:p> </o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US">for</SPAN><SPAN
lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US">( i
= 0; i < nBandCount; i++ )<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US">{<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-spacerun: yes"> </SPAN>VRTSourcedRasterBand<SPAN
style="mso-spacerun: yes"> </SPAN>*poVRTBand;<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-spacerun: yes"> </SPAN>GDALRasterBand<SPAN
style="mso-spacerun: yes"> </SPAN>*poSrcBand;<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-spacerun: yes"> </SPAN>GDALDataType<SPAN
style="mso-spacerun: yes">
</SPAN>eBandType;<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-tab-count: 2">
</SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-spacerun: yes"> </SPAN>poSrcBand = ((GDALDataset
*)hDataset)->GetRasterBand(i+1);<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-spacerun: yes"> </SPAN>eBandType =
poSrcBand->GetRasterDataType();<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-tab-count: 1"> </SPAN><SPAN
style="COLOR: green"><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-spacerun: yes"> </SPAN>poVDS->AddBand(
eBandType, NULL );<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-spacerun: yes"> </SPAN>poVRTBand =
(VRTSourcedRasterBand *) poVDS->GetRasterBand( i+1 );<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-tab-count: 2">
</SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-spacerun: yes">
</SPAN>poVRTBand->AddSimpleSource( poSrcBand,x, y, xsize, ysize,0, 0, xsize,
ysize );<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><o:p> </o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-spacerun: yes">
</SPAN>poVRTBand->CopyCommonInfoFrom( poSrcBand );<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US">}<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><SPAN
style="mso-tab-count: 1">
</SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><o:p> </o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US">hOutDS
= GDALCreateCopy( hDriver,"c:\\CsharpTest\\temp\\cut.bmp", (GDALDatasetH)
poVDS,FALSE, NULL, NULL, NULL );<o:p></o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><o:p> </o:p></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><o:p> </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">Than
I am calling this function from C# .Net application and I need result (in
example case cut.bmp) in byte array. <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">It is
possible use CreateCopy with out disk writing operation and return result in
byte array?<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"><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"><o:p><FONT face="Times New Roman"
size=3> <FONT face=Arial size=2>thanks ivan
</FONT></FONT></o:p></SPAN></P></FONT></DIV></BODY></HTML>