}//end constructor #region BITMAP STUFF public Bitmap ConvertToBitmap() { reader = new BinaryReader(new FileStream(File, FileMode.Open)); char[] id = reader.ReadChars(2); //CHECK FIRST CHARS TO CHECK PPM TYPE if (id[1] == '3') { //DO UNCOMPRESSED ASCII STUFF return(RawAsciiReader()); } else if (id[1] == '6') { //DO UNCOMPRESSED BINARY STUFF return(RawBinaryReader()); } else if (id[1] == '7') { //DO COMPRESSED ASCII STUFF return(DecompressRawAsciiReader()); } else if (id[1] == '8') { //DO COMPRESSED BINARY STUFF return(DecompressRawBinaryReader()); } else { //SEND EXCEPTION WINDOW AND LOAD YOU MESSED UP PICTURE ex.LoadedP1(); Bitmap bitmap = new Bitmap(@"C:\users\MCA\pictures\messedup.jpg"); IncorrectLoad = true; return(bitmap); } //end if } //end method
}//end constructor #region BITMAP STUFF public Bitmap ConvertToBitmap() { reader = new BinaryReader(new FileStream(File, FileMode.Open)); char[] id = reader.ReadChars(2); //check first chars to check PPM type if (id[1] == '3') { //DO ASCII STUFF return(RawAsciiReader()); } else if (id[1] == '6') { //DO BINARY STUFF return(RawBinaryReader()); } else { //SEND EXCEPTION WINDOW AND LOAD YOU MESSED UP PICTURE ex.LoadedP1(); Bitmap bitmap = new Bitmap(@"C:\users\MCA\pictures\messedup.jpg"); IncorrectLoad = true; return(bitmap); } //end if } //end method
}//end constructor #region BITMAP STUFF public Bitmap ConvertToBitmap() { reader = new BinaryReader(new FileStream(File, FileMode.Open)); char[] id = reader.ReadChars(2); try { //CHECK FIRST CHARS TO CHECK PPM TYPE if (id[1] == '3') { //DO UNCOMPRESSED ASCII STUFF return(RawAsciiReader()); } else if (id[1] == '6') { //DO UNCOMPRESSED BINARY STUFF return(RawBinaryReader()); } else if (id[1] == '7') { //DO COMPRESSED ASCII STUFF return(DecompressRleAsciiReader()); } else if (id[1] == '8') { //DO COMPRESSED BINARY STUFF return(DecompressRleBinaryReader()); } else if (id[1] == '9') { //DO COMPRESSED ASCII STUFF return(DecompressLzwAsciiReader()); } else if (id[1] == '1') { //DO COMPRESSED BINARY STUFF return(DecompressLzwBinaryReader()); } else { //SEND EXCEPTION WINDOW AND LOAD YOU MESSED UP PICTURE ex.LoadedP1(); return(null); }//end if } catch { MessageBox.Show("Error decompressing - Corrupt data", "Error"); return(null); } }//end method