« first day (177 days earlier)      last day (4768 days later) » 

3:09 AM
hey tina :)
 
3:39 AM
if ptr2 is a BYTE**, don't you need another level of indirection to compare it with rndval, or to do += rndval..?
I don't see how that can work?
even if rndvalue is a BYTE, you still have a missing indirection (because ptr2[k] gives you a BYTE*, not a BYTE
right?
which would explain your compiler error
you want to compare a float to a pointer?
yes but you do ptr2[k] <= rndval
rndval is a float
ptr2[k] is a BYTE*
a pointer to BYTE
I think you need to ask yourself the question of you really intend to compare a pointer to a float
how is that meaningful?
then you need to cast your float to a BYTE*
but ptr2 values are pointers
why is ptr2 a BYTE**?
why isn't it a BYTE*?
I don't think so
but I think something is pretty wrong if you're comparing pointers to floats and storing the sum of the two in a byte..
unless you want to work with the value of the byte at ptr2[k]
in which case you could cast that to a BYTE
ok
in that case, where you use ptr2[k] now, use (BYTE)ptr2[k]
well..
you could just do BYTE* ptr2 = (BYTE*)dib2.GetPtr();
but I don't know if that makes any sense
what's dib2?
ok, so ptr2 is a two-dimensional array of bytes?
@tina not meaningfully
but you can always cast the float to whatever you want to compare it to
BYTE*, in your original code
the point is that it isn't meaningful, though: floats and pointers don't have much in common
whether you should compare a pointer to an integer is debatable
how about ((BYTE*)ptr2)[k]
well, it gets the kth byte beyond the first byte ptr2 points to
as ptr2 is a two-dimensional array representing an image
it would presumably get the kth pixel
if it's a grayscale image..
or a plane in an RGB image
what are you trying to do? binarize the image?
ok, then I think ((BYTE*)ptr2)[k] should be ok for that..
yeah
I gotta go, though
good luck :)
both places
because sizeof(BYTE*) != sizeof(BYTE)
yes: in the comparison and in the assignment
where you use ptr2[k]
good luck - gotta go
you're welcome - hope it works out :)
 
4:49 AM
What can I do for you @tina?
can I know the line please?
Error 1 at what line?
 
5:34 AM
Well ptr2 is a BYTE **
So when you do ptr2[k] it gives you a BYTE*
*(ptr2[k]) would give you a BYTE, but I don't know if it makes any sense in your context
alright but BYTE* isn't a float, it's a pointer
I don't know if BYTE can be converted to double, but what I know is that BYTE* (pointer to BYTE) compared with a double won't give you expected result
You do know that a variable of type BYTE is different from a variable of type BYTE* (pointer to BYTE) right?
ok
if you do ptr2[k] < rndval , what are the types of the variables?
ptr2[k] and rndval
ok
ok, so what do you want to do, compare the address of the BYTE or the value of the BYTE?
ok
One way to get a value out of a pointer, is by dereferencing it.
*(ptr2[k]) < mdval
ptr2[k] is a BYTE*
*(ptr2[k]) is a BYTE
but wait
it seems that in your code ptr2 is an array of array, am I right?
 
5:56 AM
Does C++ support closure?
 
@Chacha102 They call it lambda, and C++0x support it
Ok, well what was your intention, when you were doing ptr2[k] <rndvalue ? to round every values of your table?
Does it answer your question @Chacha102 ?
@tina well you should probably do an other double for loop to loop throught every element of your array
 
@Drahakar Yes
 
unless your double array only countains a total of 256 elements, if I look at your code.
May I know why you were interested in C++ Lambda @Chacha102?
@tina of course, but I suppose you had a logical reason to put them in a by-dimentionnal array, didn't you?
No I mean, what is your 2d array trying to represent. You usually want to reprensent things with your code. So was a 2d array the best abstraction or would a 1d array be a better one?
 
@Drahakar I felt like coming into a room about a language I know nothing about and hopefully asking a very stupid question in hopes of getting a laugh out of someone. But you have heroically stopped my comedic efforts right in their rather large-shoed tracks
 
:) What language are you more familliar with @Chacha102?
 
6:09 AM
PHP, Java, Javascript, Ruby, Python, English ... although that last one is believed to be a little bit buggy..
It is prone to lots of interpreter errors..
 
@tina you can can easilly round up values within a 2D array, but you need to go throught all the values with a double for loop.
for(int i=0; i< MAX_VAL; i++){
for (int j=0; j<MAX_VAL2; j++) {
if(ptr2[i][j]<rndval) {
LUT2[i][j]=(BYTE)ptr2[i][j];
}else{
LUT2[i][j]=((BYTE*)ptr2)[i][j]+rndval;
}
@Chacha102 context sensitive language are bad, really bad.
@tina practice makes ferpect
what are your errors?
what line is this?
which one?
let me guess the if?
@tina 203 doesn't tell me what line it is :)
but from what I can see
ptr2 is a BYTE**
ptr2[j] is a BYTE*
ptr2[j][i] is a BYTE
So you are trying to dereference a value, which of course is not an 'array or pointer type'
yes
arrays are pointer
when you do ptr2[i] it means ptr2 + i
get the pointer adress of ptr2 and move of (i * sizeof(BYTE))
so when you do this you get at the position ptr2 + (i*sizeof(BYTE)) in memory which point to a value of a certain type
ptr2 is of type BYTE**, so the value, once we've moved, (you can see a memory move as a dereferenciation), is of type BYTE*
so by doing ptr2[j][i] you are dereferencing ptr2 twice
This tutorial seems to be pretty complete on pointers arithmetics and array, you should take a look at it.
Keep in mind that this is C code
but the pointer arithmetics stays the same
And it will help you to understand pointer a little bit more :)
This one seems pretty interesting too
And the first lines explains what is going on with multi-dimentional array
Time to sleep here
Good night all / Bonne nuit.
 
7:06 AM
40 mins ago, by Drahakar
arrays are pointer
@Drahakar No, arrays are not pointers!
6
20
Q: How do I use arrays in C++?

FredOverflowC++ inherited arrays from C where they are used virtually everywhere. C++ provides abstractions that are easier to use and less error-prone (std::vector<T> since C++98 and std::array<T, n> since C++0x), so the need for arrays does not arise quite as often as it does in C. However, whe...

 
Als
@tina: Abundance of good folks here :)
The "enable Desktop notification" link in the bottom right hand corner...does nothing for me in Google Chrome....What does it supposedly do?
 
7:29 AM
@Als it should notify you with a message bubble when you get a message directed at you with the @address symbol
@tina hello
 
7:54 AM
@Model In fact, friendship is such an important concept that C++ has its own keyword for it ;)
4
Why does it say "@Model" when I'm clearly addressing tina?
 
@FredOverflow donno, bug or feature?
 
@Model Checking if tina->Model substitution happens for me.
Yes, it does. And then it showed tina for a small time before replacing it by Model.
@FredOverflow Checking an hypothesis with Fred...
 

« first day (177 days earlier)      last day (4768 days later) »