View Single Post
Old 07-12-2016, 05:42 AM   #6
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

Use this code to draw to LICE
Code:
inline void Cairo_Draw_To_Lice(IGraphics *pGraphics, cairo_surface_t *surf, int x, int y, int width, int height)
{
    cairo_surface_flush(surf);
    unsigned int *data = (unsigned int*)cairo_image_surface_get_data(surf);
    IRECT rect = IRECT(x,y,width,height);

#ifdef _WIN32
    
    LICE_WrapperBitmap WrapperBitmap = LICE_WrapperBitmap(data, width, height, width, false);
    IBitmap result(&WrapperBitmap, width, height);
    pGraphics->DrawBitmap(&result, &rect);
    
#elif defined(__APPLE__)
    
        for(int i = 0; i < (width * height); ++i)
    {
        // argb to bgra   aaaaaaaa rrrrrrrr gggggggg bbbbbbbb    to    bbbbbbbb gggggggg rrrrrrrr aaaaaaaa
        
        *data = (*data >> 24) | (*data << 24) | ((*data &0xFF0000) >> 8) | ((*data &0xFF00) << 8);
        //       ___a           b__a             b_ra                           bgra
        
        
        data = data + 1;
    }
    data = data - (width * height);
    LICE_WrapperBitmap WrapperBitmap = LICE_WrapperBitmap(data, width, height, width, false);
    IBitmap result(&WrapperBitmap, width, height);
    pGraphics->DrawBitmap(&result, &rect);
    
#endif
}
Youlean is offline   Reply With Quote