It might sound stupid but i dont know...
BYTE *GetLine (int line ,BYTE surface,int stride)
{return (surface + stride * line);}
this little function is bugging me alot... the erro i get is this
''return'' : cannot convert from ''int'' to ''unsigned char *''
But fromt the normal tutorial it work fine.. man.. can someoen give me a tip.. sorry for the dummy question
Metal Typhoon
The function should probably read:
BYTE* Getline(int line, BYTE* surface, int stride)
{ return (surface + stride*line); }
If you can''t see this then you probably need
to read up on C. (and C++ if you want).
BYTE* Getline(int line, BYTE* surface, int stride)
{ return (surface + stride*line); }
If you can''t see this then you probably need
to read up on C. (and C++ if you want).
Hmmm, looks just like a piece of code I've been working on for my image class.
First off, your data types should be unsigned BYTE* (or unsigned char*). Also changing your function to this:
should make it work.
HTH
SysOp_1101
[edited by - SysOp_1101 on August 16, 2002 4:10:39 AM]
First off, your data types should be unsigned BYTE* (or unsigned char*). Also changing your function to this:
unsigned BYTE *GetLine (int line, unsigned BYTE* surface, int stride) { return (surface + (stride * line));}
should make it work.
HTH
SysOp_1101
[edited by - SysOp_1101 on August 16, 2002 4:10:39 AM]
quote:Original post by Metal Typhoon
BYTE *GetLine (int line ,BYTE surface,int stride)
{return (surface + stride * line);}
Metal Typhoon
Thats right - you will get that error because surface, I presume, should be a pointer:
BYTE *GetLine ( int Line, BYTE *pSurface, int Stride )
{
return ( pSurface + ( Stride * Line ) );
}
I believe that you should use "BYTE *surface" instead of "BYTE surface" in the function header.
Hope that works.
/John
Hope that works.
/John
Its all to do with "type casting" in C/C++, you can cast anything as anything but only if you tell it. What you need to is explicitly cast the result you are returning as a BYTE*, like this:
Then all should be happy
NightWraith
BYTE *GetLine (int line ,BYTE surface,int stride){return (BYTE*)(surface + stride * line);}
Then all should be happy
NightWraith
quote:Original post by SysOp_1101
Hmmm, looks just like a piece of code I''ve been working on for my image class.
First off, your data types should be unsigned BYTE* (or unsigned char*). Also changing your function to this:
unsigned BYTE *GetLine (int line, BYTE* surface, int stride) { return (surface + (stride * line));}
should make it work.
HTH
SysOp_1101
[edited by - SysOp_1101 on August 16, 2002 3:58:55 AM]
lol what a conincidence... this fucntion if to read a line pts toa bitmap.. well this i feed the function with the right parameters.. first of if i just compile without using the function the error shows..
Metal Typhoon
Consider this:
What you''re doing is this:
Furthermore, you don''t have BYTE *a, but BYTE* is a return type which is a pointer, not the same as (surface + stride * line), which is an integer. The compiler''s smart enough to check what you''re returning against what you''ve meant to return in a function. Remember, usually BYTE == char, so BYTE* == char*!
Simply change that return type to what you''re returning, or vice versa:
Hope this helps,
Crispy
What you''re doing is this:
BYTE *a;//assigning to a pointer address!a = surface + stride * line;
Furthermore, you don''t have BYTE *a, but BYTE* is a return type which is a pointer, not the same as (surface + stride * line), which is an integer. The compiler''s smart enough to check what you''re returning against what you''ve meant to return in a function. Remember, usually BYTE == char, so BYTE* == char*!
Simply change that return type to what you''re returning, or vice versa:
int GetLine (int line ,BYTE surface,int stride){return (surface + stride * line);}
Hope this helps,
Crispy
OMGGGGGGGGGG thx for all the replies... how i did not see that ? LOLSSSSSSS i''ve been programming for 10 hours straight O_o i think i need to sleep
Metal Typhoon
Metal Typhoon
Crispy,
What he is returning is a pointer to an unsigned char[] in memory, not an offset to plug between the brackets. The way that numerous posters suggested is not incorrect. The surface + stride * line simply tells the application to move the current byte pointer (stride * line) bytes ahead of the current pointer (thus setting it at the next line). You then use the returned pointer as the offset in memory to begin reading from or writing to.
What he is returning is a pointer to an unsigned char[] in memory, not an offset to plug between the brackets. The way that numerous posters suggested is not incorrect. The surface + stride * line simply tells the application to move the current byte pointer (stride * line) bytes ahead of the current pointer (thus setting it at the next line). You then use the returned pointer as the offset in memory to begin reading from or writing to.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement