-
-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
image_buffer error in version 1.1.5 #388
Comments
I uploaded the normal xlsx from version 1.1.3 above. Please find the abnormal xlsx without the intended image generated via version 1.1.5 below. My OS info: |
Could you add this this debug code to your example and run it on the system/version where is doesn't work as expected. int main()
{
png_t *png = calloc(1, sizeof(png_t));
cairo_surface_t *sf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT);
cairo_t *cr = cairo_create(sf);
cairo_set_antialias(cr, CAIRO_ANTIALIAS_BEST);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, 200.0);
cairo_move_to(cr, WIDTH / 10, HEIGHT / 1.25);
cairo_show_text(cr, "FOOBAR");
cairo_surface_write_to_png_stream(sf, png_write_callback, png);
cairo_destroy(cr);
cairo_surface_destroy(sf);
// Add this to your code.
printf("Version = %s\n", lxw_version());
printf("Length = %zu\n", png->length);
printf("Data = %c%c%c\n", png->data[1], png->data[2], png->data[3]);
lxw_workbook *wb = workbook_new("foo.xlsx");
lxw_worksheet *ws = workbook_add_worksheet(wb, "bar");
worksheet_insert_image_buffer_opt(ws, 0, 0, png->data, png->length, &img_opt);
lxw_error e = workbook_close(wb);
if (e) {
fprintf(stderr, "Error closing workbook, %d = %s\n", e, lxw_strerror(e));
return e;
}
free((char *)png->data);
free(png);
return 0;
} You should get ouput like this:
|
Here is what I get:
and for v1.1.3, no warning and normal xlsx:
|
Thanks. In the 1.1.5 example are you using |
|
@mohd-akram could you have a look at this issue. I can't reproduce it on the mac or Ubuntu systems that I have but I suspect that the issue may be the https://github.com/jmcnamara/libxlsxwriter/blob/main/src/worksheet.c#L10396 That |
This is a bit of a strange issue. The image buffer code wasn't really touched since it already used buffers. The CentOS version is quite old and I suspect it might be a glibc issue. Can you print what's the glibc version ( |
Tried this in a @jmcnamara Seems to be the bug mentioned here under notes. Changing @slw287r Try making that change and see if it works for you. |
@mohd-akram Thanks. Nice detective work. |
|
Fix/workaround for Centos 7 fmemopen() issue. See #388 for details.
@slw287r Thanks for the test/report. Fixed on main. Closing. |
I encountered the follow warning and failed to insert cairo picture from memory on CentOS Linux:
I switched on and off of
USE_MEM_FILE
and got the same error.It worked on macOS for version 1.1.5 and CentOS Linux for version 1.1.3 (1.1.4 not tested).
My demo scripts (a.c):
Compile and run:
Normal foo.xlsx
The text was updated successfully, but these errors were encountered: