[Gdal-dev] ER Mapper and Visual C++ 2005...?

Charles Wivell Charles.Wivell at dnr.state.mn.us
Mon Feb 5 13:39:55 EST 2007


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
=====================================



More information about the Gdal-dev mailing list