C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TFF

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
joel
Guest





PostPosted: Tue Mar 15, 2005 9:04 pm    Post subject: TFF Reply with quote





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! ]
Back to top
Victor Bazarov
Guest





PostPosted: Wed Mar 16, 2005 9:07 am    Post subject: Re: TFF Reply with quote



joel wrote:
Quote:
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?

Quote:
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?

Quote:
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! ]

Back to top
Jay Nabonne
Guest





PostPosted: Thu Mar 17, 2005 2:08 am    Post subject: Re: TFF Reply with quote



On Tue, 15 Mar 2005 16:04:29 -0500, joel wrote:

Quote:


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! ]

Back to top
Ron Natalie
Guest





PostPosted: Thu Mar 17, 2005 4:00 pm    Post subject: Re: TFF Reply with quote

joel wrote:

Quote:
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! ]


Back to top
Ron Natalie
Guest





PostPosted: Thu Mar 17, 2005 4:01 pm    Post subject: Re: TFF Reply with quote

joel wrote:

Quote:
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! ]


Back to top
Allan W
Guest





PostPosted: Thu Mar 17, 2005 4:03 pm    Post subject: Re: TFF Reply with quote

joel wrote:
Quote:
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! ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.