0
私はこの写真のように3dテキストを作成しようとしていますandroidにcreate3dテキストを作成するには
目的のために私は次のコードを書いています。その3Dを正面から見るとほぼ3Dですが、x軸で回転させると90度で消える点があります。 3次元テキスト用のアプリも店内にはほとんどありません。 最初にテキストをビットマップに変換してから、オーバーレイを適用して3D効果を与えます。
img= (ImageView) findViewById(R.id.imageView);
skBar= (SeekBar) findViewById(R.id.seekBar);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.img);
bm = textAsBitmap("TEXT CHECK", 140.0f, Color.BLUE);
img.setImageBitmap(overlay(bm,bm));
skBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
img.setRotationY(Float.parseFloat(String.valueOf(progress)));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
for (float i = 20; i > 0; i-=0.5f) {
canvas.drawBitmap(bmp2, i, i, null);
}
for (float i = 1; i <= 20; i+=0.5f) {
canvas.drawBitmap(bmp2, i, i, null);
}
return bmOverlay;
}
public Bitmap textAsBitmap(String text, float textSize, int textColor) {
Paint paint = new Paint();
paint.setTextSize(textSize);
paint.setColor(textColor);
paint.setTextAlign(Paint.Align.LEFT);
paint.setTextScaleX(1.5f);
// paint.setTexth(5.0f);
float baseline = -paint.ascent(); // ascent() is negative
int width = (int) (paint.measureText(text) + 0.5f); // round
int height = (int) (baseline + paint.descent() + 0.5f);
Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(image);
canvas.drawText(text, 0, baseline, paint);
return image;
}
感謝に役立ちますが、私はすでに、これらをチェックします。 – farhan678