【发布时间】:2017-02-02 12:53:24
【问题描述】:
我正在尝试将 Siemens Star 绘制到空位图中。当我记下圆形像素坐标的公式时,程序告诉我,它会产生一个长整数而不是整数。
double d = 0.001;
Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
for(int r = Rin; r < Rout; r++){
double phi = 0;
while( phi < 2* Math.PI){
for(int i = 0; i<Math.PI/nPeriods*1/d; i++){
int x = Math.round(X_Center + Math.cos(phi)*r);
int y = Math.round(Y_Center + Math.sin(phi)*r);
bmp.setPixel(x,y,Color.BLACK);
phi = phi+d;
}
for(int i = 0; i<Math.PI/nPeriods*1/d; i++){
phi = phi+d;
}
}
}
我在 Matlab 中尝试过这种算法,效果很好。谁能告诉我我的错误?
【问题讨论】:
标签: android math android-bitmap imaging