我从相机获取预览数据.它采用NV21格式.我想将预览保存到SD卡,即位图.我的代码是获取图像并保存它,但在图库中它没有捕获预览.它只是黑色矩形,这是代码.
public void processImage() {
Bitmap bitmap = null;
if (flag == true) {
flag = false;
if (mCamera != null) {
Camera.Parameters parameters = mCamera.getParameters();
int imageFormat = parameters.getPreviewFormat();
if (imageFormat == ImageFormat.NV21) {
Toast.makeText(mContext, "Format: NV21", Toast.LENGTH_SHORT)
.show();
int w = parameters.getPreviewSize().width;
int h = parameters.getPreviewSize().height;
YuvImage yuvImage = new YuvImage(mData, imageFormat, w, h,
null);
Rect rect = new Rect(0, 0, w, h);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
yuvImage.compressToJpeg(rect, 100, baos);
byte[] jData = baos.toByteArray();
bitmap = BitmapFactory.decodeByteArray(jData, …Run Code Online (Sandbox Code Playgroud) 我有一个带有背景图像的画布。我需要知道是否有可能清除此画布上的涂料以重绘而不清除其背景图像。这是我的示例以及到目前为止的结果。
爪哇
public void setCanvas() {
if(mFile != null && mFile.exists()) {
mPictureBitmap = BitmapFactory.decodeFile(mFile.getAbsolutePath());
mBitmap = Bitmap.createScaledBitmap(mPictureBitmap, mImageView.getWidth(), mImageView.getHeight(), false);
mBitmap = mBitmap.copy(Bitmap.Config.ARGB_8888, true);
mCanvas = new Canvas(mBitmap);
mImageView.setImageBitmap(mBitmap);
mImageView.setOnTouchListener(this);
}
}
private void draw() {
mCanvas.drawColor(Color.TRANSPARENT, Mode.CLEAR); // THIS LINE CLEARS
int lastIndex = mCordHashMap.size() - 1;
int index = 0;
for (LinkedHashMap.Entry<String, ArrayList<Circle>> entry : mCordHashMap.entrySet()) {
ArrayList<Circle> coords = new ArrayList<Circle>();
coords = entry.getValue();
Path path = new Path();
String key = entry.getKey();
String surface = …Run Code Online (Sandbox Code Playgroud) 我试图了解Windows工具栏的行为 - 特别是以下值如何交互:
按钮显示的文本与我的情况无关.
我真正想要做的是为用户提供一个选项,这样他就可以从几个工具栏按钮大小中选择(显示16x16,32x32或48x48像素的位图),并在选项值更改后相应地重新显示工具栏.这是通过销毁工具栏的图像列表并使用适当的位图重建它们来实现的.我目前遇到的问题是,当从大小16切换到48并返回到大小16时,工具栏看起来与以前略有不同.
这是应用程序启动时工具栏的样子(正确):

一旦我切换到48号并再次返回,它看起来像这样(错误):

所有按钮都比以前更高,每个下拉按钮在其位图及其下拉箭头周围都有额外的空间.
(出于测试目的,工具栏已经足够高,可以容纳所有按钮大小,而不需要增加高度.这是为了排除按钮大小的变化源于可能的工具栏调整大小的必要性,需要暂时切换到大小48.)
看起来好像在按钮位图和按钮边缘之间呈现了额外的填充 - 好像用较大的位图/按钮重建工具栏会导致Windows内部增加填充(这是有意义的),但是当我随后重建时不会减少它具有较小位图/按钮的工具栏.但是,发送TB_GETPADDING始终返回0x00060007,这表示16x16位图的标准(正确)填充已到位.
为了通过自己设置填充来解决问题,我在所有非分隔符按钮上设置TBSTYLE_AUTOSIZE样式(这是为了应用填充所必需的).使用这种样式,甚至没有调用TB_SETPADDING,切换到48后再返回,工具栏如下所示:

在这种情况下,按钮高度也是错误的.
问题是:在重建图像列表后,导致按钮显示的原因是什么?
一些备注:
只是尝试使用:
var context = CGBitmapContextCreate(nil,
self.bounds.width as UInt,
self.bounds.height as UInt,
8,
nil,
CGColorSpaceCreateDeviceRGB(),
kCGBitmapByteOrder32Big)
Run Code Online (Sandbox Code Playgroud)
但它说这kCGBitmapByteOrder32Big是未解决的标识符.但是我在stackoverflow中找到了很多这样的例子,但是对于objectiveC.问:如何初始化/获取CGBitmapInfo
正确的语法:
var context:CGContextRef = CGBitmapContextCreate(nil,
UInt(self.bounds.width),
UInt(self.bounds.height),
8,
0,
CGColorSpaceCreateDeviceRGB(),
CGBitmapInfo.ByteOrder32Big)
Run Code Online (Sandbox Code Playgroud) 在Android Studio你可以在调试器中查看图作为描述在这里:
在调试时,您现在可以右键单击应用程序中Bitmap类型的变量,并调用View Bitmap

有没有办法做到这一点Eclipse?我不想在SD卡上保存位图.
我们已经尝试了Android和PHP的这个代码.请看下面的代码.
Android的
Scn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// Open default camera
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// start the image capture Intent
startActivityForResult(intent, 100);
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 100 && resultCode == RESULT_OK) {
selectedImage = intent.getData();
imageBitmap = (Bitmap) intent.getExtras().get("data");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 40, baos);
imageView1.setImageBitmap(imageBitmap);
byte[] imageBytes = baos.toByteArray();
String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
submitData(encodedImage);
} …Run Code Online (Sandbox Code Playgroud) 我现在能够模糊整个位图(例如通过调整大小而不是向上调整大小).
我想要实现的效果是选择性模糊:结果位图会模糊,减去它的圆形/椭圆形部分,它仍然是锐利的:

困难的部分是尖锐的椭圆形部分可能更小或更大,并且应该是可移动的(其坐标并不总是原始位图的中心).
我已经找到了解决方案,但我认为它不是一个性能良好的解决方案:

另一种解决方案可以是重新创建模糊算法,该算法将贯穿原始位图的每个像素并且根据位图的部分应用更高或更低的模糊量.
旋转位图我遇到了很多麻烦.下面的代码有效,但它比Galaxy Note 2手机附带的Gallery应用程序慢4-6倍.
码:
File DirectoryFile = new File(Image_Path);
Bitmap bitmap = BitmapFactory.decodeFile(DirectoryFile.getAbsolutePath());
String imagePATH = FileLocation + "test.jpg";
final File newfile = new File(imagePATH);
FileOutputStream mFileOutputStream = null;
try {
mFileOutputStream = new FileOutputStream(newfile);
} catch (FileNotFoundException e1) { }
try {
Bitmap RotatedBitmap = RotateImage(imagePATH, bitmap);
RotatedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, mFileOutputStream);
bitmap.recycle();
RotatedBitmap.recycle();
mFileOutputStream.flush();
mFileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
private Bitmap RotateImage(String filePath, Bitmap bitmap) throws IOException {
ExifInterface exif = new ExifInterface(filePath);
int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, …Run Code Online (Sandbox Code Playgroud) 我是Android新手.我正在开发一个项目,我将获得无线电信号值(我可以从API获取值).我有一个平面图.平面图有厨房,大厅,卧室部分..如果我点击厨房部分,我需要在该部分放置一个带有无线电信号值的Pin图像.单击"保存"后,我需要锁定该特定部分中的图像(带有值).同样,我可以根据要求放置许多Pin图像.
请给我一些相关的链接或示例代码来开发它.我附上了图片供您参考.任何帮助将非常感激.

我试图用我的图像的RGB值对一些值进行异或,保存该图像并执行后退步骤,以获得原始图像.问题是,我不知道为什么我不清楚(有一些噪音)图像.这是我的代码,下面是一张图片:
Bitmap original = new Bitmap("D:\\img\\1.jpg");
Bitmap inp_bmp = new Bitmap("D:\\img\\1.jpg");
int width = inp_bmp.Width;
int height = inp_bmp.Height;
Color pixel;
for (int y = 0; y < height; y += 1)
{
for (int x = 0; x < width; x += 1)
{
pixel = inp_bmp.GetPixel(x, y);
int a = pixel.A;
int r = (pixel.R ^ (1000))%256;
int g = (pixel.G ^ (185675))%256;
int b = (pixel.B ^ (78942))%256;
inp_bmp.SetPixel(x, y, Color.FromArgb(a, r, g, b));
}
}
pictureBox2.Image …Run Code Online (Sandbox Code Playgroud)