可以请别人解释我(ASCII是真的欢迎)什么stride说法代表在Canvas.drawBitmap()和Bitmap.setPixels()/getPixels()?我理解这是跳过colors数组中元素的一种方法,但是如何?
我试图将Bitmap传递给另一个Activity,我正在使用其他Activity显示相同的图像ImageView.这就是我通过Bitmap的方式.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == CAMERA_RESULT) {
File out = new File(getFilesDir(), "newImage.jpg");
if(!out.exists()) {
Toast.makeText(getBaseContext(),
"Error while capturing image", Toast.LENGTH_LONG)
.show();
return;
}
Bitmap mBitmap = BitmapFactory.decodeFile(out.getAbsolutePath());
Intent bitIntent = new Intent(this, CameraTake.class);
bitIntent.putExtra("BitmapImage", mBitmap);
startActivity(bitIntent);
Run Code Online (Sandbox Code Playgroud)
这就是我收到价值的方式:
Intent intent = getIntent();
bitmap= (Bitmap)intent.getParcelableExtra("BitmapImage");
ImageView im1 = (ImageView)findViewById(R.id.camOut);
im1.setImageBitmap(bitmap);
Run Code Online (Sandbox Code Playgroud)
在运行App时,这里是我获得的logcat:
> 10-17 08:32:11.241 16762-16762/obx.com.futurister E/AndroidRuntime? FATAL EXCEPTION: main …Run Code Online (Sandbox Code Playgroud) 我想渲染到一个屏幕外的位图(或RGBA值数组),然后UIView在视图的drawRect函数中将它们blit到a .我更喜欢做完整的32位渲染(包括alpha通道),但也会满足于24位渲染.
有人会介意用一些代码片段或相关API指出我正确的方向吗?
另外,我确切知道如何使用OpenGL完成此操作 - 我更愿意在Core Graphics本身中完成这项工作.
我有一个RGB unsigned char的缓冲区,我想将其转换为位图文件,有谁知道怎么做?
我的RGB float具有以下格式
R [(0,0)],G [(0,0)],B [(0,0)],R [(0,1)],G [(0,1)],B [(0, 1)],R [(0,2)],G [(0,2)],B [(0,2)] .....
每个数据单元的值范围从0到255.任何人都有任何想法如何进行此转换?
我打开一个png图像到一个位图,对它进行一些修改,然后将其作为jpg保存到磁盘.在png具有一些透明区域的情况下,它们被保存为黑色.有没有办法更改此默认行为,以便使用不同的颜色背景(如白色)保存图像?
谢谢
我想用BitmapFactory.decodeFile(路径,选项)解码SD卡中的图像.
我还希望将大于2048x2048像素的图像缩小到最多2048x2048(保持比例).
我可以在获取位图后手动执行此操作,但除了已分配的字节之外,还需要分配大量字节.
我应该如何设置我的BitmapFactory.Options对象以获得该效果?
谢谢
我想以编程方式更改位图的对比度.直到现在我都试过这个.
private Bitmap adjustedContrast(Bitmap src, double value)
{
// image size
int width = src.getWidth();
int height = src.getHeight();
// create output bitmap
Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
// color information
int A, R, G, B;
int pixel;
// get contrast value
double contrast = Math.pow((100 + value) / 100, 2);
// scan through all pixels
for(int x = 0; x < width; ++x) {
for(int y = 0; y < height; ++y) {
// get pixel color
pixel …Run Code Online (Sandbox Code Playgroud) 我有一个项目将图像格式文件转换为图标文件.但是,在转换图像后,图像的颜色会发生变化.
这是我的代码
Bitmap theBitmap = new Bitmap(theImage, new Size(width, height));
IntPtr Hicon = theBitmap.GetHicon();// Get an Hicon for myBitmap.
Icon newIcon = Icon.FromHandle(Hicon);// Create a new icon from the handle.
FileStream fs = new FileStream(@"c:\Icon\" + filename + ".ico", FileMode.OpenOrCreate);//Write Icon to File Stream
Run Code Online (Sandbox Code Playgroud)

谁知道怎么解决这个问题?
如何检查Bitmap对象是否完全空白,即所有像素都是透明的,每个像素上都没有xy循环?
目前我正在开发一个加载非常大的图像的系统,最小宽度x高度= = 10.000.000像素.
但是用户上传图像的比例通常与我们的要求比率不匹配,因此我必须将其裁剪为适当的比例,但是当使用System.Drawing位图裁剪它时,我总是得到SytemOutOfMemory异常.
我尝试使用正确的RectangleF但没有运气的Bitmap.Clone和Graphic.DrawImage.
反正有没有得到outofmemory异常,或者System.Drawing库有什么替代方法可以轻松完成这项任务吗?
我的代码从用户上传文件加载图像:
var fileBinary = new byte[stream.Length];
stream.Read(fileBinary, 0, fileBinary.Length);
stream.Position = 0;
var fileExtension = Path.GetExtension(fileName);
using (Image image = Image.FromStream(stream, false, false))
{
//validation and check ratio
CropImage(image, PORTRAIT_RATIO, fileExtension);
}
Run Code Online (Sandbox Code Playgroud)
而CropImage功能:
//Crop Image from center with predefine ratio
private byte[] CropImage(Image sourceImg, float ratio, string fileExtension)
var height = sourceImg.Height;
var width = sourceImg.Width;
var isPortrait = width < height;
RectangleF croppingRec = new RectangleF();
float positionX = 0;
float positionY = …Run Code Online (Sandbox Code Playgroud)