Android 设置像素;像素坐标与数据类型';长';
我正试图将一个西门子星号绘制成一个空位图。当我写下圆形像素坐标的公式时,POGRAM告诉我,它会产生一个长的数字,而不是一个整数Android 设置像素;像素坐标与数据类型';长';,android,math,android-bitmap,imaging,Android,Math,Android Bitmap,Imaging,我正试图将一个西门子星号绘制成一个空位图。当我写下圆形像素坐标的公式时,POGRAM告诉我,它会产生一个长的数字,而不是一个整数 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* Ma
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;
}
}
}
double d=0.001;
位图bmp=Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888);
对于(int r=Rin;r 对于(int i=0;i您需要使用以下代码将Math.round结果转换为整数:
int x = (int) Math.round(X_Center + Math.cos(phi)*r);
这么简单…谢谢你!