I am using Cairo to render an image, and I have an issue that the canvas always drawing with blank (no image was drawn). Please refer my code below:
int width, height, channels;
unsigned char* data = stbi_load(imagePath.c_str(), &width, &height, &channels, STBI_rgb_alpha);
int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
this->imageSource = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, width, height, stride);
free(data);
But if I render png file using currently supported function from Cairo, it's working well, my code below:
this->imageSource = cairo_image_surface_create_from_png(imagePath.c_str());