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

Watermark image is not scaled correctly #293

Open bijington opened 2 years ago

bijington commented 2 years ago

Description

When applying a watermark sourceFile to an image the scaling is not correctly applied to the varying output sizes (see below).

Screenshot 2021-11-02 at 22 01 21

Reproduction Steps

Steps to reproduce the behavior:

  1. Configure a set of icons as per: https://mobilebuildtools.com/images/configuring-images/#watermarking-images
  2. Build and check the obj folders
  3. See error

Expected Behavior

The watermark image should be stretched/shrunk to correctly fit the whole output icon.

Actual Behavior

As can be seen in the screenshot the smaller icon sizes result in a smaller watermark.

Environment

Reproduction App

Please include a sample app that reproduces the issue and/or a binlog. Failure to reproduce either of these may lead to the issue being closed or ignored.

themronion commented 2 years ago

@bijington @dansiegel this maybe connected, or maybe not. I was recently trying out the library (which is amazing BTW!) and noticed that my svg-s are being rendered 4 times smaller than with ResizetizerNT. I am using the default scale - 1.0 (setting the scale to 4.0 throws errors). Would appreciate some help if u have some clue what may be going on here, really don't want to bring in an extra package because everything is basically baked in here

themronion commented 2 years ago

i guess it has something to do with setting the BaseSize - https://github.com/Redth/ResizetizerNT#basesize. As i see here the biggest generated png (drawable-xxxhdpi) is exactly the same size as the BaseSize which i defined in Resizetizer

bijington commented 2 years ago

@themronion are you able to share an SVG that you are using along with the JSON config file for that image?

themronion commented 2 years ago

shared.zip Nothing special. I specify the BaseSize as 55,57 in ResizetizerNT

bijington commented 2 years ago

@themronion MBT works rather differently to ResizetizerNT, it will by default scale an image down from it's source dimensions to smaller versions for each of the possible DPIs. Now as your SVG is rather small you will need to configure it to scale up before it then applies this. Something like this should work for your me.json file:

{
  "$schema": "http://mobilebuildtools.com/schemas/v2/resourceDefinition.schema.json",
  "name": "me",
  "android": {
    "resourceType": "Drawable",
    "scale": 4
  }
}

You will need to do the same for iOS but use a scale of 3.

Of course these numbers are assuming that you want the resulting image to be rendered at the same size as the SVG dimensions of 55,57.

themronion commented 2 years ago

Yeap, this tip did the trick! Thanks a lot!