本文整理汇总了C#中Android.Graphics.Bitmap.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.Dispose方法的具体用法?C# Bitmap.Dispose怎么用?C# Bitmap.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Bitmap
的用法示例。
在下文中一共展示了Bitmap.Dispose方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BitmapToBase64String
public static String BitmapToBase64String(Bitmap originalImage)
{
MemoryStream ms = new MemoryStream();
originalImage.Compress(Bitmap.CompressFormat.Png, 100, ms);
byte[] imageData = ms.ToArray();
originalImage.Dispose();
return Base64.EncodeToString(imageData, Base64Flags.NoWrap);
}
示例2: ScaleUpBitmap
public static Bitmap ScaleUpBitmap(Bitmap originalImage, int wantedWidth, int wantedHeight)
{
Bitmap output = Bitmap.CreateBitmap(wantedWidth, wantedHeight, Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(output);
Matrix m = new Matrix();
m.SetScale((float)wantedWidth / originalImage.Width, (float)wantedHeight / originalImage.Height);
canvas.DrawBitmap(originalImage, m, new Paint());
canvas.Dispose ();
originalImage.Dispose ();
return output;
}
示例3: DisposeBitmap
private static void DisposeBitmap(Bitmap bitmap)
{
if (bitmap != null)
{
if (!bitmap.IsRecycled)
{
bitmap.Recycle();
}
bitmap.Dispose();
}
}
示例4: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
Utils.Util.SetDisplayMetrics (Resources.DisplayMetrics);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button> (Resource.Id.btn_draw);
ImageView iv = FindViewById<ImageView> (Resource.Id.imageView_output);
button.Click += delegate {
int width = Utils.Util.DetectScreenSize().Width;
int height = Utils.Util.DetectScreenSize().Height;
if(b != null)
{
iv.SetImageBitmap(null);
}
b = DrawImages.GetImage(width,height);
iv.SetImageBitmap (b);
b.Dispose();
};
}
示例5: GetResized
static Drawable GetResized(Bitmap b, Android.Content.Res.Resources res)
{
double width = (double)b.Width;
double height = (double)b.Height;
if (width <= MaxWidth && height <= MaxHeight)
return new BitmapDrawable(res, b);
if (width > height)
{
height = height / width * MaxWidth;
width = MaxWidth;
}
else if (height > width)
{
width = width / height * MaxHeight;
height = MaxHeight;
}
else
{
width = MaxWidth;
height = MaxHeight;
}
var resized = Bitmap.CreateScaledBitmap(b, (int)width, (int)height, false);
b.Dispose();
return new BitmapDrawable(res, resized);
}
示例6: DismissBitmap
private void DismissBitmap(Bitmap bitmap)
{
if (bitmap != null)
{
bitmap.Recycle();
bitmap.Dispose();
GC.Collect();
}
}
示例7: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
intensity_arr = new string[256];
hexcijfers = new string[]{"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
int j = 0;
int k = 0;
for(int i = 0; i < 256;i++)
{
intensity_arr [i] += hexcijfers [j];
intensity_arr [i] += hexcijfers [k];
k++;
if (k == 16) {
k = 0;
j++;
}
}
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
Utils.Util.SetDisplayMetrics (Resources.DisplayMetrics);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button> (Resource.Id.btn_draw);
ImageView iv = FindViewById<ImageView> (Resource.Id.imageView_output);
SeekBar intensity = FindViewById<SeekBar> (Resource.Id.seekBar1);
int width = Utils.Util.DetectScreenSize ().Width;
int height = Utils.Util.DetectScreenSize ().Height;
intensity.ProgressChanged += (object sender, SeekBar.ProgressChangedEventArgs e) => {
if (e.FromUser) {
intensiteit = intensity_arr [e.Progress];
if (b != null) {
iv.SetImageBitmap (null);
}
b = DrawImages.GetImage (width, height,intensiteit);
iv.SetImageBitmap (b);
b.Dispose ();
//waarde.Text = string.Format ("The value of the intensity is {0}", intensity_arr[e.Progress]);
}
};
button.Click += delegate {
intensiteit = intensity_arr[intensity.Progress];
if (b != null) {
iv.SetImageBitmap (null);
}
b = DrawImages.GetImage (width, height,intensiteit);
iv.SetImageBitmap (b);
b.Dispose ();
};
}
示例8: OnLoad
// This gets called when the drawing surface is ready
protected override void OnLoad (EventArgs e)
{
base.OnLoad (e);
try {
// Clear the current Context
GraphicsContext.MakeCurrent (null);
// Create a secondary context using the same information the primary
// context was created with
backgroundContext = new AndroidGraphicsContext(GraphicsMode, WindowInfo, GraphicsContext, ContextRenderingApi, GraphicsContextFlags.Embedded);
}catch {
// secondary context not supported
backgroundContext = null;
}
MakeCurrent();
var vertexShader = LoadShader(ShaderType.VertexShader, vertexShaderCode);
var fragmentShader = LoadShader(ShaderType.FragmentShader, fragmentShaderCode);
program = GL.CreateProgram (); // create empty OpenGL Program
GL.AttachShader (program, vertexShader); // add the vertex shader to program
GL.AttachShader (program, fragmentShader); // add the fragment shader to program
GL.BindAttribLocation (program, ATTRIB_VERTEX, "position");
GL.BindAttribLocation (program, ATTRIB_TEXCOORD, "texcoord");
GL.LinkProgram (program); // create OpenGL program executables
uniformTextureLocation = GL.GetUniformLocation (program, "texture");
if (vertexShader != 0) {
GL.DetachShader (program, vertexShader);
GL.DeleteShader (vertexShader);
}
if (fragmentShader != 0) {
GL.DetachShader (program, fragmentShader);
GL.DeleteShader (fragmentShader);
}
GL.Viewport (0, 0, Width, Height);
// Run the render loop
Run ();
Task.Factory.StartNew (() => {
//Thread.Sleep(500);
// load the bitmap
bitmap = BitmapFactory.DecodeResource (Context.Resources, Resource.Drawable.f_spot);
// the device may or may not support a background Context. But rather than
// duplicating this code we just create an Action which we can invoke on this
// background thread later or queue to be executed on the rendering thread.
Action acton = new Action (() => {
GL.Enable (EnableCap.Texture2D);
GL.GenTextures(1, out textureid);
GL.ActiveTexture (TextureUnit.Texture0);
GL.BindTexture (TextureTarget.Texture2D, textureid);
// setup texture parameters
GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
Android.Opengl.GLUtils.TexImage2D ((int)TextureTarget.Texture2D, 0, bitmap, 0);
// make sure the texture is pushed to the GPU.
GL.Flush();
// make sure we free resources
bitmap.Recycle();
bitmap.Dispose();
bitmap = null;
});
// take a lock so the main rendering thread does not try to draw anything
// there are other ways to do this, but its is probably the simplest
lock (lockobject) {
if (backgroundContext != null) {
// Clear the current context bound to the Display
backgroundContext.MakeCurrent (null);
// make this context active
backgroundContext.MakeCurrent (WindowInfo);
// do our processing
acton.Invoke ();
// clear the current context again so we don't error on the main thread
backgroundContext.MakeCurrent (null);
} else {
// Secondary Context's are not supported on this device
// queue the action for execution later.
actions.Enqueue (acton);
}
}
});
}