Original Post
Hey everyone, Im working on a lossy compression program for school over spring break here (great homework huh), and its quadtree compression of a picture in binary format. But the professor made up his own kind of picture format, with a .[1] extension and the first 4 bytes of the file are the dimensions of the picture followed by the rest of the picture data, where each byte represents a pixel.
My dumb question is, how do I get those first 4 bytes (2 for rows, 2 for columns, which is why Im using shorts) into short variables? This is a really dumb question I know, I probably have some lame syntax bug somewhere but heres what I have:
Any suggestions?
short imgSizeRows; short imgSizeCols; fin.open( argv[1], ios::binary ); fin.read( (char*)&imgSizeRows, sizeof(imgSizeRows) ); fin.read( (char*)&imgSizeCols, sizeof(imgSizeCols) );Where imgSizeRows & imgSizeCols are private variables in the quadtree class. Right after I read in the dimensions I allocate a 2D array for the rest of the pixels and fill in that array, but for some reason the code above I always get 2''s for the two variables
