2011-07-31 7 views
0
에 MapField에서 비트 맵의 ​​폭과 높이를 조정

나는 아래의 코드처럼 MapField에 위치 점을 중심으로 원을 그리기 오전 :블랙 베리

public void drawCircleMap(int [] radius) 
{ 
    int i = 0; 
    Graphics graphics = null; 
    int x2,y2; 
    bmparr = new Bitmap[radius.length]; 
    for(int j=0;j<radius.length;j++) 
    { 
       XYPoint fieldOut = new XYPoint(); 
       convertWorldToField(mPoints[1], fieldOut); 
       x2 = fieldOut.x; 
       y2 = fieldOut.y; 
       bmparr[i] = new Bitmap(getWidth(), getHeight()); 
       bmparr[i].createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP); 
       graphics = Graphics.create(bmparr[i]); 
       graphics.setColor(Color.BLUE); 
       graphics.drawEllipse(x2, y2, x2+radius[j], y2, x2,y2+radius[j], 0, 360); 
       graphics.fillEllipse(x2, y2, x2+radius[j], y2, x2,y2+radius[j], 0, 360); 
       i++; 
    } 

}

protected void paint(Graphics graphics) { 
    super.paint(graphics); 

    for(int i =0 ;i < bmparr.length;i++) 
    { 
     graphics.setGlobalAlpha(100); 
     graphics.drawBitmap(0, 0, bmparr[i].getWidth(), bmparr[i].getHeight(), bmparr[i], 0, 0); 
    } 

}

4 개의 원을 그려야합니다. 더 많은 수의 원을 그렸을 때지도가 희미 해 보입니다. 누군가이 문제를 해결할 수있는 방법을 알려주시겠습니까?

+0

당신은 정말 질문에 대한 답변으로 솔루션을 추가과 이용 약관을 읽고 동의를해야한다. 그런 식으로 유사한 문제를 찾는 누군가는이 질문에 대한 해결책이 있다는 것을 한눈에 볼 수 있습니다. –

답변

1

나는 모든 비트 맵에 대한 투명한 배경을 그림으로써이 문제를 해결 한 :

bmparr = new Bitmap[radius.length]; 
for(int j=0;j<radius.length;j++) 
{ 
    XYPoint fieldOut = new XYPoint(); 
    convertWorldToField(mPoints[1], fieldOut); 
    x2 = fieldOut.x; 
    y2 = fieldOut.y; 
    bmparr[i] = new Bitmap(getWidth(), getHeight()); 
    bmparr[i].createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP); 
    int[] argb = new int[getWidth() * getHeight()]; 
    bmparr[i].getARGB(argb, 0, getWidth(), 0, 0, getWidth(), getHeight()); 
    for(int k = 0; k < argb.length; k++) 
    { 
     argb[k] = 0x00000000; 
    } 
    bmparr[i].setARGB(argb, 0, getWidth(), 0, 0, getWidth(), getHeight()); 
    graphics = Graphics.create(bmparr[i]); 
    graphics.setColor(Color.BLUE); 
    graphics.drawEllipse(x2, y2, x2+radius[j], y2, x2,y2+radius[j], 0, 360); 
    graphics.fillEllipse(x2, y2, x2+radius[j], y2, x2,y2+radius[j], 0, 360); 
    i++; 
} 
0

귀하의 문제는 알파 블렌딩으로 생각됩니다. 약 50 %의 알파로 각 이미지를 다른 이미지 위에 겹쳐서 그립니다. 따라서 첫 번째 반경은 기존 픽셀 강도의 절반을 "덮습니다". 다음 반경은 나머지 강도의 절반, 또는 원래의 강도의 75 %를 덮습니다. 그리고 여러분은 이미지를 그릴 때마다 점점 더 원래의 강도를 덮고 있습니다.

모든 서클의 강도를 동일하게 유지하려면 접근 방식을 재검토해야합니다. 예를 들어 모든 원을지도 위에 그리기 전에 단일 비트 맵으로 그려 보는 것이 좋습니다. 또는 더 큰 원이 100 % 투명한 "구멍"을 남겨 둘 것을 고려해보십시오.

+0

많은 의견을 보내 주시면 감사하겠습니다. – Suppi