What I'm trying to do is to access the elements of an array that represent an image in RGB565 (16 bits) and trying to convert it to RGB888 (24 bits).
The array is as follows:
Code from the .h file
UG_BMP logo_config_placas;
Code from the .c file
UG_BMP logo_config_placas = {
(void*)&logo_config_placas_i,
245 ,
231,
BMP_BPP_16,
BMP_RGB565 };
const UG_U16 logo_config_placas_i[] = {
0x0,0x0,0x0,0x0,0x0,0x0,0x0 ... }
I know that these numbers shown are just zero (this corner is black), but further on there are other colors.
What I'm trying to do is to get the rgb565 color from each element of the array and convert it to rgb888 so i can print it on a display. The numbers 231 and 245 are because the size of the image (245 px width, 231 px height).
for (int j = 0; j < 231; j++) {
for (int i = 0; i < 245; i++) {
UG_COLOR rgb16 = (UG_COLOR)*(logo_config_placas.p + i + (245 * j));
UG_COLOR rgb24 = ((((rgb16 & 0x0000F800) << 8) | ((rgb16 & 0x000007E0) << 5)) | ((rgb16 & 0x0000001F) << 3)) & 0x00FFFFFF;
Print_Pixel(2 + i, 38 + j, rgb24);
}
}
I just keep getting warnings and errors like:
Error: invaid use of void expression
Warning: deferencing 'void*' pointer
I'm sure the error is in the line with the rgb16 variable, but i can't figure how to call the element of the array properly.
I guess logo_config_placas.p is the first element of your struct. If that's true then that's because you're doing:
logo_config_placas.p
which means you're doing .p
on a void *
(based on your case in logo_config_placas
)
Minimal simulation of your problem:
struct A
{
int a;
} sa;
struct B
{
void *a;
} sb = {(void *)&sa};
int main()
{
int c = (int) *(sb.a);
}
which results in:
a.c: In function ‘main’:
a.c:15:16: warning: dereferencing ‘void *’ pointer
int c = (int) *(sb.a);
^~~~~~~
a.c:15:10: error: invalid use of void expression
int c = (int) *(sb.a);
which is self-explanatory.
You will need to first cast .p
to whatever you're using it as.
User contributions licensed under CC BY-SA 3.0