我希望在通知中清楚一点BigPictureStyle位图的图像大小.
我已经阅读了一些教程,但无法找到有关此位图的大小规格.
有人告诉他们有2:1的宽高比.
我想要一些清晰度,比如建议的位图/图像大小
NotificationCompat.BigPictureStyle s = new NotificationCompat.BigPictureStyle().bigPicture(bitmap_image);
s.setSummaryText("Summary text appears on expanding the notification");
notificationBuilder.setStyle(s);
Run Code Online (Sandbox Code Playgroud)
请指导我完成这个.
notifications android bitmap push-notification android-notifications
我正在用android进行原生开发.我不能在java中使用OpenCV.我将Bitmap作为jni的输入.我找到了一种转换Bitmap-> Mat的方法.然后我可以处理()Mat图像类型.现在我需要重新转换处理后的Mat-> Bitmap并将其发送到java文件.
我无法找到关于如何在jni c ++中完成Mat-> Bitmap转换的任何帖子.
如果我能就此得到任何建议,那将是非常有帮助的
我需要加载尺寸为2450 x 2450像素的大图像.
Bitmap bitmap = ImageLoader.getInstance().loadImageSync(url,
ImageConfig.getImageOptions());
Run Code Online (Sandbox Code Playgroud)
问题是,在低端设备(内存小于1 GB的手机)上,出现内存不足的情况.
这是我的DisplayImageOptions
public static DisplayImageOptions getImageOptions() {
DisplayImageOptions.Builder options = new DisplayImageOptions.Builder();
options.delayBeforeLoading(10)
//The reason I'm using ARGB_8888 because I need to load bitmap without losing it's quality
.bitmapConfig(Bitmap.Config.ARGB_8888)
.imageScaleType(ImageScaleType.NONE)
//I'm not using disk or memory cache
.cacheOnDisk(false)
.cacheInMemory(false);
return options.build();
}
Run Code Online (Sandbox Code Playgroud)
我尝试根据设备分辨率添加目标大小,但它不起作用,加载的位图仍然具有2450 x 2450像素的尺寸.
int height = orientation == Configuration.ORIENTATION_PORTRAIT ?
displaymetrics.heightPixels : displaymetrics.widthPixels;
Bitmap bitmap = ImageLoader.getInstance().loadImageSync(imageUri,
new ImageSize(height, height), ImageConfig.getImageOptions());
Run Code Online (Sandbox Code Playgroud)
我试图将imageScaleType更改为ImageScaleType.EXACTLY,加载位图大小调整为1225 x 1225像素,在所有设备上,我需要获得高端设备的原始尺寸,并调整低端设备的尺寸.
主要问题是目标尺寸不起作用 …
在Android中,如何将Bitmap对象转换为android.media.image对象?我的代码是:
Bitmap frame;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
frame.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] byteArray = stream.toByteArray();
Run Code Online (Sandbox Code Playgroud)
如何在android.media.image中写入bytearray?
谢谢,
我有一个来自我的其余API的图片网址.现在我想在加载活动时将其设置为imageview.下面是我如何从其余的api获取bean,然后从中获取URL.
Message message=new Message();
String imageUrl=message.getImageUrl();
Run Code Online (Sandbox Code Playgroud)
我从我的数据库中获取Message对象,并且图像url包含在该Message对象中.
然后我使用Url对象获取该图像的URL.
URL url = null;
try {
url = new URL(imageUrl);
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
contentImageView.setImageBitmap(bmp);
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我使用上面的代码将图像加载到imageview对象contentImageView.
但我仍然无法将此图像加载到imageview,没有任何东西被加载.
有什么想法吗?
我把位图作为BYTE数组保存,它以微软CBitmap类的非常相似和可互换的格式保存每个像素的RGB值.所以让我们考虑一下我有一个CBitmaps数组,我想用MediaFoundation Transcode Api将它们转换为mp4,如下例所示:toMp4.但是在此示例中,它们从URL流式传输.
// Use the source resolver to create the media source
hr = pResolver->CreateObjectFromURL(pszURL, MF_RESOLUTION_MEDIASOURCE, NULL, &ObjectType, &pSource);
Run Code Online (Sandbox Code Playgroud)
在我的情况下,我的记忆中有我的位图.所以我相信我可以使用这个功能.IMFSourceResolver :: CreateObjectFromByteStream
我不确定这是否可行.总结如何使用转码api将我的CBitmap数组转换为mp4?
我正在使用Custom TG2480-H打印机打印收据.除了徽标外,我已收到所有收据.
我有一个.bmp代表徽标的单色文件,并且具有正确的尺寸.
我正在使用不同的响应类型检索文件:
this.http.get('/assets/images/brand/logo-bnw.bmp', {
responseType: ResponseContentType.Blob
}).subscribe((response: Response) => {
console.log('Blob bytes', this.kiowarePrintService.getBytesFromText(response.text()));
});
this.http.get('/assets/images/brand/logo-bnw.bmp', {
responseType: ResponseContentType.Text
}).subscribe((response: Response) => {
console.log('Text bytes', this.kiowarePrintService.getBytesFromText(response.text()));
});
this.http.get('/assets/images/brand/logo-bnw.bmp', {
responseType: ResponseContentType.ArrayBuffer
}).subscribe((response: Response) => {
console.log('ArrayBuffer bytes', this.kiowarePrintService.getBytesFromText(response.text()));
});
Run Code Online (Sandbox Code Playgroud)
这是关于ResponseContentType的文档以及它可以具有的不同值.
这是以下代码getBytesFromText:
getBytesFromText(text: string) {
const bytes: number[] = [];
for (let i = 0; i < text.length; i++) {
bytes.push(text.charCodeAt(i));
}
return bytes;
}
Run Code Online (Sandbox Code Playgroud)
将响应转换为字节会打印以下值:
Blob bytes (2) [123, 125]
Text bytes (951) …Run Code Online (Sandbox Code Playgroud) 我目前正在使用Bitmap,并尝试对像素进行一些操作。我想使用Color.argb(),Color.valueOf()但是对于API Level <26而言,这些功能不起作用。
是否有任何库或类似的东西可以与任何API Level> 21一起使用?
这是我使用的部分功能:
int width = myBitmap.getWidth();
int height = myBitmap.getHeight();
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
int [] allpixels = new int [ bmp.getHeight()*bmp.getWidth()];
myBitmap.getPixels(allpixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(),bmp.getHeight());
bmp.setPixels(allpixels, 0, width, 0, 0, width, height);
for(int i =0; i<bmp.getHeight()*bmp.getWidth();i++) {
allpixels[i] = Color.argb(
Color.valueOf(allpixels[i]).red(),
Color.valueOf(allpixels[i]).red(),
Color.valueOf(allpixels[i]).green(),
Color.valueOf(allpixels[i]).blue());
}
Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码在Android中向图像添加文本:
public Bitmap drawTextToBitmap(Context gContext, Bitmap image, String gText) {
Resources resources = gContext.getResources();
float scale = resources.getDisplayMetrics().density;
android.graphics.Bitmap.Config bitmapConfig =
image.getConfig();
// set default bitmap config if none
if(bitmapConfig == null) {
bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
}
// resource bitmaps are imutable,
// so we need to convert it to mutable one
Bitmap bitmap = null;
try{
bitmap = image.copy(bitmapConfig, true);
image.recycle();
Canvas canvas = new Canvas(bitmap);
// new antialised Paint
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
// text color - …Run Code Online (Sandbox Code Playgroud) 我使用OpenCV进行图像处理。我想反转此位图(黑到白,白到黑),但我有一些问题。
我这样做后得到了这个位图:
// to grey
Imgproc.cvtColor(mat, mat, Imgproc.COLOR_RGB2GRAY, 4);
Imgproc.adaptiveThreshold(mat, mat, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY_INV, 15, 4);
Utils.matToBitmap(mat, bitmapCopy);
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
// to grey
Imgproc.cvtColor(mat, mat, Imgproc.COLOR_RGB2GRAY, 4);
Imgproc.adaptiveThreshold(mat, mat, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY_INV, 15, 4);
Utils.matToBitmap(mat, bitmapCopy);
for(int y = 0; y < bitmapCopy.getHeight(); y++){
for(int x = 0; x < bitmapCopy.getWidth(); x++){
int pixel = bitmapCopy.getPixel(x,y);
if (pixel == Color.WHITE){
bitmapCopy.setPixel(x, y, Color.BLACK);
} else {
bitmapCopy.setPixel(x, y, Color.WHITE);
}
}
}
Run Code Online (Sandbox Code Playgroud)
第一张图片中的白线应反转为黑线,但不起作用。我使用Adobe Photoshop检查了文件。当我指向图像的白色区域时,它表明颜色是白色(#FFFFFF)。
我想念什么?有人可以启发我吗?