dansiegel / Mobile.BuildTools

The Mobile.BuildTools makes it easier to develop code bases in a clean, consistent, secure, and configurable way. Determine at Build which environment your app needs to run on, and what Client Secrets it should have. Plus many more amazing features!
http://mobilebuildtools.com
MIT License
228 stars 29 forks source link

Android padding factor appears to scale incorrectly #240

Closed bijington closed 3 years ago

bijington commented 3 years ago

Description

The padding factor is not correctly applied. It appears to grow the image rather than reducing the size.

Reproduction Steps

Use the attached project with the key json below:

{
  "$schema": "https://mobilebuildtools.com/schemas/v2/resourceDefinition.schema.json",
  "android": {
      "resourceType": "Mipmap",
      "name": "icon",
      "scale": 0.1875,
      "additionalOutputs": [
          {
              "name": "launcher_foreground",
              "resourceType": "Mipmap",
              "scale": 0.28125,
              "padFactor": 1.5
          },
          {
              "name": "logo",
              "resourceType": "Drawable"
          }
      ]
  },
  "iOS": {
      "name": "AppIcon",
      "background": "#ffffff",
      "additionalOutputs": [
          {
              "name": "logo"
          }
      ]
  }
}

Expected Behavior

Expect the icon to sit nicely inside the adaptive icon area for Android following these rules:

Imagine a 1024x1024px image with padFactor: 1.5, height: 100 and width: 100.

  1. Canvas created at padFactor * original image size. (1024 * 1.5 -> 1536).
  2. Image added at original image size. (1024).
  3. Canvas then scaled down to output size (100x100).

Actual Behavior

Screenshot 2021-06-15 at 23 25 43

Reproduction App

Building and running Android will present the issue seen in the Actual Behavior screenshot template.zip

dansiegel commented 3 years ago

This is largely correct... but a couple of minor tweaks here... and to ensure this is clear.

Imagine a 1024x1024px image with padFactor: 1.5, height: 100 and width: 100.

  1. Original 1024x1024 image is copied
  2. If using a watermark image it is applied
  3. The canvas size is increased by a factor of 1.5 (1024 * 1.5 => 1536)
  4. Image remains 1024x1024 in the center of a 1536x1536 canvas (gives us a padding of 256px around the original image)
  5. Background color / generated watermark banner applied if applicable.
  6. Image is scaled down to the output size 100x100.