Guest User

Untitled

a guest
Nov 20th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. x_pad, y_pad = 0, 0
  2.  
  3. # Basically what's happening here is I'm trying to get the number of pixels
  4. # needed to pad the image so it can be chopped into equal 256x256 squares.
  5. #
  6. # To do this I first check if the pixel count is already cleanly divisible by
  7. # 256, and then if it's not, I then try to figure out how much more height I
  8. # need to add. I do that by first dividing the pixel count by 256 and then
  9. # adding 1 to it to give me a clean multiple of 256 to work with. Afterwards I
  10. # I multiply that by 256 to get the ideal height, and then subtract that number
  11. # by how many pixels I already have so that I get the number of pixels I need
  12. # to pad it by.
  13. #
  14. # After all that is done I divide it by 2 so it can be padded equally on both sides
  15. if (image.rows % 256) > 0
  16. x_pad = (256 * ((image.rows / 256) + 1)) - image.rows
  17. x_pad = x_pad / 2
  18. end
  19. if (image.columns % 256) > 0
  20. y_pad = (256 * ((image.columns / 256) + 1)) - image.columns
  21. y_pad = y_pad / 2
  22. end
Add Comment
Please, Sign In to add comment