[Gdal-dev] ER Mapper and Visual C++ 2005...?
Charles Wivell
Charles.Wivell at dnr.state.mn.us
Tue Feb 6 16:47:59 EST 2007
Hi all;
FYI... I could never get the C++ calls to work, so I decided to try
just the C calls in the API. It took less than 2 hours and everything
was work as I thought it would.
Chuck
=====================================
Charles Wivell
MN DNR Forestry/Resource Assessment
413 SE 13th Street
Grand Rapids, MN 55744
218-327-4449 x 233
=====================================
>>> "Charles Wivell" <Charles.Wivell at dnr.state.mn.us> 2/5/2007 12:39 PM
>>>
Hi all;
I'm trying to get the ECW/JPEG 2000 libraries to work in a VS 2005 C++
application.
The code looks something like...
mpECWImage = new CNCSFile();
eError = mpECWImage->Open(fpath,FALSE,FALSE);
if (eError == NCS_SUCCESS) {
HaveOpenECW = TRUE;
}
This works, I can get the members of the image by doing the following:
// Get information about the ECW image
mnNumOfECWSamps = mpECWImage->m_nWidth;
mnNumOfECWLines = mpECWImage->m_nHeight;
mnNumOfECWBands = mpECWImage->m_nNumberOfBands;
// Get the upper left corner of the full ECW image (UTM)
mdULECWNort = mpECWImage->m_dOriginY;
mdULECWEast = mpECWImage->m_dOriginX;
mdECWSampGSD = mpECWImage->m_dCellIncrementX;
mdECWLineGSD = -1.0 * mpECWImage->m_dCellIncrementY;
I tried using the GetFileInfo() routine but it comes back with the
structure empty..... (all zeros)
I then try setting a view into the ECW image by....
eError = mpECWImage->SetView(3, BandList, nsamps, nlines,
ULEast, ULNort, LREast, LRNort);
if (eError == NCS_SUCCESS)
{
HaveViewECW = TRUE;
}
The function returns with a success but when I try to look at the view
structure by:
NCSFileView *FileSetInfo = GetNCSFileView();
The view structure is empty.... (all values are zero)
I would like to read one band of the ECW view into a memory buffer by
doing :
for (iline = 0; iline < nlines; iline++)
{
mpECWImage->ReadLineRGB(LineBuffer);
icount2 = 0;
for (isamp = 0; isamp < nsamps; isamp++)
{
test = LineBuffer[icount2 + CountOffset];
mpECWWndBuffer[icount] = test;
icount++;
icount2 =+ 3;
}
}
But I'm getting an error from the ReadLineRGB() function the first
time
it is called. LineBuffer is being reserved at a size of an unsigned
char
(nsamps * 3)
mnECWWndSize = nlines * nsamps;
mpECWWndBuffer = new unsigned char[mnECWWndSize]; // one band
of the ECW image
unsigned char *LineBuffer = new unsigned char[nsamps * 3]; //
the line of the triplet for the ECW image....
Note: CountOffset is either a 0,1 or 2, depending on which band is to
be read into the buffer....
I think this is because SetView is not working correctly.....? Anyone
know what I'm missing? Maybe I'm missing a header file or need a way
to
start the ECW libraries...?
Any help would be greatly appreciated!!
Chuck
=====================================
Charles Wivell
MN DNR Forestry/Resource Assessment
413 SE 13th Street
Grand Rapids, MN 55744
218-327-4449 x 233
=====================================
_______________________________________________
Gdal-dev mailing list
Gdal-dev at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/gdal-dev
More information about the Gdal-dev
mailing list