LTIOMemStream read - first strip blank

For discussion of LizardTech's free Decode SDK for MrSID and JPEG 2000.

Moderator: jskiffington

LTIOMemStream read - first strip blank

Postby windflower » Fri Mar 19, 2010 11:58 am

I am decoding a MrSID image file into a stream, then reading it out. The first strip displayed is black, and the file is pushed down one strip so the top of the image is displayed below the black strip, and the bottom strip of the image is cropped off. I've confirmed that the error is exactly one strip by changing the strip size. I can mask the error by setting the strip size to 2, but then the drawing is slow. I've also debugged by writing to a file instead of a stream to confirm that the write step is working correctly. It clearly fails when I'm reading from the stream.

Any idea what could cause this problem?

[code]
// sidFile is an input string full path to the file
const LTFileSpec fileSpec(sidFile);

MrSIDImageReader *reader = MrSIDImageReader::create();
reader->initialize(fileSpec);

BMPImageWriter writer(reader);
writer.initialize();

const LTIScene scene(ulX, ulY, width, height, mag);

// set up the output stream
LTIOMemStream *ostream = new LTIOMemStream();
ostream->initialize(bytesAllocated);
ostream->open();
sts = writer.setOutputStream(ostream);

// decode MrSid image to bmp
writer.write(scene);

// read image into a byte array
lt_uint32 actualSize = ostream->read(decodedBmp, (lt_uint32)bytesAllocated);
ostream->close();
[/code]

Thanks,
Windflower
windflower
 
Posts: 3
Joined: Wed Dec 23, 2009 11:54 am

Postby gat » Fri Apr 09, 2010 10:27 am

I am very sorry that you did not get a response on this issue in a timely manner. We think it could be a matter of first seeking to the beginning of the file and then try your read. Let us know if that helps and again I'm sorry about the slow response.
gat
 
Posts: 28
Joined: Mon Jan 12, 2009 12:41 pm

Postby windflower » Fri Apr 23, 2010 1:45 pm

I tried seeking to the beginning of the stream before reading like this:

int offset = 0;
ostream->seek(offset, LTIO_SEEK_DIR_BEG);

The result is a black band at the bottom of the image with the image shifted up. Also, with an offset of 0 the image is shifted right and wrapped around so the right hand strip of the image appears on the left with a color shift. This is with a 24rgb image.

I can control the wrap and color shift by changing the offset. 0, 8, 16 all create the same amount of wrap with different color shifts. 56 produces no wrap and displays in the normal color space.

I cannot alter the width of the black strip/upward shift of the image.
---------------------------

Something I had done as a bit of a hack before was to setStripHeight on the writer to 2. When I'm not doing the seek as above, changing the strip height does change the black area on the TOP of the image and the corresponding downward shift of the image. By making it 2, the strip is small but the decoding is slower.

However, when I seek to position the stream explicitly before reading, the effect of setStripHeight disappears. Changing the 2 to something else or removing the call to setStripHeight both have no effect.

So, the seek changes it, but it doesn't fix it. Any other ideas?

Thanks,
Windflower
windflower
 
Posts: 3
Joined: Wed Dec 23, 2009 11:54 am


Return to SDKs

Who is online

Users browsing this forum: No registered users and 1 guest