imagePtr[i*cols + j]
where i and j are the row/col coordinates. this isn't right, i can't remember how else to do it. i know it's something LIKE this, just not exactly what, and google isn't cooperating. do i need to use the memory locations?
Name:
Anonymous2009-04-21 8:32
What makes you think this isn't right?
Name:
Anonymous2009-04-21 8:33
It's right. Although a variable called imagePtr is pretty dumb.
Name:
Anonymous2009-04-21 8:36
>>2
it doesn't work. memory access violation >>3
mandated
it's actually a pointer, did i do something wrong there? do i need to dereference it or something?
Name:
Anonymous2009-04-21 8:37
entire sample
image_ptr negateImage(image_ptr imagePtr, int rows, int cols, int maxval)
{
int i,j;
image_ptr negateImage(image_ptr imagePtr[], int rows, int cols, int maxval)
Name:
Anonymous2009-04-21 9:20
So, you're either overflowing your buffer, or your buffer is not of the right size. ( it should be of size cols*rows )
You didn't provide us enough code for us to be able to fix your problem, but fear not, as you can probably solve it yourself. Get a debugger! Run the application and see where it breaks, or set a breakpoint on the faulty line(which you already know), set a breakpoint on where you alloc the picture buffer as well, after this, such simple errors become apparent, but if that wasn't enough, you may post the full code and maybe some kind anon will help you, but you really shouldn't rely on that!
Name:
Anonymous2009-04-21 9:22
>>4 it's actually a pointer, did i do something wrong there?
Yes, you gave it a dumb name. Although image_ptr imagePtr is even worse.
ITT we don't know the difference between rows and columns.
And between pointers and arrays, though that's not the issue here.
Name:
Anonymous2009-04-21 10:32
>>18
It seems you're the only one here who doesn't know the difference between rows and columns.
Name:
Anonymous2009-04-21 10:49
, /prog/, >>10 and >>16 had it right, sorta. it turns out img_ptr actually isn't just a 1D array as i had thought, or something. anyway
image_ptr negateImage(image_ptr imagePtr, int rows, int cols, int maxval)
{
int i,j;
unsigned char image[rows][cols];
for (i=0; i< rows; i++)
{
for (j=0; j< cols; j++)
{
image[i][j] = abs((imagePtr[i*cols + j]-maxval));;
}
}
imagePtr=(image_ptr) image;
}
works now. or at least it doesn't crash and it obviously messes with the image, only question now is how to actually get the inversion working. i had thought what i had would work (it's for .pgm files), but it isn't. i can figure it out i'm sure, thanks again!
>>23
Shhh. As long as he believes it, at least our problem is solved.
Name:
Anonymous2009-04-21 11:41
>>23
You talk a whole lot of shit without giving any information about the problem. Your posts are general enough that they could apply to anything.
Name:
Anonymous2009-04-21 12:04
>>17
Couldn't agree more, it's people like >>4 who perverted hungarian notation.
Name:
Anonymous2009-04-21 12:15
>>25
"My posts"? What are you, an EXPERT EXTRAPOLATOR?
The information given doesn't make more specific help possible. I'm just telling you that you're making the grave error of mistaking "it seems to work" for "it works". This just shows you're very inexperienced in C. If you want to act all pissed off at someone offering genuine help, be my guest. You've already failed at life.
----------
Posted from my iPhone
Name:
Anonymous2009-04-21 12:39
>>27
my apologies if i have misinterpreted your intentions (which i honestly still don't think i have), i'm used to elitist faggotry and disinformation/aggravation from /prog/. it is working as i expected (more or less), and i know what i was doing wrong (trying to use the image_pointer structure as an simple array of unsigned int/char when in reality writing to it is not possible as so).
>>31
This is getting silly, Mr.Troll.
I refuse to believe you are a genuine idiot you pretend to be.
Name:
Anonymous2009-04-21 21:03
>>32
what's wrong with it? the casting? it may be unnecessary, but is it not proper programming practice to do it anyway? go fuck yourself, this is the kind of stupid elitist circlejerking that i've come to expect from /prog/.
>>33 go fuck yourself, this is the kind of stupid elitist circlejerking that i've come to expect from /prog/.
I'll give you a hint.
Nobody wants to help you because you're doing stupid and boring shit a 5 year old would figure out. If you can't spend enough effort to read a book on basic C then that's your problem.
go fuck yourself, this is the kind of stupid elitist circlejerking that i've come to expect from /prog/.
Stop acting like a child.
Name:
Anonymous2009-04-22 11:24
OP here, I apologize for that outburst, I don't know what came over me. Now, if you'll just answer my question everything will be fine
OP here, I apologize for that outburst, I don't know what came over me. Now, if you'll just leave me to suck a billion cocks everything will be fine
Name:
Anonymous2009-04-22 11:50
Do it twice. Call this function with two different pictures. Then you'll understand that whatever you're doing is wrong and you're not getting any ``disinformation from (unspoilered)/prog/''. This is such a basic problem that having people who don't even know about it post on our nice textboard is very embarrassing. Please go away. We don't want your kind here. There is that stack overflow forum and many other web 2.0 websights full of people who just learned about this and want world to know.