我想使用仅在水平上平铺的Bitmap,有没有办法做到这一点,所以它只会在X上扩展,就像在CSS上重复x一样.我使用以下代码,但位图tile水平和垂直:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/pinstripe"
android:tileMode="repeat"
android:gravity ="top|fill_horizontal"
android:dither="true"/>
Run Code Online (Sandbox Code Playgroud) 我工作一个应用程序图像上传到SD卡我正在缩放sdcard保存到数据库有时一个错误发生位图大小超过vm预算
ouput :
01-11 15:39:51.809: ERROR/AndroidRuntime(6214): Uncaught handler: thread main exiting due to uncaught exception
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method)
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:384)
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:397)
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at com.fitzgeraldsoftware.shout.presentationLayer.Shout.onActivityResult(Shout.java:1653)
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at android.app.Activity.dispatchActivityResult(Activity.java:3624)
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at android.app.ActivityThread.deliverResults(ActivityThread.java:3220)
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3266)
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at android.app.ActivityThread.access$2600(ActivityThread.java:116)
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823)
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at android.os.Handler.dispatchMessage(Handler.java:99)
01-11 15:39:51.979: ERROR/AndroidRuntime(6214): at android.os.Looper.loop(Looper.java:123) …Run Code Online (Sandbox Code Playgroud) 我正从横向模式的相机保存图像.所以它以横向模式保存,然后我将横向应用于横向模式.我想旋转该图像,然后保存.例如,如果我有这个

我想顺时针旋转90度,然后将其保存到sdcard:

这是如何实现的?
我试图创建圆角矩形和背景作为重复位图.我这样写,但是在角落里得到位图.
任何人都可以帮忙吗?
background.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<stroke
android:width="1dp"
android:color="#FFFFFF" />
<corners android:radius="50dp" />
</shape>
</item>
<item>
<bitmap
android:src="@drawable/carbon_4"
android:tileMode="repeat" />
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud) **我在"thepic"变量中有位图类型的位图.
imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
String realpath=getRealPathFromURI(imageUri);
thepic = BitmapFactory.decodeFile(realpath);**
Run Code Online (Sandbox Code Playgroud) 我正在尝试将图像发送到服务器.在发送之前,我正在减小其尺寸和质量,然后解决任何轮换问题.我的问题是,在旋转图像后,当我保存它时,文件比以前更大.旋转尺寸为10092之前,旋转之后为54226
// Scale image to reduce it
Bitmap reducedImage = reduceImage(tempPhotoPath);
// Decrease photo quality
FileOutputStream fos = new FileOutputStream(tempPhotoFile);
reducedImage.compress(CompressFormat.JPEG, 55, fos);
fos.flush();
fos.close();
// Check and fix rotation issues
Bitmap fixed = fixRotation(tempPhotoPath);
if(fixed!=null)
{
FileOutputStream fos2 = new FileOutputStream(tempPhotoFile);
fixed.compress(CompressFormat.JPEG, 100, fos2);
fos2.flush();
fos2.close();
}
public Bitmap reduceImage(String originalPath)
{
// Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
o.inPurgeable = true;
o.inInputShareable = true;
BitmapFactory.decodeFile(originalPath, o);
// The new size we want to …Run Code Online (Sandbox Code Playgroud) 我想改变图像某些部分的亮度.我知道如何使用ColorMatrix来改变图像的亮度(或色调).但它将应用于整个图像.
我有一个掩码文件(黑白图像).我想仅在该蒙版的白色部分应用亮度变化.如何在Android中执行此操作?
下面是一个掩码图像和我想得到的结果.

我有两个位图,我在onCreate()中创建它们.
Bitmap bmp1 = BitmapFactory.decodeResource(getResources(),id);
Bitmap bmp2 = BitmapFactory.decodeResource(getResources(),id);
Run Code Online (Sandbox Code Playgroud)
bmp1和bmp2是一样的.我在我的应用程序中修改了bmp2.我的工作完成后,单击"清除"按钮.当我点击"清除"按钮时,我正在尝试将bmp1(清洁图像)复制到bmp2(已更改的图像).但我不想使用createBitmap()或copy()函数.因为这些是创建新的Bitmap对象.我只想使用我的两个位图(bmp1和bmp2).如何将bmp1复制到bmp2?我搜索谷歌,但无论如何使用createBitmap()或copy().
谢谢.
我正在使用Kinect传感器通过将视频输入设置为位图源来显示图像上的视频输入,如下所示.但我的问题是如何将图像添加到图像/位图,例如分数计数器,我在下面添加了一张图片来展示我想要实现的目标.
void myKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame == null) return;
byte[] colorData = new byte[colorFrame.PixelDataLength];
colorFrame.CopyPixelDataTo(colorData);
KinectVideo.Source = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96,
PixelFormats.Bgr32, null, colorData, colorFrame.Width * colorFrame.BytesPerPixel);
}
}
Run Code Online (Sandbox Code Playgroud)

我想要减少图像尺寸的功能.
该函数应该采用图像URL,检查图像是4MB大小还是更大,如果是,则将其调整为爱人然后4MB并返回字节.
我有下一个方法:
public byte[] ResizeImage(string url)
{
var uri = new Uri(url);
var c = new WebClient();
var oldImgStream = new MemoryStream(c.DownloadData(uri));
if (oldImgStream.Length <= 4194304)
{
return oldImgStream.ToArray();
}
using (var oldImage = new Bitmap(oldImgStream))
using (var newImageStream = new MemoryStream())
{
var format = oldImage.RawFormat;
float resizePercent = (float)4194304 / oldImgStream.Length;
var newImage = ResizeImageByPercent(oldImage, resizePercent);
newImage.Save(newImageStream, format);
return newImageStream.ToArray();
}
}
public static Bitmap ResizeImageByPercent(Bitmap image, float resizePercent)
{
//Set minimum resizePercentage to 80%
resizePercent = …Run Code Online (Sandbox Code Playgroud) bitmap ×10
android ×8
c# ×2
java ×2
asp.net-mvc ×1
background ×1
colorfilter ×1
colormatrix ×1
compression ×1
drawing ×1
exception ×1
image ×1
imageview ×1
memorystream ×1
pdf ×1
repeat ×1
size ×1
wpf ×1