private int[] GetImageDataAsInts() { // if the image is set to a pnm input data this way if (InputTypeE.PNM == inputType) { PNMtoBuffer.PNMtoBufferedIntArray buffer = new PNMtoBuffer.PNMtoBufferedIntArray(); PNMtoBuffer.PNMIntArrayObject output = buffer.Compile(this.filePath); this.width = output.Width; this.height = output.Height; this.breadth = 1; return(output.Pixels); } else { //TODO return(null); } }
private PNMIntArrayObject ReadBinaryGreyscaleImage(BinaryReader reader) { // create the object to be sent back PNMIntArrayObject output = new PNMIntArrayObject { // grab the two headers Width = GetNextHeaderValue(reader), Height = GetNextHeaderValue(reader), // ensure the scalse is set to an invalid number Scale = GetNextHeaderValue(reader) }; // Initalize the array output.Pixels = new int[output.Height * output.Width - 1]; for (int index = 0; index < (output.Height * output.Width) - 1; index++) { output.Pixels[index] = reader.ReadByte() * 255 / output.Scale; } return(output); }