我创建了一个位图图像,它是一个圆形,并且比我想对其进行动画处理,因此我将其转换为bitmapdrawable,然后将其添加到动画drawable中。但是由于此,圆形变成了椭圆形...
所以我该怎么做 ?
是否有其他方法可以仅对位图文件进行动画处理。?
提前致谢..
我试图在屏幕上绘制一些东西,然后将其复制到舞台上的位图上.
我以前做过这个,用程序绘制的形状像圆圈但是当我使用库项目时,大多数源像素被切断.
这是我的代码 - 在另一个函数中,位图对象被添加到舞台上,我可以看到copyPixels工作,但正如我所说的只复制了一些像素.我试过玩矩形但到目前为止没有运气.
var s:StarAsset = new StarAsset();
s.x = e.stageX;
s.y = e.stageY;
s.scaleX = e.pressure * 10;
s.scaleY = e.pressure * 10;
s.rotation = Math.random() * 360;
var bms:BitmapData = new BitmapData(s.width + 6, s.height + 6, true, 0x00000000);
bms.draw(s);
var srect:Rectangle = new Rectangle();
srect.width = s.width + 6;
srect.height = s.height + 6;
var destpoint:Point = new Point(s.x, s.y);
bmcontainer.copyPixels(bms, srect, destpoint, null, null, true);
Run Code Online (Sandbox Code Playgroud) 我想在内部存储(而不是外部存储)上存储位图图像.我写了这段代码,但似乎有问题.因为当我从DDMS下载图像时,我无法打开它.
public String writeFileToInternalStorage(Context context, Bitmap outputImage) {
String fileName = Long.toString(System.currentTimeMillis()) + ".png";
try {
OutputStreamWriter osw = new OutputStreamWriter(context.openFileOutput(fileName, Context.MODE_PRIVATE));
osw.write(outputImage.toString());
Log.i(TAG, "Image stored at: " + fileName);
} catch (Exception e) {
Log.w(TAG, e.toString());
fileName = null;
}
return fileName;
}
Run Code Online (Sandbox Code Playgroud) 我遇到了打印质量问题,我在此链接中对其进行了 描述:在此处输入链接说明
我尝试了许多不同的解决方案,帮助其他类似概率的人,但他们不适合我,因为我有一个新的概率将图像保存为位图(低质量)
最后我决定问我当前的问题,因为正如你在上面的链接中看到的,我的问题在保存系统(96dpi)中的图像并恢复之后开始.但我没有办法,所以我正在寻找一种方法,可以保存图像(具有从图形中绘制的像素)而不会降低质量.
提前
我需要通过从其他活动中选择图像来动态更改活动的背景.并将所选图像传递回调用活动,但是当我尝试获取图像时,它为空.这是我的代码.
public class SelectGoalBackground extends OrmLiteBaseActivity<DatabaseHelper> {// implements{
GridView gridview ;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.select_goal_background);
final String from = getIntent().getExtras().getString("from");
goalsList = new ArrayList<Goal>();
try {
goalsList = getTop3Goals();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (java.sql.SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
ImageView l = (ImageView)gridview.getChildAt(position);
Drawable …Run Code Online (Sandbox Code Playgroud) 我有一个类似的数组byte[] pixels.有没有办法在不复制数据的情况下从中创建bitmap对象pixels?我有一个小图形库,当我需要在WinForms窗口上显示图像时我只是将该数据复制到一个bitmap对象,然后我使用draw方法.我可以避免这种复制过程吗?我记得我在某个地方看过它,但也许我的记忆很糟糕.
编辑:我试过这个代码并且它可以工作,但这样安全吗?
byte[] pixels = new byte[10 * 10 * 4];
pixels[4] = 255; // set 1 pixel
pixels[5] = 255;
pixels[6] = 255;
pixels[7] = 255;
// do some tricks
GCHandle pinnedArray = GCHandle.Alloc(pixels, GCHandleType.Pinned);
IntPtr pointer = pinnedArray.AddrOfPinnedObject();
// create a new bitmap.
Bitmap bmp = new Bitmap (10, 10, 4*10, PixelFormat.Format32bppRgb, pointer);
Graphics grp = this.CreateGraphics ();
grp.DrawImage (bmp, 0, 0);
pixels[4+12] = 255; // add …Run Code Online (Sandbox Code Playgroud) 我是Android中的菜鸟和新手.
我只知道Bitmap按像素存储图像并且不进行任何压缩.
Drawable是否与Bitmap相同?
或者
对于相同的图像文件,Drawable比Bitmap占用更少的内存?
谢谢你的回复.
我需要将以下方法从C#转换为符合MonoTouch的代码:
private WritableBitMap CreateBitMapWPF(RGBPaletteRecord rgbPalette, double dpi)
{
WritableBitMap bitmapImage = null;
try
{
bitmapImage = new WritableBitMap(TileRecord.PixelWidth, TileRecord.PixelHight, dpi, dpi, PixelFormats.Rgb24, BitmapPalettes.Halftone256);
// int nStride = (bitmapImage.PixelWidth * bitmapImage.Format.BitsPerPixel + 7) / 8;
int nStride = (bitmapImage.PixelWidth * bitmapImage.Format.BitsPerPixel / 8);
System.Windows.Int32Rect rect = new System.Windows.Int32Rect(0, 0, TileRecord.PixelWidth, TileRecord.PixelHight);
byte[] data = GetBytes(rgbPalette);
bitmapImage.WritePixels(rect, data, nStride, 0);
}
catch (Exception ex)
{
}
//// temp write to file to test
//using (FileStream stream5 = new FileStream(@"C:\test.bmp", FileMode.Create))
//{
// …Run Code Online (Sandbox Code Playgroud) 我正在与Winforms中的Emgu Cv一起使用Kinect进行人脸识别.现在,我想转向WPF.但是,EmguCv库仅支持Bitmap类.
我可以在WPF中使用Bitmap类(在Winforms中使用)吗?如果没有,是否有其他方法在WPF中使用带有kinect的Emgu cv?
谢谢.
首先,这个问题不是关于"如何将位图保存为磁盘上的jpeg?"
我无法找到(或想到)Bitmap使用Jpeg压缩转换a的方法,但将其保留为Bitmap对象.MSDN清楚地展示了如何将Bitmap保存为JPEG,但我正在寻找的是如何将编码/压缩应用于Bitmap对象,因此我仍然可以在我的代码中传递它,而无需引用该文件.
其背后的原因之一是处理位图的辅助类,但不应该知道使用的持久性方法.