Android Bitmap getPixel() error
<pre><code>private Bitmap loadBitmap() {

        Resources res = getResources();
        Bitmap bitmap =BitmapFactory.decodeResource(res, R.drawable.image);

        return bitmap;
    }

private void setImage(Context context) {

        bitmap = loadBitmap();
        originalBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
        finalbitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);;
        c2 = new Canvas(finalbitmap);
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        canvas.drawColor(Color.LTGRAY);

        if(rx&gt;=0 &amp;&amp; ry&gt;=0) {
            if(eraser==0) {
                setAlpha(rx,ry);
                c2.drawCircle(rx-curPoint.x, ry-curPoint.y, brushsize, paint);
            } else if(eraser==1) {
                unsetAlpha(rx,ry);
                c2.drawCircle(rx-curPoint.x, ry-curPoint.y, brushsize, erase);
            }
        }
        if(showfinal) {
            imsi = finalbitmap.copy(Bitmap.Config.ARGB_8888, true);
            applyAlpha(originalBitmap, imsi);
            canvas.drawBitmap(imsi, curPoint.x, curPoint.y, null);
        }
        else canvas.drawBitmap(bitmap, curPoint.x, curPoint.y, null);
    }

    public void startLine(float x, float y) {
        rx=(int)x;
        ry=(int)y;
        invalidate();       
    }

    public void setAlpha(float x, float y) {
        int i, j;
        int jmin, jmax;
        for(i=(int)x-brushsize;i&lt;=(int)x+brushsize;i++) {
            if(i-curPoint.x&lt;0 || i-curPoint.x&gt;=bitmap.getWidth()) continue;
            jmin=(int)y-(int)Math.sqrt((brushsize*brushsize)-(i-x)*(i-x));
            jmax=(int)y+(int)Math.sqrt((brushsize*brushsize)-(i-x)*(i-x));
            for(j=jmin+1;j&lt;=jmax;j++) {
                if(j-curPoint.y&lt;0 || j-curPoint.y&gt;=bitmap.getHeight()) continue;
                int a = originalBitmap.getPixel(i-curPoint.x,j-curPoint.y);
                bitmap.setPixel(i-curPoint.x, j-curPoint.y, (Color.argb(Color.alpha(a), (Color.red(a)+128)/2, Color.green(a)/2, Color.blue(a)/2)));
            }
        }
    }
    public void unsetAlpha(float x, float y) {
        int i, j;
        int jmin, jmax;
        for(i=(int)x-brushsize;i&lt;=(int)x+brushsize;i++) {
            if(i-curPoint.x&lt;0 || i-curPoint.x&gt;=bitmap.getWidth()) continue;
            jmin=(int)y-(int)Math.sqrt((brushsize*brushsize)-(i-x)*(i-x));
            jmax=(int)y+(int)Math.sqrt((brushsize*brushsize)-(i-x)*(i-x));
            for(j=jmin+1;j&lt;=jmax;j++) {
                if(j-curPoint.y&lt;0 || j-curPoint.y&gt;=bitmap.getHeight()) continue;
                bitmap.setPixel(i-curPoint.x, j-curPoint.y, originalBitmap.getPixel(i-curPoint.x,j-curPoint.y));
            }
        }
    }   
</code></pre>

<p><strong>Error log :</strong></p>

<pre><code>01-28 16:08:26.402: E/AndroidRuntime(29658): FATAL EXCEPTION: main 
01-28 16:08:26.402: E/AndroidRuntime(29658): java.lang.IllegalStateException 
01-28 16:08:26.402: E/AndroidRuntime(29658): at android.graphics.Bitmap.setPixel(Bitmap.java:1002) 
01-28 16:08:26.402: E/AndroidRuntime(29658): at com.example.imagecut.CutView.setAlpha(CutView.java:122) 
01-28 16:08:26.402: E/AndroidRuntime(29658): at com.example.imagecut.CutView.onDraw(CutView.java:91)
</code></pre>

<p>In my code: <br></p>

<pre><code> int a = originalBitmap.getPixel(i-curPoint.x,j-curPoint.y); 
</code></pre>

<p><br> In function :<br></p>

<pre><code>setAlpha(float x, float y)
</code></pre>

<p>and 
<br>  <code>unsetAlpha(float x, float y)</code> has error, I don't know why.
Please help me..TT </p>
