Lines Matching refs:image

35 // This holds an image as 8bpp RGBA.
447 static void get_outline(image_info* image)
449 int midX = image->width / 2;
450 int midY = image->height / 2;
451 int endX = image->width - 2;
452 int endY = image->height - 2;
455 if (image->width > 4) {
456 find_max_opacity(image->rows, 1, midY, midX, -1, 1, 0, &image->outlineInsetsLeft);
457 find_max_opacity(image->rows, endX, midY, midX, -1, -1, 0, &image->outlineInsetsRight);
459 image->outlineInsetsLeft = 0;
460 image->outlineInsetsRight = 0;
464 if (image->height > 4) {
465 find_max_opacity(image->rows, midX, 1, -1, midY, 0, 1, &image->outlineInsetsTop);
466 find_max_opacity(image->rows, midX, endY, -1, midY, 0, -1, &image->outlineInsetsBottom);
468 image->outlineInsetsTop = 0;
469 image->outlineInsetsBottom = 0;
472 int innerStartX = 1 + image->outlineInsetsLeft;
473 int innerStartY = 1 + image->outlineInsetsTop;
474 int innerEndX = endX - image->outlineInsetsRight;
475 int innerEndY = endY - image->outlineInsetsBottom;
479 // assuming the image is a round rect, compute the radius by marching
481 image->outlineAlpha = max(max_alpha_over_row(image->rows[innerMidY], innerStartX, innerEndX),
482 max_alpha_over_col(image->rows, innerMidX, innerStartY, innerStartY));
485 find_max_opacity(image->rows, innerStartX, innerStartY, innerMidX, innerMidY, 1, 1,
494 image->outlineRadius = 3.4142f * diagonalInset;
497 image->outlineInsetsLeft,
498 image->outlineInsetsTop,
499 image->outlineInsetsRight,
500 image->outlineInsetsBottom,
501 image->outlineRadius,
502 image->outlineAlpha));
555 static uint32_t get_color(image_info* image, int hpatch, int vpatch)
559 hpatch, image->xDivs[0], image->xDivs[1],
560 image->width, &left, &right);
562 vpatch, image->yDivs[0], image->yDivs[1],
563 image->height, &top, &bottom);
566 const uint32_t c = get_color(image->rows, left, top, right, bottom);
571 static status_t do_9patch(const char* imageName, image_info* image)
573 image->is9Patch = true;
575 int W = image->width;
576 int H = image->height;
581 int32_t* xDivs = image->xDivs = (int32_t*) malloc(maxSizeXDivs);
582 int32_t* yDivs = image->yDivs = (int32_t*) malloc(maxSizeYDivs);
595 image->info9Patch.paddingLeft = image->info9Patch.paddingRight =
596 image->info9Patch.paddingTop = image->info9Patch.paddingBottom = -1;
598 image->layoutBoundsLeft = image->layoutBoundsRight =
599 image->layoutBoundsTop = image->layoutBoundsBottom = 0;
601 png_bytep p = image->rows[0];
633 if (get_vertical_ticks(image->rows, 0, H, transparent, true, &yDivs[0],
640 // Copy patch size data into image...
641 image->info9Patch.numXDivs = numXDivs;
642 image->info9Patch.numYDivs = numYDivs;
645 if (get_horizontal_ticks(image->rows[H-1], W, transparent, false, &image->info9Patch.paddingLeft,
646 &image->info9Patch.paddingRight, &errorMsg, NULL, false) != NO_ERROR) {
647 errorPixel = image->info9Patch.paddingLeft;
653 if (get_vertical_ticks(image->rows, (W-1)*4, H, transparent, false, &image->info9Patch.paddingTop,
654 &image->info9Patch.paddingBottom, &errorMsg, NULL, false) != NO_ERROR) {
655 errorPixel = image->info9Patch.paddingTop;
661 get_horizontal_layout_bounds_ticks(image->rows[H-1], W, transparent, false,
662 &image->layoutBoundsLeft,
663 &image->layoutBoundsRight, &errorMsg);
665 get_vertical_layout_bounds_ticks(image->rows, (W-1)*4, H, transparent, false,
666 &image->layoutBoundsTop,
667 &image->layoutBoundsBottom, &errorMsg);
669 image->haveLayoutBounds = image->layoutBoundsLeft != 0
670 || image->layoutBoundsRight != 0
671 || image->layoutBoundsTop != 0
672 || image->layoutBoundsBottom != 0;
674 if (image->haveLayoutBounds) {
675 NOISY(printf("layoutBounds=%d %d %d %d\n", image->layoutBoundsLeft, image->layoutBoundsTop,
676 image->layoutBoundsRight, image->layoutBoundsBottom));
680 get_outline(image);
683 if (image->info9Patch.paddingLeft < 0) {
684 image->info9Patch.paddingLeft = xDivs[0];
685 image->info9Patch.paddingRight = W - 2 - xDivs[1];
688 image->info9Patch.paddingRight = W - 2 - image->info9Patch.paddingRight;
690 if (image->info9Patch.paddingTop < 0) {
691 image->info9Patch.paddingTop = yDivs[0];
692 image->info9Patch.paddingBottom = H - 2 - yDivs[1];
695 image->info9Patch.paddingBottom = H - 2 - image->info9Patch.paddingBottom;
702 image->info9Patch.paddingLeft, image->info9Patch.paddingRight,
703 image->info9Patch.paddingTop, image->info9Patch.paddingBottom));
705 // Remove frame from image.
706 image->rows = (png_bytepp)malloc((H-2) * sizeof(png_bytep));
708 image->rows[i] = image->allocRows[i+1];
709 memmove(image->rows[i], image->rows[i]+4, (W-2)*4);
711 image->width -= 2;
712 W = image->width;
713 image->height -= 2;
714 H = image->height;
740 image->info9Patch.numColors = numColors;
741 image->colors = (uint32_t*)malloc(numColors * sizeof(uint32_t));
783 c = get_color(image->rows, left, top, right - 1, bottom - 1);
784 image->colors[colorIndex++] = c;
796 printf(" #%08x", image->colors[i]);
803 "ERROR: 9-patch image %s malformed.\n"
913 // Scan the entire image and determine if:
918 // NOISY(printf("Initial image data:\n"));
939 // Check if image is really grayscale
948 // Check if image is really opaque
957 // Check if image is really <= 256 colors
996 // Choose the best color type for the image.
1020 printf("%s: forcing image to gray (max deviation = %d)\n", imageName, maxGrayDeviation);
1027 // Perform postprocessing of the image or palette data based on the final
1043 // If the image is gray or gray + alpha, compact the pixels into outRows
1097 NOISY(printf("Writing image %s: w = %d, h = %d\n", imageName,
1108 // If the image is a 9-patch, we need to preserve it as a ARGB file to make
1217 // NOISY(printf("Final image data:\n"));
1256 printf("Processing image: %s\n", printableName.string());
1338 printf(" (processed image %s: %d%% size of source)\n", printableName.string(), percent);
1353 fprintf(stderr, "ERROR: Failure processing PNG image %s\n",
1374 printf("Processing image to cache: %s => %s\n", source.string(), dest.string());
1384 // Call libpng to get a struct to read image data into
1392 // Call libpng to get a struct to read image info into
1428 // Call libpng to create a structure to hold the processed image data
1436 // Call libpng to create a structure to hold processed image info that can
1475 printf(" (processed image to cache entry %s: %d%% size of source)\n",