// image_buffer is type unsigned char* of RGB image
// This seems to be wrong:
image_buffer[0]=(unsignedchar)(H/255)*100;
image_buffer[1]=(unsignedchar)(S*100);
image_buffer[3]=(unsignedchar) V;
//
// result: (unsigned char *) 0x6f0020 ""
// Nothing was added
// Normally I would do something like:
// memcpy(image_buffer, rows_buffer[0], raw_size);
/* But because of convertion from RGB to HSV I need to join the 3 components to 3 bytes string and add it to image_buffer. */
The commands will be inside loop of 1200 cycles. I found that if I run any function inside such loop it will make the reading+conversion time 25% slower.
So what is wrong on my try to copy value? I know image_buffer i pointer but does image_buffer[0]= really assign value? Also does (unsigned char *) really do the conversion correct? Passing of (unsigned char)(H/255)*100 into Watch will give value 0.
Passing of (unsigned char)(H/255)*100 into Watch will give value 0.
What is the type of H? If it is integral type, you are using integer division with all implications of that.
I suggest you to reorder multiplication and dicision as H*100/255.
does image_buffer[0]= really assign value?
Yes, as any C++ tutorial will tell you.
What exactly is your problem? What do you intend to do?
The type of H,S,V are floats. H value at this moment is 88.421051, but maximum value can be 360
You can study this function: http://paste.ofcode.org/a4N5QCrzwDjw2HFy2ESACs
it reads jpeg file in RGB and during reading line by line it should convert to HSV and save to image_buffer. It was a purpose not to run function RGB2HSV directly because it slows down program by 25%.
Is now clear what I am trying to do? The function code should explain it.
But I don't ask you to write complete function for me, I need to solve just this part small part: save the H,S,V as 3 bytes string into buffer. I don't ask for complete solution, so respect it.
(unsignedchar)(H/255) will transform number into integer. If it is less than 1, it will be 0. I think there should be another pair of parentheses around whole expression.