Bitmap/Read a PPM file: Difference between revisions

Content added Content deleted
m (→‎{{header|D}}: missing D, btw implementation is probably slow, and would be cool to change it)
(→‎{{header|D}}: drastically improve reading :))
Line 171: Line 171:
import tango.io.MappedBuffer;
import tango.io.MappedBuffer;
import tango.io.stream.LineStream;
import tango.io.stream.LineStream;
import tango.io.stream.DataStream;
import tango.io.protocol.Reader;
import tango.io.protocol.Reader;
import tango.text.convert.Integer;
import tango.text.convert.Integer;
Line 190: Line 189:
throw new BadInputException;
throw new BadInputException;


if (processData(new DataInput(fileBuf)))
if (processData(fileBuf))
throw new BadInputException;
throw new BadInputException;
}
}
Line 221: Line 220:
}
}


int processData(DataInput di) {
int processData(MappedBuffer mb) {
if (! gotImg) throw new NoImageException;
if (! gotImg) throw new NoImageException;
foreach (ref cell; bitmap) {
mb.fill(bitmap.data);
cell(di.getByte, di.getByte, di.getByte);
}
return 0;
return 0;
}
}