From: igor <igo...@pu...> - 2004-01-13 22:51:32
|
Hello I'm sorry for bothering you again but I want to know! Thanks to Miguel to his reply on my post: "help about osd image loading - drawing". I have tried by myself to find out how to load an bitmap image from a file and display it over a stream but i was unsuccessful! I need more explanations how to use the xine_osd_draw_bitmat , xine_osd_set_palette. I have already read the xine hacker guide few times but still i don't get it! So i have few questins about it! 1) Is this a correct way to load a bitmap image into memory: // global defined variables uint8_t *bitmap; //bitmap image to use with xine osd api int main() { struct stat file; //file description structure stat("image.bmp",&file); // allocate the memory equal to the file size bitmap = (uint8_t *) malloc(file.st_size); // or is this way better? bitmap[file.st_size]; FILE *stream; stream = fopen("image.bmp","r"); // is this a way to load a bitmap? fread(bitmap,1,file.st_size,stream); //or is this the right way? int c; long i = 0; do { c = getc(stream); bitmap[i] = (uint8_t) c; i++; } while(c != EOF); fclose(stream); return 0; } Do i have to remove file(image) headers manually so that the data can be used in the xine_osd_draw_bitmap function or the function handles the image data automaticly? 2) How do i get the color palette for the stored image? Which type of color palette is used in the file, if is RGB do i have to convert it manually into yuv or is there any algorithm which does the conversion? If i have to do it manually what is the correct formula to convert RGB to YUV so that image can be displayed in xine with the osd? 3) Now questions about the xine_osd_set_palette(uint32_t *color,uint_8 *trans); function! I found that two pointers were defined in the xine osd api: uint32_t *color; and uint8_t *trans; If I'm not wrong color is the color value and trans means transparency value! Suppose i have loaded an image with 2 colors (red and white). Do i have to fill the color array only with 2 values to display the image like here below? color[0] = white; //i don't know the yuv value for white color[1] = red; //the same as for white trans[0] = 15; trans[1] = 15; If I want that only red color pixels to be displayed is it enough to set the trans[0] value to 0? 4) Questions about xine_osd_draw_bitmap( uint8_t *bitmap, int x, int y, int width,int height,uint8_t *palette_map);. The last argument is palette_map which is of uint8_t type. How do i create a palette map? Isn't it enough if I use xine_osd_set_palette function? Can I send a NULL value for the last argument? Thank you for your help and your patience. Have a nice day Bye. |