• 0

C# - Converting floats to pixels


Question

2 answers to this question

Recommended Posts

  • 0

This should work. If I understand your question correctly, you're trying to find the scaling percentage for any width image so that the final width is 204 px. Try this equation:

204 = width * scale%

so:

scale% = 204/width

And the scale% is the float you want. Also, make sure you're not dividing integers or else you won't get any decimal places. So, just make sure to convert the width to a float: Convert.ToFloat(width) before dividing 204.0 by it. Hope that helps.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.