Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. public Sprite getSubImage(int sX, int sY, int w, int h)
  2. {
  3. try {
  4. Sprite s = new Sprite(w, h);
  5. int[] thePixels = new int[w * h];
  6. for (int i = sX; i < w; i++)
  7. {
  8. for (int i1 = sY; i1 < h; i1++)
  9. {
  10. int i2 = i - sX;
  11. int i3 = i1 - sY;
  12. thePixels[i2 + i3 * w] = this.myPixels[i + i1 * this.myWidth];
  13. }
  14. }
  15. s.myHeight = h - sY;
  16. s.myWidth = w - sX;
  17. s.myPixels = thePixels;
  18. return s;
  19. } catch(Exception e) {
  20. e.printStackTrace();
  21. }
  22. return null;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement