我尝试过很多代码,看过Android开发人员,但无法使其工作.我希望搜索栏调整我的位图图像亮度
我想使用谷歌地图生成一个位图文件而不通过mapView传递数据,比如后台线程(下载切片以便编写位图)
有没有人有想法?
例如:输入坐标,单击按钮后,SD卡中会生成.png,其中包含COMPLETE加载的图块.
任何建议?
谢谢!!!
我有一个Async正在运行以从我创建的页面获取数据.它得到的文本很好,但当我尝试通过另一个类从图像src获取图像时,应用程序强制关闭.以下是强制关闭的代码:
public class FullReportActivity extends NavigationActivity {
private TextView textView;
private String url = "http://www.backcountryskiers.com/sac/sac-full.html";
private ImageView ivDangerRose;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// tell which region this covers
getSupportActionBar().setSubtitle("...from Sierra Avalanche Center");
setContentView(R.layout.activity_fullreport);
textView = (TextView) findViewById(R.id.todaysReport);
ivDangerRose = (ImageView) findViewById(R.id.dangerRose);
fetcher task = new fetcher();
task.execute();
}
// GET THE IMAGE and RETURN IT
public static Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
connection.setDoInput(true);
connection.connect(); …Run Code Online (Sandbox Code Playgroud) 目前正在尝试将C用于以前在python(pypy)中完成的工作.我想我会尝试用C语言编写它(以获得最佳速度),并使用ctypes进行通信.
现在我想做的是从Bitmap(bmp文件)中获取pixelbuffer,将其发送到C函数,该函数将原始缓冲区转换为R,G,B值的平面数组并将其返回到python.但是当我试图将"缓冲区"转换为R,G,B值时,我陷入了困境.在python中,我只需使用"struct"模块:B,G,R = struct.unpack('<BBB', buffer[i:i+3])
我该如何在C中做同样的事情?
蟒蛇:
from bmplib import Bitmap
import ctypes
lib = ctypes.CDLL('_bitmap.dll')
bmp = Bitmap()
bmp.open('4x4.bmp')
buf = bmp._rawAsArray() #Returns a array.array() of char (raw pixel-data)
addr, count = buf.buffer_info()
lib.getData.argtypes = []
arr = ctypes.cast(addr, ctypes.POINTER(ctypes.c_char))
lib.getData(arr, count) #Does not return anything yet..
Run Code Online (Sandbox Code Playgroud)
C尝试转换像素失败:
#include <stdio.h>
void getData(char *, const int);
void getData(char * array, const int length) {
int i = 0;
while(i < length) {
/* ----- Clearly wrong as i got …Run Code Online (Sandbox Code Playgroud) 我目前正在编写一个小型绘图应用程序,用户可以在Panel上绘图.我正在使用选择工具,并希望能够选择面板的某个区域,然后将此选定区域直接粘贴到我刚刚在Panel右侧的PictureBox中.
我的问题是我的代码目前无法正常工作,当我尝试从面板粘贴我正在创建的Bitmap时,我在PictureBox中获得了一个大的红色X而不是实际的图像.我知道图像正在正确地复制到Bitmap,因为我尝试在它周围放一些代码将它作为jpeg保存到磁盘,然后查看图像,它显示正常.
这是我的代码:
private void tbCopy_Click(object sender, EventArgs e)
{
int width = selectList[0].getEnd().X - selectList[0].getInitial().X;
int height = selectList[0].getEnd().Y - selectList[0].getInitial().Y;
using (Bitmap bmp = new Bitmap(width, height))
{
pnlDraw.DrawToBitmap(bmp, new System.Drawing.Rectangle(
selectList[0].getInitial().X,
selectList[0].getInitial().Y,
width, height));
pbPasteBox.Image = bmp;
}
}
Run Code Online (Sandbox Code Playgroud)
宽度和高度只是我要复制的区域的尺寸,而selectList是一个包含一个对象的List,其中包含我要复制的区域的坐标.
任何帮助将不胜感激.
我正在用几个位图构建一个Bitmap.我所做的是调用多个返回Task的方法.
我遇到的问题是死锁,因为我试图通过.Result从.ContinueWith()中的异步方法中检索值,这不起作用,因为它将异步方法转换为同步方法,这导致我陷入僵局.
我的问题是如何调用.ContinueWith中的异步方法,以及实现这种方法的正确方法是什么?
我需要删除.Result并正确调用异步方法任务.什么是正确的方法?
这是我的代码.
public async static Task<Bitmap> RollUpDrawingsImage(IElevation elevation)
{
int height = 0, width = 800;
Bitmap completeDrawings = null;
using (Bitmap elevationDoor = await ShopDrawing.Merger.MergeElevationAndDoor(elevation, RotateFlipType.Rotate90FlipNone))
{
using (Bitmap partsList = await MaterialsList.Manager.GetMaterialList(elevation).ContinueWith(async (ml) => await ml.Result.GetDrawing()).Result)
{
using (Bitmap optimized = await Optimization.Manager.GetOptimizedParts(elevation).ContinueWith(async (op) => await op.Result.GetDrawing()).Result)
{
using (Bitmap cutSheet = await CutSheet.Manager.GetCutSheet(elevation).ContinueWith(async (cs) => await cs.Result.GetDrawing()).Result)
{
height = (elevationDoor.Height + optimized.Height + cutSheet.Height + partsList.Height);
completeDrawings = new Bitmap(width, height + 40); …Run Code Online (Sandbox Code Playgroud) 在构建位图并共同构建一些位图并将它们组合到一个位图中时,它对.MakeTransparent()有帮助.
或者,在我将Bitmap发送到请求客户端之前,如果我.MakeTransparent()它会变小吗?不是宽度或高度,以字节为单位购买?
换句话说,.MakeTransparent()会优化Bitmap,如果不是,有人会在通过互联网通过网络发送到请求客户端之前获得有关如何优化Bitmap的任何建议吗?
有问题的代码是 sheet.MakeTransparent()
internal static Task<Bitmap> GetDoorSecheduleSheetAsync(ShopDrawing.DoorSchedules schedules, RotateFlipType rotate, byte schedulesPerSheet, byte currentI)
{
return Task.Run(() =>
{
var sheet = new Bitmap(DrawingOptions.PAGE_HEIGHT_SIZE, DrawingOptions.PAGE_WIDTH_SIZE);
sheet.SetResolution(150, 150);
byte scheduleCnt = 0;
float prevWidth = 0;
using (Graphics dc = Graphics.FromImage(sheet))
{
dc.Clear(Color.White);
using (Pen pen = new Pen(Color.FromArgb(80, Color.Black), 4))
{
for (; currentI < schedules.Count(); currentI++)
{
if (scheduleCnt > 0)
{
dc.DrawLine(pen, prevWidth, 380/*need constant for start height*/, prevWidth, sheet.Height);
};
using (var doorSchedule = schedules[currentI].Door) …Run Code Online (Sandbox Code Playgroud) 实际上我正在尝试用壁纸创建简单的应用程序.
我正在尝试将我的图像缩放到用户设备屏幕大小.我正在使用像下面这样的代码:
/*
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
*/
Display metrics = getWindowManager().getDefaultDisplay();
int height = metrics.getHeight();
int width = metrics.getWidth();
float fourToThree;
int wymiar;
Bitmap mbitmap; //definicja zmiennej przechowuj?cej bitmap?
try {
Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), cardBase.cardImages[position]);
//UP - zapisanie obrazu z tablicy do zmiennej bitmapy
/*if(height>=width) {
fourToThree = height * 0.75f; //height
wymiar = (int)Math.round(fourToThree);
mbitmap = Bitmap.createScaledBitmap(myBitmap, height, wymiar, true);
} else {
fourToThree = height * …Run Code Online (Sandbox Code Playgroud) 我需要从HTML5 Canvas中获取1位位图.
画布是黑白的.但是,我只能使用带有png/jpeg输出的toUrlData(),但找不到任何生成位图的方法(并将颜色深度更改为1位).
这种转换有什么可用的解决方案吗?或者也许是一个可以编写位图图像的javascript库?
我完成了获得灰度值,但我不知道如何使用函数将灰度转换为二进制图像.请帮帮我,这里是我的功能代码:
public Bitmap toBinary(Bitmap bmpOriginal) {
int width, height, threshold;
height = bmpOriginal.getHeight();
width = bmpOriginal.getWidth();
threshold = 127;
final Bitmap bmpBinary = null;
for(int x = 0; x < width; ++x) {
for(int y = 0; y < height; ++y) {
// get one pixel color
int pixel = bmpOriginal.getPixel(x, y);
//get grayscale value
int gray = (int)(pixel & 0xFF);
//get binary value
if(gray < threshold){
bmpBinary.setPixel(x, y, 0);
} else{
bmpBinary.setPixel(x, y, 255);
}
}
}
return bmpBinary; …Run Code Online (Sandbox Code Playgroud) bitmap ×10
android ×5
c# ×3
.net-4.5 ×1
arrays ×1
async-await ×1
binary ×1
brightness ×1
c ×1
canvas ×1
copy ×1
ctypes ×1
graphics ×1
grayscale ×1
html5 ×1
image ×1
javascript ×1
maps ×1
optimization ×1
paste ×1
picturebox ×1
python ×1
scale ×1
seekbar ×1