我正在使用一个Android平板电脑应用程序,其中许多工作与图像.
我必须在滚动视图中加载数百个大位图图像.一幅图像大约是1Mb到3Mb.
我已经使用位图工厂和样本大小缩放图像,并且还在Async任务中加载所有图像.
我正在加载SD卡的所有图像.
滚动一些图像后仍然面临OUT OF MEMORY问题.任何帮助,将不胜感激.提前致谢.
我尝试将base64字符串转换为位图,但后来我得到一个黑色图像..这是我用来解码的脚本:
function Base64ToBitmap(const S: string): TBitmap;
var
SS: TStringStream;
V: string;
begin
V := Decode(S);
SS := TStringStream.Create(V);
try
Result := TBitmap.Create;
Result.LoadFromStream(SS);
finally
SS.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
这是解码脚本:
function Decode(const Input: AnsiString): string;
var
bytes: TBytes;
utf8: UTF8String;
begin
bytes := EncdDecd.DecodeBase64(Input);
SetLength(utf8, Length(bytes));
Move(Pointer(bytes)^, Pointer(utf8)^, Length(bytes));
Result := string(utf8);
end;
Run Code Online (Sandbox Code Playgroud)
BitMap到base64
function BitmapToBase64(ABitmap: TBitmap): string;
var
SS: TStringStream;
V: string;
begin
SS := TStringStream.Create('');
try
ABitmap.SaveToStream(SS);
V := SS.DataString;
Result := Encode(V);
finally
SS.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
编码:
function Encode(const …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作全屏截图并将其加载到pictureBox中,但它给了我这个错误: System.Drawing.dll中出现类型'System.ArgumentException'的第一次机会异常附加信息:Ongeldige参数.
码:
using (Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height))
{
using (Graphics g = Graphics.FromImage(bmpScreenCapture))
{
g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0, 0,
bmpScreenCapture.Size,
CopyPixelOperation.SourceCopy);
}
pictureBox1.Image = bmpScreenCapture;
}
Run Code Online (Sandbox Code Playgroud)
Joery.
我有两种形式.
我需要屏幕拍摄第一张表格,而不是将其放在表格2的顶部,也不包括表格2中的内容.
以下是我正在使用的一些内容,我正在努力解决这个问题.
Private Function TakeScreenShot(ByVal Control As Control) As Bitmap
Dim Screenshot As New Bitmap(Control.Width, Control.Height)
Control.DrawToBitmap(Screenshot, New Rectangle(0, 0, Control.Width, Control.Height))
Return Screenshot
End Function
Run Code Online (Sandbox Code Playgroud)
此功能无效,因为Control.drawtoBitmap未设置IMG的值.
IMG是空白的,并以纯白图像的形式返回.
这个函数的调用就是这个
TakeScreenShot(form1.webbrowser1).Save("c:\Screenshot.png",
System.Drawing.Imaging.ImageFormat.Png)
Run Code Online (Sandbox Code Playgroud)
所有帮助将不胜感激.
我试着以这种方式写文本,但它不起作用,我不明白我错在哪里.
mImageView.buildDrawingCache();
Bitmap bmap = mImageView.getDrawingCache();
Canvas c = new Canvas (bmap);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStyle(Style.FILL);
paint.setTextSize(20);
c.drawText("Some Text", 0, 25, paint);
Run Code Online (Sandbox Code Playgroud)
我试过几次,但显示器无法显示任何文字.我必须确保此图像随后与书面文本一起保存.谢谢
我一直无法将视频转换为8位BMP帧。如何使用FFmpeg进行转换?或有建议软件可以做到这一点?
我的问题很简单 - 如何将MovieClip(从库中拖出)转换为bitmapData?
PS:我已经搜索了一下这个解决方案,但我得到的唯一结果是另一种方法 - 将bitmapData转换为MC/Sprite/bitmap
所以我有一堆我希望垂直附加的图像:
convert *.png -append output.png
Run Code Online (Sandbox Code Playgroud)
但是我遇到了两个问题:
如何居中对齐所有图像并指定它们之间的间距?
好吧,所以这段代码就在Android开发者网站上,该网站设置ImageView为Bitmap:
class BitmapWorkerTask extends AsyncTask<Integer, Void, Bitmap> {
private final WeakReference<ImageView> imageViewReference;
private int data = 0;
public BitmapWorkerTask(ImageView imageView) {
// Use a WeakReference to ensure the ImageView can be garbage collected
imageViewReference = new WeakReference<ImageView>(imageView);
}
// Decode image in background.
@Override
protected Bitmap doInBackground(Integer... params) {
data = params[0];
return decodeSampledBitmapFromResource(getResources(), data, 100, 100));
}
// Once complete, see if ImageView is still around and set bitmap.
@Override
protected void onPostExecute(Bitmap bitmap) { …Run Code Online (Sandbox Code Playgroud) 我试图修复Android摄像头意图保存图像景观时拍摄肖像问题,但遇到了dalvikvm-heap Out of memory on a 63489040-byte allocation.错误的问题.我看了一下createBitmap()引导我进入java.lang.OutOfMemoryError,但这个问题没有任何帮助.我不知道如何解决这个问题.我试着调用recycle()位图,但这不起作用.
String file = getRealPathFromURI(Uri.parse(mUriString));
BitmapFactory.Options bounds = new BitmapFactory.Options();
bounds.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file, bounds);
BitmapFactory.Options opts = new BitmapFactory.Options();
Bitmap bm = BitmapFactory.decodeFile(file, opts);
ExifInterface exif = new ExifInterface(file);
String orientString = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
int orientation = orientString != null ? Integer.parseInt(orientString) : ExifInterface.ORIENTATION_NORMAL;
int rotationAngle = 0;
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
rotationAngle = 90;
case ExifInterface.ORIENTATION_ROTATE_180:
rotationAngle = 180;
case ExifInterface.ORIENTATION_ROTATE_270:
rotationAngle = 270; …Run Code Online (Sandbox Code Playgroud)