branch | RCL_3 |
changeset 83 | 26b2b12093af |
parent 77 | 7cee158cb8cd |
77:7cee158cb8cd | 83:26b2b12093af |
---|---|
323 } |
323 } |
324 } |
324 } |
325 |
325 |
326 public static Image createRGBImage(int[] aRgb, int aWidth, int aHeight, boolean aProcessAlpha) |
326 public static Image createRGBImage(int[] aRgb, int aWidth, int aHeight, boolean aProcessAlpha) |
327 { |
327 { |
328 if (aRgb.length < (aWidth * aHeight)) |
|
329 { |
|
330 throw new ArrayIndexOutOfBoundsException(); |
|
331 } |
|
332 |
|
328 if (aWidth <= 0 || aHeight <= 0) |
333 if (aWidth <= 0 || aHeight <= 0) |
329 { |
334 { |
330 throw new IllegalArgumentException(); |
335 throw new IllegalArgumentException(); |
331 } |
336 } |
332 |
337 |
333 if (aRgb.length < (aWidth * aHeight) || (aWidth * aHeight) < 0) |
|
334 { |
|
335 throw new ArrayIndexOutOfBoundsException(); |
|
336 } |
|
337 try |
338 try |
338 { |
339 { |
339 return new Image(aRgb, aWidth, aHeight, aProcessAlpha); |
340 return new Image(aRgb, aWidth, aHeight, aProcessAlpha); |
340 } |
341 } |
341 catch (OutOfMemoryError oom) |
342 catch (OutOfMemoryError oom) |
447 { |
448 { |
448 end = (long)aOffset + (long)aWidth - 1; |
449 end = (long)aOffset + (long)aWidth - 1; |
449 start = (long)aOffset + (long)aScanLength*((long)aHeight-1); |
450 start = (long)aOffset + (long)aScanLength*((long)aHeight-1); |
450 } |
451 } |
451 |
452 |
453 // |
|
454 // aScanLength may be < 0, hence end < start is valid. |
|
455 // |
|
456 if ((start < 0) || (start > limit) || (end < 0) || (end > limit)) |
|
457 { |
|
458 throw new ArrayIndexOutOfBoundsException("destination range exceeds array bounds"); |
|
459 } |
|
460 |
|
452 final int width = iWidth; |
461 final int width = iWidth; |
453 final int height = iHeight; |
462 final int height = iHeight; |
454 |
463 |
455 final int sx1 = aX; // left column |
464 final int sx1 = aX; // left column |
456 final int sx2 = aX + aWidth; // right column |
465 final int sx2 = aX + aWidth; // right column |
467 if (xRangeError || yRangeError) |
476 if (xRangeError || yRangeError) |
468 { |
477 { |
469 final String info = "args=("+aX+','+aY+','+aWidth+','+aHeight+"), rect=("+sx1 +','+sy1+','+sx2+','+sy2+"), image width="+width+",height="+height; |
478 final String info = "args=("+aX+','+aY+','+aWidth+','+aHeight+"), rect=("+sx1 +','+sy1+','+sx2+','+sy2+"), image width="+width+",height="+height; |
470 throw new IllegalArgumentException("getRGB: Exceeding bounds of source image: " + info); |
479 throw new IllegalArgumentException("getRGB: Exceeding bounds of source image: " + info); |
471 } |
480 } |
472 |
|
473 // |
|
474 // aScanLength may be < 0, hence end < start is valid. |
|
475 // |
|
476 if ((start < 0) || (start > limit) || (end < 0) || (end > limit)) |
|
477 { |
|
478 throw new ArrayIndexOutOfBoundsException("destination range exceeds array bounds"); |
|
479 } |
|
480 |
|
481 final int scanLength = Math.abs(aScanLength); |
481 final int scanLength = Math.abs(aScanLength); |
482 |
482 |
483 if (scanLength < aWidth) |
483 if (scanLength < aWidth) |
484 { |
484 { |
485 throw new IllegalArgumentException("abs(Scanlength) should be >= width"); |
485 throw new IllegalArgumentException("abs(Scanlength) should be >= width"); |