University of Utah

Highschool Programming Contest

2001


Back to the main page

Q: How do I ask a question?
A: Send mail to hspc@cs.utah.edu

Q: (3/08/01) The compiler I'm using, Dev-C++, from Bloodshed Software (www.bloodshed.net) doesn't seem to be compiling the programs correctly. When running the compiled hspack program, for example, I get the following error: Image::ReadBMP - Unable to read pixels from ..\_island.bmp. Compression failed.
A: There were two versions of code released -- one for Unix and one for PC's. In the Unix version, you don't need to open a file as a 'binary' file, this happens automatically. Unfortunately, if this version is used on a PC, then file reading fails when the first Control-Z character is read. (This character marks the end of a PC file, but it can occur in the middle of a .bmp file.) To solve this, we made sure that our PC version opened the files as binary files by adding the appropriate parameter to the line that opened the file. Look in the three programs (hspack.cpp, hsunpack.cpp, and hseval.cpp) to find the instructions that open the file, and make sure they are opened in binary mode.

Q: (3/05/01) hseval gives me a large negative integer.
A: Sigh... I guess it's not quite done yet. The output is currently an integer that won't exceed 100 (a percentage) but that could be quite negative. We'll fix it later so it's a value between 0.0 and 1.0, but for now you just need to realize that 100 is a perfect match, and 0 or less is a really bad one.

Q: (3/02/01) How will hseval check the quality of my compression algorithm?
A: The (hopefully) final version of hseval is now on the web. Please try it and let us know if you find any problems. There are versions for Unix and VC++. It works as follows: It compares the average HSV values of the original picture with those of the picture that's been compressed and uncompressed, and generates a "quality index". It then divides the picture into quadrants and does the same. The quality values for the quadrants are combined with that for the whole picture. It continues to repeat that process (recursively) until it gets down to single pixels. Our goal is to imitate the way the eye averages the pixels in a picture and use that as our measure of quality.

Q: (3/01/01) How do I make my program work under DJGPP 2.03?
A: Austin Clements at Park City sent the following message:

   I wasn't able to successfully run any of the programs under DJGPP 2.03 
   until I added |ostream:out to every place where an ostream was opened 
   and an |istream:in to every place where an istream was opened.  Prior to 
   this it would say that it was not able to read the header and had been 
   able to read zero bytes when opening a bitmap and that there was an 
   error writing the file when saving a bitmap.  I don't know if anybody 
   else has had this problem or not, but I hope it helps.  (BTW, I added 
   this to the MSVC-based source code after having even more cryptic 
   problems with the other; I'm not sure how it would affect the UNIX-based 
   source code on DJGPP)

Q: (2/28/01) Can I use static variables in my Compressor class?
A: No.

Q: (2/28/01) Can I use a class/struct of my own declared outside of the Compressor class?
A: Yes, that should be fine. You could do it inside Compressor as well. In any case, all the code must be in Compressor.h and Compressor.cc files.

Q: (2/27/01) I can't compile your files with CodeWarrior C++.
A: Ray Barton at Olympus tells us that you need to do the following:

    We made the following changes in the Visual C++ versions of
    Image.cpp and Compressor.cpp and now we can pack and unpack
    images.

    Image.cpp

       Change the following lines in Image::readBMP
          i.e., add (char *)

       bytesread = in.read ((char *)fileheader, 14).gcount ();
       bytesread = in.read ((char *) infoheader, size).gcount ();
       bytesread = in.read ((char *) pixeldata, size).gcount ();

    Compressor.cpp

       Change the following lines in Compressor::decompress:
          i.e., add (char &)

       InputFile.get((char &) av );
       InputFile.get((char &) bv );
       InputFile.get((char &) cv );

    I think we also had to change a string compare to 'strcmp' 
    and a string copy to 'strcpy' in hspack.

Q: (2/26/01) hseval still doesn't work with Visual C++.
A: Sorry about that. We're working on it. Hopefully we'll have the real version of hseval ready shortly and can put that up for you to use. In the meantime, just use hspack and hsunpack to test your algorithms quantitatively and use your eye to evaluate them qualitatively.

Q: (2/23/01) I can't compile your files with Visual C++.
A: Visual C++ doesn't meet the latest C++ standard. We made several changes and created a VC++ project that you can download. If you're using another compiler on a PC, we suggest that you unzip the VC++ project and copy the .cpp files. You might have more success if you use those as a starting point. (They are the only files that have been changed.) Compressor.cpp, Image.cpp, and Pixel.cpp are in the support directory.

Q: (2/22/01) My compiler doesn't support strings.h. What should I do?
A: The string library is called string.h on some systems. If that doesn't work either, try String.h or Strings.h. One of those will certainly be correct. (If all else fails, check the documentation for your compiler.)

Q: (2/21/01) What are the functions/formulas/equations for converting RGB <-> HSV <-> YIQ <-> CMY? Or must we figure it out from the source code?
A: The Pixel class does this conversion for you. If you create a Pixel using RGB values, you can then read out the HSV values, etc, using Pixel member functions. Take a look at Pixel.h to see a list of those.


hspc@cs.utah.edu
Last modified: March 8, 2001