Hello,
I will appreciate it if you guys could give insight into my problem.
I'm working a code, which does conversion on TIFF file to
convert it to some custom file format.
However, for some tiff files it stops in the middle below loop:
1 for (int i = 0; i < numColors; ++i, pPal += offset) {
2 pPal->rgbRed = pPal->rgbGreen = pPal->rgbBlue =
(BYTE)(i * step);
3 pPal->rgbReserved = 0;
}
It is only balck and white so numColors = 2
pPal is a pointer to a struct as:
typedef struct tagRGBQ {
BYTE rgbBlue;
BYTE rgbGreen;
BYTE rgbRed;
BYTE rgbReserved;
} RGBQUAD;
After debuggin I found program flow stops on line 1 and 2. I thought it
would be pointer (pPal) but no error found.
Any comment?
Thanks in advance,
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
ramsin.savra (18)
|
3/15/2005 9:04:29 PM |
|
joel wrote:
> I will appreciate it if you guys could give insight into my problem.
> I'm working a code, which does conversion on TIFF file to
> convert it to some custom file format.
>
> However, for some tiff files it stops in the middle below loop:
>
> 1 for (int i = 0; i < numColors; ++i, pPal += offset) {
Are you sure that
pPal += offset
does not take you beyond the array to which pPal actually points?
I can imagine that if you have
RGBQUAD quad[1], *pPal = quad;
you can easily have a problem. What's pPal initialised to?
> 2 pPal->rgbRed = pPal->rgbGreen = pPal->rgbBlue =
> (BYTE)(i * step);
> 3 pPal->rgbReserved = 0;
> }
>
> It is only balck and white so numColors = 2
> pPal is a pointer to a struct as:
>
> typedef struct tagRGBQ {
> BYTE rgbBlue;
> BYTE rgbGreen;
> BYTE rgbRed;
> BYTE rgbReserved;
> } RGBQUAD;
>
> After debuggin I found program flow stops on line 1 and 2. I thought it
> would be pointer (pPal) but no error found.
What error were you looking for?
> Any comment?
Post more code.
V
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Victor
|
3/16/2005 9:07:01 AM
|
|
On Tue, 15 Mar 2005 16:04:29 -0500, joel wrote:
>
>
> Hello,
>
> I will appreciate it if you guys could give insight into my problem.
> I'm working a code, which does conversion on TIFF file to
> convert it to some custom file format.
>
> However, for some tiff files it stops in the middle below loop:
>
> 1 for (int i = 0; i < numColors; ++i, pPal += offset) {
> 2 pPal->rgbRed = pPal->rgbGreen = pPal->rgbBlue =
> (BYTE)(i * step);
> 3 pPal->rgbReserved = 0;
> }
What is "offset"? Remember that it will add offset*sizeof(RGBQUAD) to the
pointer value.
- Jay
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Jay
|
3/17/2005 2:08:01 AM
|
|
joel wrote:
> However, for some tiff files it stops in the middle below loop:
>
> 1 for (int i = 0; i < numColors; ++i, pPal += offset) {
> 2 pPal->rgbRed = pPal->rgbGreen = pPal->rgbBlue =
> (BYTE)(i * step);
> 3 pPal->rgbReserved = 0;
> }
>
What is offset? What does pPal point to?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Ron
|
3/17/2005 4:00:50 PM
|
|
joel wrote:
> 1 for (int i = 0; i < numColors; ++i, pPal += offset) {
> 2 pPal->rgbRed = pPal->rgbGreen = pPal->rgbBlue =
> (BYTE)(i * step);
> 3 pPal->rgbReserved = 0;
> }
>
> It is only balck and white so numColors = 2
> pPal is a pointer to a struct as:
Pointer to one struct? You need at least two. What is offset
anyhow? You do know that you only need to increment a pointer
to get to the next one in an array regardless of what size it is.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Ron
|
3/17/2005 4:01:13 PM
|
|
joel wrote:
> for some tiff files it stops in the middle below loop:
>
> 1 for (int i = 0; i < numColors; ++i, pPal += offset) {
> 2 pPal->rgbRed = pPal->rgbGreen = pPal->rgbBlue =
> (BYTE)(i * step);
> 3 pPal->rgbReserved = 0;
> }
>
> pPal is a pointer to a struct as:
>
> typedef struct tagRGBQ {
> BYTE rgbBlue;
> BYTE rgbGreen;
> BYTE rgbRed;
> BYTE rgbReserved;
> } RGBQUAD;
>
> After debuggin I found program flow stops on line 1 and 2. I thought
it
> would be pointer (pPal) but no error found.
> Any comment?
First rule of describing symptoms: nothing ever just stops. You need to
describe more precisely what you mean. I've seen "the program stops"
used to mean anything from "it displays an error message which I didn't
bother to write down," to "the computer asks me a question which I
didn't know how to answer but I didn't bother writing it down either,"
to "the computer suddenly starts re-booting," to "the program completes
normally." This is a programming newsgroup; try to be more specific.
Since you can use a debugger, can tell us more about the program state.
Are you saying that at some point it reaches line 2, and then never
makes it to line 3? Or are you saying that it reaches line 2 over and
over again, but never seems to exit the loop?
If the program hangs at line 2, it is almost certainly a memory
overwrite -- surprising your debugger can't say so. pPal no longer
points into the middle of your array of RGBQUADs.
If the program never exits the loop, take a look at the values modified
in the loop. If i is incrementing but pPal isn't, it means that the
value of offset has somehow changed to 0 -- again, possibly a memory
overwrite. Also, you're going to have to look at numColors to see why
that didn't exit the loop. If i isn't incrementing either... well, I
don't know what could cause that.
If this hasn't solved your problem, would you please re-post your
question with more detail?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Allan
|
3/17/2005 4:03:13 PM
|
|
|
5 Replies
87 Views
(page loaded in 0.354 seconds)
Similiar Articles: FFT Not Defined for Double - comp.soft-sys.matlabUndefined function or method 'ftt' for input arguments of type 'double'. There is only one among eight is good TFF, FTT, FTF, FFT, TFT, TTF, FFF, TTT Bruno Input argument is undefined - comp.soft-sys.matlab... Defined for Double - comp.soft-sys.matlab Undefined function or method 'ftt' for input arguments of type >> 'double'. >> >> There is only one among eight is good >> TFF ... Texas Fishing Forum - discussion, tournaments, guides, events ...Texas Fishing Forum, fishing discussion, news, tournaments, guides, outfitters, lodging, saltwater and fishing Turkish Football Federation Official Web Site Home Page TFFUEFA U19 Women's European Championship, which was held in Antalya, Turkey was finished with Sweden-Spain final game at tonight. After the ennd of extra-time Sweden ... 7/23/2012 2:50:48 AM
|