Read width & Height of jpeg file
-
ok...one thing I absolutely hate is how .NET throws this for the code you provided:
Error 6 Control cannot fall through from one case label ('case 207:') to another D:\XNA\Files\Projects\Terrain\TerrainWIP\Terrain\Terrain\JPEG.cs 61 58 Terrain
Was your code C#.NET code? How were you able to force it to fall through the cases?
Welcome my son...Welcome..to the Machine
Hi, I did not actually run the code I posted, but it seems OK to me. cases should be empty (that is how you can list cases to share all their code) or end on a change-of-flow (break, return, throw...) Did you somehow change the code and violate the above ? I guess you did, since 207 is 0xCF and that one ended on return... :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
Hi, I did not actually run the code I posted, but it seems OK to me. cases should be empty (that is how you can list cases to share all their code) or end on a change-of-flow (break, return, throw...) Did you somehow change the code and violate the above ? I guess you did, since 207 is 0xCF and that one ended on return... :)
Luc Pattyn [My Articles] [Forum Guidelines]
no...identical code. Cut & pasted it. .NET's saying that it won't let a case fall through to execute code from another case. ...OxCF was the case that actually had code to execute. ..the others fell through to 0xCF.
Welcome my son...Welcome..to the Machine
-
no...identical code. Cut & pasted it. .NET's saying that it won't let a case fall through to execute code from another case. ...OxCF was the case that actually had code to execute. ..the others fell through to 0xCF.
Welcome my son...Welcome..to the Machine
-
Hi, I did not actually run the code I posted, but it seems OK to me. cases should be empty (that is how you can list cases to share all their code) or end on a change-of-flow (break, return, throw...) Did you somehow change the code and violate the above ? I guess you did, since 207 is 0xCF and that one ended on return... :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
...even if you have a return, it still wants you to have the break after it
Welcome my son...Welcome..to the Machine
My Visual Studio C# 2005 Express Edition is happy without a break after a return, and produces a warning "unreachable code" if there is such a break; both seem logical to me. Are you using an different, maybe older, IDE ? :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
...even if you have a return, it still wants you to have the break after it
Welcome my son...Welcome..to the Machine
I have now tried with Visual Studio 7.1 and it behaves identically: return without break is fine, return+break gives warning. :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
I have now tried with Visual Studio 7.1 and it behaves identically: return without break is fine, return+break gives warning. :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
I have now tried with Visual Studio 7.1 and it behaves identically: return without break is fine, return+break gives warning. :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
Well, that's a small mystery, one we will not solve easily, but I guess you can live with it ? Anyway, I trust you got the code up and running... :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
Well, that's a small mystery, one we will not solve easily, but I guess you can live with it ? Anyway, I trust you got the code up and running... :)
Luc Pattyn [My Articles] [Forum Guidelines]
yeah, I can live with it...I'm having a new problem though:
if (code != 0xFF) throw new ApplicationException(
"Unexpected value in file " + filename);throws ....code equaled 216. What exactly is that check for? Do you know what the value of 216 means in this context? The first pass through, "code" was 255, then the next value was ...[Fixed it before I finished the post] ...Since the only thing I'm wanting to do is determine the width & height of the file, I just place a check for them inside the code check so it's now looking for
if(code != 0xFF && width == 0 && height == 0)
{
throw;
}so now it will only throw if the width & height haven't been set yet..if they've been set, then I simply break when the code is not 0xFF. ...Is 0xFF like a key value for the header or something like that?
Welcome my son...Welcome..to the Machine
-
yeah, I can live with it...I'm having a new problem though:
if (code != 0xFF) throw new ApplicationException(
"Unexpected value in file " + filename);throws ....code equaled 216. What exactly is that check for? Do you know what the value of 216 means in this context? The first pass through, "code" was 255, then the next value was ...[Fixed it before I finished the post] ...Since the only thing I'm wanting to do is determine the width & height of the file, I just place a check for them inside the code check so it's now looking for
if(code != 0xFF && width == 0 && height == 0)
{
throw;
}so now it will only throw if the width & height haven't been set yet..if they've been set, then I simply break when the code is not 0xFF. ...Is 0xFF like a key value for the header or something like that?
Welcome my son...Welcome..to the Machine
Hi, the FF-check is for protection (I want the code to fail on something that isnt a JPEG at all!); so far all valid packets have a two-byte code that looks like 0xFFXX, and my code did return as soon as size was seen; you should not continue scanning the file after that ! (typically the size info is in the first few % of the file, and the scanner as is probably is unable to handle everything that might follow it). If there is any more trouble, please publish the entire method again. If you think there are some valid JPEG files that my code does not handle well, then mail me one or two of them. :)
Luc Pattyn [My Articles] [Forum Guidelines]
-
Hi, the FF-check is for protection (I want the code to fail on something that isnt a JPEG at all!); so far all valid packets have a two-byte code that looks like 0xFFXX, and my code did return as soon as size was seen; you should not continue scanning the file after that ! (typically the size info is in the first few % of the file, and the scanner as is probably is unable to handle everything that might follow it). If there is any more trouble, please publish the entire method again. If you think there are some valid JPEG files that my code does not handle well, then mail me one or two of them. :)
Luc Pattyn [My Articles] [Forum Guidelines]
yeah...I didn't remove the return from your case code, but it was definitely not hitting it, which is extremely odd. ...It was definitely continuing past the point that it determined the width & height, which is why doing the assignment checks for width & height automagically switched the block. I'll look into what I did when I get home from work...and I'll post a screenshot of what I got completed.
Welcome my son...Welcome..to the Machine