mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
plugin/ppm: improved compatibility
This commit is contained in:
parent
86853f1194
commit
89a5ec74cd
1 changed files with 20 additions and 13 deletions
|
|
@ -18,20 +18,27 @@ bool PPMRaster::Create()
|
|||
}
|
||||
|
||||
try {
|
||||
if(stream.GetLine() != "P6")
|
||||
if(stream.Get(2) != "P6")
|
||||
return false;
|
||||
String h = stream.GetLine();
|
||||
CParser p(h);
|
||||
size.cx = p.ReadInt();
|
||||
size.cy = p.ReadInt();
|
||||
if(size.cx <= 0 || size.cx > 99999 || size.cy <= 0 || size.cy >= 99999)
|
||||
return false;
|
||||
h = stream.GetLine();
|
||||
CParser p1(h);
|
||||
int maxval = p1.ReadInt();
|
||||
if(maxval <= 0 || maxval > 65535)
|
||||
return false;
|
||||
is16 = maxval > 255;
|
||||
int ii = 0;
|
||||
int num[3];
|
||||
String line;
|
||||
CParser p(line);
|
||||
while(ii < 3) {
|
||||
while(p.IsEof() || p.Char('#')) {
|
||||
if(stream.IsEof())
|
||||
return false;
|
||||
line = stream.GetLine();
|
||||
p.Set(line);
|
||||
}
|
||||
int n = p.ReadInt();
|
||||
if(n <= 0 || n > 65535)
|
||||
return false;
|
||||
num[ii++] = n;
|
||||
}
|
||||
size.cx = num[0];
|
||||
size.cy = num[1];
|
||||
is16 = num[2] > 255;
|
||||
pixel_pos = stream.GetPos();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue