Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsafe
- {
- byte* ptr = (byte*)data.Scan0;
- short colorValue = 0;
- bool isLastDigit = false;
- for (int length = file.ReadBlock(buffer, 0, buffer.Length); length != 0; length = file.ReadBlock(buffer, 0, buffer.Length))
- {
- for (int i = 0; i < length; i++)
- {
- if (Char.IsDigit(buffer[i]) && !isComment)
- {
- colorValue = (short)(colorValue * 10 + buffer[i] - '0');
- isLastDigit = true;
- }
- else if (isComment && (buffer[i] == '\n'))
- {
- isComment = false;
- }
- else
- {
- if (isLastDigit)
- {
- *(ptr++) = (byte)((colorValue * 255) / dimension.ColourRange.Value);
- isLastDigit = false;
- colorValue = 0;
- }
- if (buffer[i] == '#')
- isComment = true;
- }
- };
- }
- bmp.UnlockBits(data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement