Lines Matching refs:image

263   // Scan the entire image and determine if:
269 printf("Initial image data:\n");
293 // Check if image is really grayscale
304 // Check if image is really opaque
315 // Check if image is really <= 256 colors
359 // Choose the best color type for the image.
385 diag->Note(DiagMessage() << "forcing image to gray (max deviation = "
393 // Perform postprocessing of the image or palette data based on the final
410 // If the image is gray or gray + alpha, compact the pixels into outRows
465 diag->Note(DiagMessage() << "writing image: w = " << info->width
477 // If the image is a 9-patch, we need to preserve it as a ARGB file to make
598 printf("Final image data:\n");
616 diag->Note(DiagMessage() << "image written: w = " << width
886 static void getOutline(PngInfo* image) {
887 int midX = image->width / 2;
888 int midY = image->height / 2;
889 int endX = image->width - 2;
890 int endY = image->height - 2;
893 if (image->width > 4) {
894 findMaxOpacity(image->rows.data(), 1, midY, midX, -1, 1, 0,
895 &image->outlineInsetsLeft);
896 findMaxOpacity(image->rows.data(), endX, midY, midX, -1, -1, 0,
897 &image->outlineInsetsRight);
899 image->outlineInsetsLeft = 0;
900 image->outlineInsetsRight = 0;
904 if (image->height > 4) {
905 findMaxOpacity(image->rows.data(), midX, 1, -1, midY, 0, 1,
906 &image->outlineInsetsTop);
907 findMaxOpacity(image->rows.data(), midX, endY, -1, midY, 0, -1,
908 &image->outlineInsetsBottom);
910 image->outlineInsetsTop = 0;
911 image->outlineInsetsBottom = 0;
914 int innerStartX = 1 + image->outlineInsetsLeft;
915 int innerStartY = 1 + image->outlineInsetsTop;
916 int innerEndX = endX - image->outlineInsetsRight;
917 int innerEndY = endY - image->outlineInsetsBottom;
921 // assuming the image is a round rect, compute the radius by marching
923 image->outlineAlpha = std::max(
924 maxAlphaOverRow(image->rows[innerMidY], innerStartX, innerEndX),
925 maxAlphaOverCol(image->rows.data(), innerMidX, innerStartY, innerStartY));
928 findMaxOpacity(image->rows.data(), innerStartX, innerStartY, innerMidX,
937 image->outlineRadius = 3.4142f * diagonalInset;
941 image->outlineInsetsLeft, image->outlineInsetsTop,
942 image->outlineInsetsRight, image->outlineInsetsBottom,
943 image->outlineRadius, image->outlineAlpha);
976 static bool do9Patch(PngInfo* image, std::string* outError) {
977 image->is9Patch = true;
979 int W = image->width;
980 int H = image->height;
985 int32_t* xDivs = image->xDivs = new int32_t[W];
986 int32_t* yDivs = image->yDivs = new int32_t[H];
999 image->info9Patch.paddingLeft = image->info9Patch.paddingRight = -1;
1000 image->info9Patch.paddingTop = image->info9Patch.paddingBottom = -1;
1001 image->layoutBoundsLeft = image->layoutBoundsRight = 0;
1002 image->layoutBoundsTop = image->layoutBoundsBottom = 0;
1004 png_bytep p = image->rows[0];
1037 if (!getVerticalTicks(image->rows.data(), 0, H, transparent, true, &yDivs[0],
1044 // Copy patch size data into image...
1045 image->info9Patch.numXDivs = numXDivs;
1046 image->info9Patch.numYDivs = numYDivs;
1049 if (!getHorizontalTicks(image->rows[H - 1], W, transparent, false,
1050 &image->info9Patch.paddingLeft,
1051 &image->info9Patch.paddingRight, &errorMsg, nullptr,
1053 errorPixel = image->info9Patch.paddingLeft;
1059 if (!getVerticalTicks(image->rows.data(), (W - 1) * 4, H, transparent, false,
1060 &image->info9Patch.paddingTop,
1061 &image->info9Patch.paddingBottom, &errorMsg, nullptr,
1063 errorPixel = image->info9Patch.paddingTop;
1069 getHorizontalLayoutBoundsTicks(image->rows[H - 1], W, transparent, false,
1070 &image->layoutBoundsLeft,
1071 &image->layoutBoundsRight, &errorMsg);
1073 getVerticalLayoutBoundsTicks(image->rows.data(), (W - 1) * 4, H, transparent,
1074 false, &image->layoutBoundsTop,
1075 &image->layoutBoundsBottom, &errorMsg);
1077 image->haveLayoutBounds =
1078 image->layoutBoundsLeft != 0 || image->layoutBoundsRight != 0 ||
1079 image->layoutBoundsTop != 0 || image->layoutBoundsBottom != 0;
1081 if (image->haveLayoutBounds) {
1083 printf("layoutBounds=%d %d %d %d\n", image->layoutBoundsLeft,
1084 image->layoutBoundsTop, image->layoutBoundsRight,
1085 image->layoutBoundsBottom);
1090 getOutline(image);
1093 if (image->info9Patch.paddingLeft < 0) {
1094 image->info9Patch.paddingLeft = xDivs[0];
1095 image->info9Patch.paddingRight = W - 2 - xDivs[1];
1098 image->info9Patch.paddingRight = W - 2 - image->info9Patch.paddingRight;
1100 if (image->info9Patch.paddingTop < 0) {
1101 image->info9Patch.paddingTop = yDivs[0];
1102 image->info9Patch.paddingBottom = H - 2 - yDivs[1];
1105 image->info9Patch.paddingBottom = H - 2 - image->info9Patch.paddingBottom;
1113 image->info9Patch.paddingLeft, image->info9Patch.paddingRight,
1114 image->info9Patch.paddingTop,
1115 image->info9Patch.paddingBottom);
1118 // Remove frame from image.
1121 newRows[i] = image->rows[i + 1];
1124 image->rows.swap(newRows);
1126 image->width -= 2;
1127 W = image->width;
1128 image->height -= 2;
1129 H = image->height;
1155 image->info9Patch.numColors = numColors;
1156 image->colors.resize(numColors);
1194 c = getColor(image->rows.data(), left, top, right - 1, bottom - 1);
1195 image->colors[colorIndex++] = c;
1211 printf(" #%08x", image->colors[i]);