rgb565 image data transform to OLED data

    技术2022-05-20  48

    {

    //input : uint32 *image_addr

     

            uint16 row,col,image_data_temp;         uint16 *image_addr_temp=NULL;         static uint16 dst_image[4][96] = {0x00};

     

    //one pixel is 16bit

            image_addr_temp = (uint16 *)image_addr;

     

    //clear dst_image buffers

            for(row=0;row<32;row++)         {             for(col=0;col<96;col++)             {                 dst_image[row/8][col] = 0x00;             }         }

     

    //fill dst_image buffers

            for(col=0;col<96;col++)         {             for(row=0;row<32;row++)             {                 image_addr_temp = (uint16 *)image_addr;                                 image_data_temp = *(image_addr_temp+96*row+col);                 if((((image_data_temp&0xf800)>>11) + /                     ((image_data_temp&0x07e0)>>5) + /                     (image_data_temp&0x001f))/3 > 20)//transform rgb565 to black-white image                 {                     dst_image[row/8][col] |= 1<<(row%8);                 }                 else                 {                     dst_image[row/8][col] |= 0<<(row%8);                 }             }         }

    //then the dst_image buffer is the OLED data that it needed

            image_addr = (uint32 *)&dst_image[0][0];

    }

     

     

    OLED data example as following:

                                          (Start Column)-->                                                 (End Col)

    --------------------------------|-------------------------------------------------------------|-----

                          |  |  |  |  |  |  |0|  |   <- LSB D0                                     |  |  |  |  |  |  |  |

                          |  |  |  |  |  |  |1|  |                                                       |  |  |  |  |  |  |  |

    PAGE(n)          |  |  |  |  |  |  |1|  |                                                        |  |  |  |  |  |  |  |

    (Start page)     |  |  |  |  |  |  |0|  |                                                        |  |  |  |  |  |  |  |

                          |  |  |  |  |  |  |0|  |                     ....................                    |  |  |  |  |  |  |  |

                          |  |  |  |  |  |  |1|  |                                                        |  |  |  |  |  |  |  |

                          |  |  |  |  |  |  |0|  |                                                        |  |  |  |  |  |  |  |

                          |  |  |  |  |  |  |1|  |   <- MSB D7                                     |  |  |  |  |  |  |  |

    -----------------------------------------------------------------------------------------------------

     

     


    最新回复(0)