diff options
| author | Yuuki Harano | 2020-05-26 20:22:20 +0900 |
|---|---|---|
| committer | Jeff Walsh | 2020-11-24 12:24:40 +1100 |
| commit | 25cf59203e3e2787f8085462989ecaabb6292f75 (patch) | |
| tree | e0f7c0e127713d0ca65c793ee894ec2aa06e3952 /src | |
| parent | 3b161dd3c8a9440024bacb7fe26cdb7eff289361 (diff) | |
| download | emacs-25cf59203e3e2787f8085462989ecaabb6292f75.tar.gz emacs-25cf59203e3e2787f8085462989ecaabb6292f75.zip | |
Change coding style
* src/image.c (image_create_pattern_from_pixbuf): Change coding style
(image_create_bitmap_from_data): Change coding style
(image_create_bitmap_from_file): Change coding style
Diffstat (limited to 'src')
| -rw-r--r-- | src/image.c | 87 |
1 files changed, 49 insertions, 38 deletions
diff --git a/src/image.c b/src/image.c index c7ae3b99447..e2d142ed32e 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -402,14 +402,15 @@ image_reference_bitmap (struct frame *f, ptrdiff_t id) | |||
| 402 | 402 | ||
| 403 | #ifdef HAVE_PGTK | 403 | #ifdef HAVE_PGTK |
| 404 | static cairo_pattern_t * | 404 | static cairo_pattern_t * |
| 405 | image_create_pattern_from_pixbuf (struct frame *f, GdkPixbuf *pixbuf) | 405 | image_create_pattern_from_pixbuf (struct frame *f, GdkPixbuf * pixbuf) |
| 406 | { | 406 | { |
| 407 | GdkPixbuf *pb = gdk_pixbuf_add_alpha (pixbuf, TRUE, 255, 255, 255); | 407 | GdkPixbuf *pb = gdk_pixbuf_add_alpha (pixbuf, TRUE, 255, 255, 255); |
| 408 | cairo_surface_t *surface = cairo_surface_create_similar_image (cairo_get_target( | 408 | cairo_surface_t *surface = |
| 409 | f->output_data.pgtk->cr_context), | 409 | cairo_surface_create_similar_image (cairo_get_target |
| 410 | CAIRO_FORMAT_A1, | 410 | (f->output_data.pgtk->cr_context), |
| 411 | gdk_pixbuf_get_width (pb), | 411 | CAIRO_FORMAT_A1, |
| 412 | gdk_pixbuf_get_height (pb)); | 412 | gdk_pixbuf_get_width (pb), |
| 413 | gdk_pixbuf_get_height (pb)); | ||
| 413 | 414 | ||
| 414 | cairo_t *cr = cairo_create (surface); | 415 | cairo_t *cr = cairo_create (surface); |
| 415 | gdk_cairo_set_source_pixbuf (cr, pb, 0, 0); | 416 | gdk_cairo_set_source_pixbuf (cr, pb, 0, 0); |
| @@ -462,38 +463,45 @@ image_create_bitmap_from_data (struct frame *f, char *bits, | |||
| 462 | #endif | 463 | #endif |
| 463 | 464 | ||
| 464 | #ifdef HAVE_PGTK | 465 | #ifdef HAVE_PGTK |
| 465 | GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, | 466 | GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, |
| 466 | FALSE, | 467 | FALSE, |
| 467 | 8, | 468 | 8, |
| 468 | width, | 469 | width, |
| 469 | height); | 470 | height); |
| 470 | { | 471 | { |
| 471 | char *sp = bits; | 472 | char *sp = bits; |
| 472 | int mask = 0x01; | 473 | int mask = 0x01; |
| 473 | unsigned char *buf = gdk_pixbuf_get_pixels (pixbuf); | 474 | unsigned char *buf = gdk_pixbuf_get_pixels (pixbuf); |
| 474 | int rowstride = gdk_pixbuf_get_rowstride (pixbuf); | 475 | int rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
| 475 | for (int y = 0; y < height; y++) { | 476 | for (int y = 0; y < height; y++) |
| 476 | unsigned char *dp = buf + rowstride * y; | 477 | { |
| 477 | for (int x = 0; x < width; x++) { | 478 | unsigned char *dp = buf + rowstride * y; |
| 478 | if (*sp & mask) { | 479 | for (int x = 0; x < width; x++) |
| 479 | *dp++ = 0xff; | 480 | { |
| 480 | *dp++ = 0xff; | 481 | if (*sp & mask) |
| 481 | *dp++ = 0xff; | 482 | { |
| 482 | } else { | 483 | *dp++ = 0xff; |
| 483 | *dp++ = 0x00; | 484 | *dp++ = 0xff; |
| 484 | *dp++ = 0x00; | 485 | *dp++ = 0xff; |
| 485 | *dp++ = 0x00; | 486 | } |
| 486 | } | 487 | else |
| 487 | if ((mask <<= 1) >= 0x100) { | 488 | { |
| 488 | mask = 0x01; | 489 | *dp++ = 0x00; |
| 489 | sp++; | 490 | *dp++ = 0x00; |
| 490 | } | 491 | *dp++ = 0x00; |
| 491 | } | 492 | } |
| 492 | if (mask != 0x01) { | 493 | if ((mask <<= 1) >= 0x100) |
| 493 | mask = 0x01; | 494 | { |
| 494 | sp++; | 495 | mask = 0x01; |
| 496 | sp++; | ||
| 497 | } | ||
| 498 | } | ||
| 499 | if (mask != 0x01) | ||
| 500 | { | ||
| 501 | mask = 0x01; | ||
| 502 | sp++; | ||
| 503 | } | ||
| 495 | } | 504 | } |
| 496 | } | ||
| 497 | } | 505 | } |
| 498 | #endif | 506 | #endif |
| 499 | 507 | ||
| @@ -507,7 +515,8 @@ image_create_bitmap_from_data (struct frame *f, char *bits, | |||
| 507 | #ifdef HAVE_PGTK | 515 | #ifdef HAVE_PGTK |
| 508 | dpyinfo->bitmaps[id - 1].img = pixbuf; | 516 | dpyinfo->bitmaps[id - 1].img = pixbuf; |
| 509 | dpyinfo->bitmaps[id - 1].depth = 1; | 517 | dpyinfo->bitmaps[id - 1].depth = 1; |
| 510 | dpyinfo->bitmaps[id - 1].pattern = image_create_pattern_from_pixbuf (f, pixbuf); | 518 | dpyinfo->bitmaps[id - 1].pattern = |
| 519 | image_create_pattern_from_pixbuf (f, pixbuf); | ||
| 511 | #endif | 520 | #endif |
| 512 | 521 | ||
| 513 | dpyinfo->bitmaps[id - 1].file = NULL; | 522 | dpyinfo->bitmaps[id - 1].file = NULL; |
| @@ -567,10 +576,11 @@ image_create_bitmap_from_file (struct frame *f, Lisp_Object file) | |||
| 567 | ptrdiff_t id; | 576 | ptrdiff_t id; |
| 568 | void * bitmap = gdk_pixbuf_new_from_file(SSDATA(file), &err); | 577 | void * bitmap = gdk_pixbuf_new_from_file(SSDATA(file), &err); |
| 569 | 578 | ||
| 570 | if (!bitmap) { | 579 | if (!bitmap) |
| 571 | g_error_free(err); | 580 | { |
| 572 | return -1; | 581 | g_error_free(err); |
| 573 | } | 582 | return -1; |
| 583 | } | ||
| 574 | 584 | ||
| 575 | id = image_allocate_bitmap_record(f); | 585 | id = image_allocate_bitmap_record(f); |
| 576 | 586 | ||
| @@ -580,7 +590,8 @@ image_create_bitmap_from_file (struct frame *f, Lisp_Object file) | |||
| 580 | //dpyinfo->bitmaps[id - 1].depth = 1; | 590 | //dpyinfo->bitmaps[id - 1].depth = 1; |
| 581 | dpyinfo->bitmaps[id - 1].height = gdk_pixbuf_get_width (bitmap); | 591 | dpyinfo->bitmaps[id - 1].height = gdk_pixbuf_get_width (bitmap); |
| 582 | dpyinfo->bitmaps[id - 1].width = gdk_pixbuf_get_height (bitmap); | 592 | dpyinfo->bitmaps[id - 1].width = gdk_pixbuf_get_height (bitmap); |
| 583 | dpyinfo->bitmaps[id - 1].pattern = image_create_pattern_from_pixbuf (f, bitmap); | 593 | dpyinfo->bitmaps[id - 1].pattern |
| 594 | = image_create_pattern_from_pixbuf (f, bitmap); | ||
| 584 | return id; | 595 | return id; |
| 585 | #endif | 596 | #endif |
| 586 | 597 | ||