Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Sprite getSubImage(int sX, int sY, int w, int h)
- {
- try {
- Sprite s = new Sprite(w, h);
- int[] thePixels = new int[w * h];
- for (int i = sX; i < w; i++)
- {
- for (int i1 = sY; i1 < h; i1++)
- {
- int i2 = i - sX;
- int i3 = i1 - sY;
- thePixels[i2 + i3 * w] = this.myPixels[i + i1 * this.myWidth];
- }
- }
- s.myHeight = h - sY;
- s.myWidth = w - sX;
- s.myPixels = thePixels;
- return s;
- } catch(Exception e) {
- e.printStackTrace();
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement