public virtual void setImageBitmap(android.graphics.Bitmap bm) { // if this is used frequently, may handle bitmaps explicitly // to reduce the intermediate drawable object setImageDrawable(new android.graphics.drawable.BitmapDrawable(mContext.getResources (), bm)); }
public static Drawable getDrawableWithNumber(Drawable baseDrawable, int number, int iconSize, Context context) { if (number < 0 || number > 9) { number = 0; } Drawable numberDrawable = context.Resources.getDrawable(R.drawable.number_round); if (numberDrawable == null) { return(baseDrawable); } int appIconShift = context.Resources.getDimensionPixelOffset(R.dimen.ord_app_icon_shift); Bitmap bitmap = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); int textSize = context.Resources.getDimensionPixelSize(R.dimen.number_icon_text_size); int textColor = context.Resources.getColor(R.color.fc_app_icon_number_color); TextDrawable textDrawable = new TextDrawable(number.ToString(), textSize, textColor); baseDrawable.setBounds(0, 0, iconSize, iconSize); baseDrawable.draw(canvas); numberDrawable.setBounds(iconSize - (appIconShift + numberDrawable.IntrinsicWidth), appIconShift, iconSize - (appIconShift), appIconShift + numberDrawable.IntrinsicHeight); numberDrawable.draw(canvas); textDrawable.setBounds(iconSize - (appIconShift + numberDrawable.IntrinsicWidth), appIconShift, iconSize - (appIconShift), appIconShift + numberDrawable.IntrinsicHeight); textDrawable.draw(canvas); return(new BitmapDrawable(context.Resources, bitmap)); }
private void printBitmap() { string pathName = mTextView.Text.ToString(); Bitmap bitmap = null; if (pathName.Length == 0) { mImageView.buildDrawingCache(); bitmap = mImageView.DrawingCache; } EditText editText = (EditText)findViewById(R.id.editText1); int horizontalStartPosition = int.Parse(editText.Text.ToString()); editText = (EditText)findViewById(R.id.editText2); int verticalStartPosition = int.Parse(editText.Text.ToString()); editText = (EditText)findViewById(R.id.editText3); int width = int.Parse(editText.Text.ToString()); editText = (EditText)findViewById(R.id.editText4); int level = int.Parse(editText.Text.ToString()); if (bitmap == null) { MainActivity.mBixolonLabelPrinter.drawBitmap(pathName, horizontalStartPosition, verticalStartPosition, width, level); } else { MainActivity.mBixolonLabelPrinter.drawBitmap(bitmap, horizontalStartPosition, verticalStartPosition, width, level); } MainActivity.mBixolonLabelPrinter.print(1, 1); }
/// <summary> /// Synonym for opening the given resource and calling /// <see cref="decodeResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, Rect, Options) /// ">decodeResourceStream(android.content.res.Resources, android.util.TypedValue, java.io.InputStream, Rect, Options) /// </see> /// . /// </summary> /// <param name="res">The resources object containing the image data</param> /// <param name="id">The resource id of the image data</param> /// <param name="opts"> /// null-ok; Options that control downsampling and whether the /// image should be completely decoded, or just is size returned. /// </param> /// <returns> /// The decoded bitmap, or null if the image data could not be /// decoded, or, if opts is non-null, if opts requested only the /// size be returned (in opts.outWidth and opts.outHeight) /// </returns> public static android.graphics.Bitmap decodeResource(android.content.res.Resources res, int id, android.graphics.BitmapFactory.Options opts) { android.graphics.Bitmap bm = null; java.io.InputStream @is = null; try { android.util.TypedValue value = new android.util.TypedValue(); @is = res.openRawResource(id, value); bm = decodeResourceStream(res, value, @is, null, opts); } catch (System.Exception) { } finally { try { if (@is != null) { @is.close(); } } catch (System.IO.IOException) { } } // Ignore if (bm == null && opts != null && opts.inBitmap != null) { throw new System.ArgumentException("Problem decoding into existing bitmap"); } return(bm); }
/// <summary>Create a drawable projection from a bitmap to nine patches.</summary> /// <remarks>Create a drawable projection from a bitmap to nine patches.</remarks> /// <param name="bitmap">The bitmap describing the patches.</param> /// <param name="chunk"> /// The 9-patch data chunk describing how the underlying /// bitmap is split apart and drawn. /// </param> /// <param name="srcName">The name of the source for the bitmap. Might be null.</param> public NinePatch(android.graphics.Bitmap bitmap, byte[] chunk, string srcName) { // Useful for debugging mBitmap = bitmap; mChunk = chunk; mSrcName = srcName; validateNinePatchChunk(mBitmap.nativeInstance, chunk); }
/// <summary>Call this to create a new shader that will draw with a bitmap.</summary> /// <remarks>Call this to create a new shader that will draw with a bitmap.</remarks> /// <param name="bitmap">The bitmap to use inside the shader</param> /// <param name="tileX">The tiling mode for x to draw the bitmap in.</param> /// <param name="tileY">The tiling mode for y to draw the bitmap in.</param> public BitmapShader(android.graphics.Bitmap bitmap, android.graphics.Shader.TileMode ?tileX, android.graphics.Shader.TileMode?tileY) { mBitmap = bitmap; android.graphics.Bitmap.NativeBitmap b = bitmap.nativeInstance; native_instance = nativeCreate(b, (int)tileX, (int)tileY); native_shader = nativePostCreate(native_instance, b, (int)tileX, (int)tileY); }
/// <summary>Call this to create a new shader that will draw with a bitmap.</summary> /// <remarks>Call this to create a new shader that will draw with a bitmap.</remarks> /// <param name="bitmap">The bitmap to use inside the shader</param> /// <param name="tileX">The tiling mode for x to draw the bitmap in.</param> /// <param name="tileY">The tiling mode for y to draw the bitmap in.</param> public BitmapShader(android.graphics.Bitmap bitmap, android.graphics.Shader.TileMode ? tileX, android.graphics.Shader.TileMode? tileY) { mBitmap = bitmap; android.graphics.Bitmap.NativeBitmap b = bitmap.nativeInstance; native_instance = nativeCreate(b, (int)tileX, (int)tileY); native_shader = nativePostCreate(native_instance, b, (int)tileX, (int)tileY); }
/// <summary> /// Create drawable from raw nine-patch data, setting initial target density /// based on the display metrics of the resources. /// </summary> /// <remarks> /// Create drawable from raw nine-patch data, setting initial target density /// based on the display metrics of the resources. /// </remarks> public NinePatchDrawable(android.content.res.Resources res, android.graphics.Bitmap bitmap, byte[] chunk, android.graphics.Rect padding, string srcName) : this(new android.graphics.drawable.NinePatchDrawable.NinePatchState(new android.graphics.NinePatch (bitmap, chunk, srcName), padding), res) { // dithering helps a lot, and is pretty cheap, so default is true // These are scaled to match the target density. mNinePatchState.mTargetDensity = mTargetDensity; }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: private void showPicture(final android.graphics.Bitmap bitmap) private void showPicture(Bitmap bitmap) { // TODO: Remove when SDK invokes callback on calling thread runOnUiThread(() => { pictureImageView.ImageBitmap = bitmap; pictureDialog.show(); }); }
public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { base.inflate(r, parser, attrs); android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.NinePatchDrawable); int id = a.getResourceId([email protected]_src, 0); if (id == 0) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <nine-patch> requires a valid src attribute"); } bool dither = a.getBoolean([email protected]_dither , DEFAULT_DITHER); android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory .Options(); if (dither) { options.inDither = false; } options.inScreenDensity = android.util.DisplayMetrics.DENSITY_DEVICE; android.graphics.Rect padding = new android.graphics.Rect(); android.graphics.Bitmap bitmap = null; try { android.util.TypedValue value = new android.util.TypedValue(); java.io.InputStream @is = r.openRawResource(id, value); bitmap = android.graphics.BitmapFactory.decodeResourceStream(r, value, @is, padding , options); @is.close(); } catch (System.IO.IOException) { } // Ignore if (bitmap == null) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <nine-patch> requires a valid src attribute"); } else { if (bitmap.getNinePatchChunk() == null) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <nine-patch> requires a valid 9-patch source image"); } } setNinePatchState(new android.graphics.drawable.NinePatchDrawable.NinePatchState( new android.graphics.NinePatch(bitmap, bitmap.getNinePatchChunk(), "XML 9-patch" ), padding, dither), r); mNinePatchState.mTargetDensity = mTargetDensity; a.recycle(); }
public override int getOpacity() { if (mBitmapState.mGravity != android.view.Gravity.FILL) { return(android.graphics.PixelFormat.TRANSLUCENT); } android.graphics.Bitmap bm = mBitmap; return((bm == null || bm.hasAlpha() || mBitmapState.mPaint.getAlpha() < 255) ? android.graphics.PixelFormat .TRANSLUCENT : android.graphics.PixelFormat.OPAQUE); }
/// <hide></hide> public NinePatch(android.graphics.NinePatch patch) { mBitmap = patch.mBitmap; mChunk = patch.mChunk; mSrcName = patch.mSrcName; if (patch.mPaint != null) { mPaint = new android.graphics.Paint(patch.mPaint); } validateNinePatchChunk(mBitmap.nativeInstance, mChunk); }
/// <summary>Construct a canvas with the specified bitmap to draw into.</summary> /// <remarks> /// Construct a canvas with the specified bitmap to draw into. The bitmap /// must be mutable. /// <p>The initial target density of the canvas is the same as the given /// bitmap's density. /// </remarks> /// <param name="bitmap">Specifies a mutable bitmap for the canvas to draw into.</param> public Canvas(android.graphics.Bitmap bitmap) { if (!bitmap.isMutable()) { throw new System.InvalidOperationException("Immutable bitmap passed to Canvas constructor" ); } throwIfRecycled(bitmap); mNativeCanvas = initRaster(bitmap.nativeInstance); mBitmap = bitmap; mDensity = bitmap.mDensity; }
public virtual void setBitmap(int arg0, java.lang.String arg1, android.graphics.Bitmap arg2) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.widget.RemoteViews._setBitmap11795, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.widget.RemoteViews.staticClass, global::android.widget.RemoteViews._setBitmap11795, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2)); } }
public virtual void onReceivedIcon(android.webkit.WebView arg0, android.graphics.Bitmap arg1) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.webkit.WebChromeClient._onReceivedIcon10396, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.webkit.WebChromeClient.staticClass, global::android.webkit.WebChromeClient._onReceivedIcon10396, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1)); } }
public virtual void setBitmap(android.graphics.Bitmap arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.app.WallpaperManager._setBitmap857, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.app.WallpaperManager.staticClass, global::android.app.WallpaperManager._setBitmap857, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } }
public virtual void setImageBitmap(android.graphics.Bitmap arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.widget.ImageView._setImageBitmap11474, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.widget.ImageView.staticClass, global::android.widget.ImageView._setImageBitmap11474, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } }
public virtual int findFaces(android.graphics.Bitmap arg0, android.media.FaceDetector.Face[] arg1) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { return(@__env.CallIntMethod(this.JvmHandle, global::android.media.FaceDetector._findFaces4956, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1))); } else { return(@__env.CallNonVirtualIntMethod(this.JvmHandle, global::android.media.FaceDetector.staticClass, global::android.media.FaceDetector._findFaces4956, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1))); } }
public override void onPictureTaken(sbyte[] bytes) { Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.Length); if (bitmap != null) { outerInstance.showPicture(bitmap); } else { Toast.makeText(outerInstance, [email protected]_picture_failed, Toast.LENGTH_LONG).show(); } }
/// <summary>Decode an immutable bitmap from the specified byte array.</summary> /// <remarks>Decode an immutable bitmap from the specified byte array.</remarks> /// <param name="data">byte array of compressed image data</param> /// <param name="offset"> /// offset into imageData for where the decoder should begin /// parsing. /// </param> /// <param name="length">the number of bytes, beginning at offset, to parse</param> /// <param name="opts"> /// null-ok; Options that control downsampling and whether the /// image should be completely decoded, or just is size returned. /// </param> /// <returns> /// The decoded bitmap, or null if the image data could not be /// decoded, or, if opts is non-null, if opts requested only the /// size be returned (in opts.outWidth and opts.outHeight) /// </returns> public static android.graphics.Bitmap decodeByteArray(byte[] data, int offset, int length, android.graphics.BitmapFactory.Options opts) { if ((offset | length) < 0 || data.Length < offset + length) { throw new System.IndexOutOfRangeException(); } android.graphics.Bitmap bm = nativeDecodeByteArray(data, offset, length, opts); if (bm == null && opts != null && opts.inBitmap != null) { throw new System.ArgumentException("Problem decoding into existing bitmap"); } return(bm); }
public override void onClick(DialogInterface dialog, int which) { RelativeLayout layout = (RelativeLayout)view.findViewById(R.id.relativeLayout1); layout.buildDrawingCache(); Bitmap bitmap = layout.DrawingCache; MainActivity.mBixolonPrinter.setPageMode(); MainActivity.mBixolonPrinter.PrintDirection = BixolonPrinter.DIRECTION_180_DEGREE_ROTATION; MainActivity.mBixolonPrinter.setPrintArea(0, 0, 384, 840); MainActivity.mBixolonPrinter.AbsoluteVerticalPrintPosition = 100; MainActivity.mBixolonPrinter.printBitmap(bitmap, BixolonPrinter.ALIGNMENT_CENTER, BixolonPrinter.BITMAP_WIDTH_FULL, 88, false); MainActivity.mBixolonPrinter.formFeed(true); }
public override void onActivityResult(int requestCode, int resultCode, Intent data) { base.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_ACTION_PICK) { if (data != null) { Uri uri = data.Data; System.IO.Stream @is = null; try { @is = ContentResolver.openInputStream(uri); } catch (FileNotFoundException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); return; } try { BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inJustDecodeBounds = false; opts.inSampleSize = 1; opts.inPreferredConfig = Bitmap.Config.RGB_565; Bitmap bm = BitmapFactory.decodeStream(@is, null, opts); mImageView.ImageBitmap = bm; } catch (System.OutOfMemoryException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); return; } ContentResolver cr = ContentResolver; Cursor c = cr.query(uri, new string[] { MediaStore.Images.Media.DATA }, null, null, null); if (c == null || c.Count == 0) { return; } c.moveToFirst(); int columnIndex = c.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); string text = c.getString(columnIndex); mTextView.Text = text; } } }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: @Override public void onDraw(final android.graphics.Canvas canv) public override void onDraw(Canvas canv) { if (null == mOfficeLayout || null == mRenderUtil) { Log.w(TAG, "Tried to render empty office"); return; } foreach (OfficeThing thing in mOfficeLayout.ThingsBottomUp) { Bitmap thingBitmap = mRenderUtil.getBitmap(thing); //TODO: reimplement glow rendering // // If it's the selected thing, make it GLOW! // if (thing.getKey().equals(mSelectedThingKey)) { // thingBitmap = mRenderUtil.getGlowingBitmap(thing); // } // Draw furniture canv.drawBitmap(thingBitmap, modelToScreen(thing.Left), modelToScreen(thing.Top), DEFAULT_PAINT); // Draw desk label if (thing.Type.Equals("desk") && thing.Name != null) { // TODO: these offset numbers were empirically determined. Calculate them instead float centerX = modelToScreen(thing.Left) + 102; float centerY = modelToScreen(thing.Top) + 70; canv.save(); // TODO: OMG this is so hacky. Fix it. These numbers were empirically determined if (thing.Rotation == 180) { canv.rotate(-thing.Rotation, centerX, centerY - 10); } else if (thing.Rotation == 90) { canv.rotate(-thing.Rotation, centerX, centerY + 45); } else if (thing.Rotation == 270) { canv.rotate(-thing.Rotation, centerX - 40, centerY); } canv.drawText(thing.Name, centerX, centerY, DESK_LABEL_PAINT); canv.restore(); } } }
private void setBitmap(android.graphics.Bitmap bitmap) { if (bitmap != mBitmap) { mBitmap = bitmap; if (bitmap != null) { computeBitmapSize(); } else { mBitmapWidth = mBitmapHeight = -1; } invalidateSelf(); } }
public override void draw(android.graphics.Canvas canvas) { android.graphics.Bitmap bitmap = mBitmap; if (bitmap != null) { android.graphics.drawable.BitmapDrawable.BitmapState state = mBitmapState; if (state.mRebuildShader) { android.graphics.Shader.TileMode?tmx = state.mTileModeX; android.graphics.Shader.TileMode?tmy = state.mTileModeY; if (tmx == null && tmy == null) { state.mPaint.setShader(null); } else { state.mPaint.setShader(new android.graphics.BitmapShader(bitmap, tmx == null ? android.graphics.Shader.TileMode .CLAMP : tmx, tmy == null ? android.graphics.Shader.TileMode.CLAMP : tmy)); } state.mRebuildShader = false; copyBounds(mDstRect); } android.graphics.Shader shader = state.mPaint.getShader(); if (shader == null) { if (mApplyGravity) { int layoutDirection = getResolvedLayoutDirectionSelf(); android.view.Gravity.apply(state.mGravity, mBitmapWidth, mBitmapHeight, getBounds (), mDstRect, layoutDirection); mApplyGravity = false; } canvas.drawBitmap(bitmap, null, mDstRect, state.mPaint); } else { if (mApplyGravity) { copyBounds(mDstRect); mApplyGravity = false; } canvas.drawRect(mDstRect, state.mPaint); } } }
private void printSample1() { MainActivity.mBixolonPrinter.setPageMode(); MainActivity.mBixolonPrinter.PrintDirection = BixolonPrinter.DIRECTION_180_DEGREE_ROTATION; MainActivity.mBixolonPrinter.AbsoluteVerticalPrintPosition = 0; MainActivity.mBixolonPrinter.AbsolutePrintPosition = 0; MainActivity.mBixolonPrinter.printText("Page mode\nsample", BixolonPrinter.ALIGNMENT_LEFT, BixolonPrinter.TEXT_ATTRIBUTE_FONT_A, BixolonPrinter.TEXT_SIZE_HORIZONTAL1 | BixolonPrinter.TEXT_SIZE_VERTICAL1, false); MainActivity.mBixolonPrinter.AbsoluteVerticalPrintPosition = 0; MainActivity.mBixolonPrinter.AbsolutePrintPosition = 128; BitmapDrawable drawable = (BitmapDrawable)Resources.getDrawable(R.drawable.bixolon); Bitmap bitmap = drawable.Bitmap; MainActivity.mBixolonPrinter.printBitmap(bitmap, BixolonPrinter.ALIGNMENT_LEFT, 128, 70, false); MainActivity.mBixolonPrinter.AbsoluteVerticalPrintPosition = 0; MainActivity.mBixolonPrinter.AbsolutePrintPosition = 256; MainActivity.mBixolonPrinter.printQrCode("www.bixolon.com", BixolonPrinter.ALIGNMENT_LEFT, BixolonPrinter.QR_CODE_MODEL2, 4, false); MainActivity.mBixolonPrinter.formFeed(true); }
/// <summary> /// <p>Copies the content of this view's surface texture into the specified /// bitmap. /// </summary> /// <remarks> /// <p>Copies the content of this view's surface texture into the specified /// bitmap. If the surface texture is not available, the copy is not executed. /// The content of the surface texture will be scaled to fit exactly inside /// the specified bitmap.</p> /// <p><strong>Do not</strong> invoke this method from a drawing method /// ( /// <see cref="onDraw(android.graphics.Canvas)">onDraw(android.graphics.Canvas)</see> /// for instance).</p> /// <p>If an error occurs, the bitmap is left unchanged.</p> /// </remarks> /// <param name="bitmap"> /// The bitmap to copy the content of the surface texture into, /// cannot be null, all configurations are supported /// </param> /// <returns>The bitmap specified as a parameter</returns> /// <seealso cref="isAvailable()"></seealso> /// <seealso cref="getBitmap(int, int)"></seealso> /// <seealso cref="getBitmap()"></seealso> /// <exception cref="System.InvalidOperationException"> /// if the hardware rendering context cannot be /// acquired to capture the bitmap /// </exception> public virtual android.graphics.Bitmap getBitmap(android.graphics.Bitmap bitmap) { if (bitmap != null && isAvailable()) { android.view.View.AttachInfo info = mAttachInfo; if (info != null && info.mHardwareRenderer != null && info.mHardwareRenderer.isEnabled ()) { if (!info.mHardwareRenderer.validate()) { throw new System.InvalidOperationException("Could not acquire hardware rendering context" ); } } applyUpdate(); applyTransformMatrix(); mLayer.copyInto(bitmap); } return(bitmap); }
private Bitmap captureBitmap(I420Frame i420Frame) { YuvImage yuvImage = i420ToYuvImage(i420Frame); ByteArrayOutputStream stream = new ByteArrayOutputStream(); Rect rect = new Rect(0, 0, yuvImage.Width, yuvImage.Height); // Compress YuvImage to jpeg yuvImage.compressToJpeg(rect, 100, stream); // Convert jpeg to Bitmap sbyte[] imageBytes = stream.toByteArray(); Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.Length); Matrix matrix = new Matrix(); // Apply any needed rotation matrix.postRotate(i420Frame.rotationDegree); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.Width, bitmap.Height, matrix, true); return(bitmap); }
private static android.graphics.Bitmap finishDecode(android.graphics.Bitmap bm, android.graphics.Rect outPadding, android.graphics.BitmapFactory.Options opts) { if (bm == null || opts == null) { return(bm); } int density = opts.inDensity; if (density == 0) { return(bm); } bm.setDensity(density); int targetDensity = opts.inTargetDensity; if (targetDensity == 0 || density == targetDensity || density == opts.inScreenDensity) { return(bm); } byte[] np = bm.getNinePatchChunk(); bool isNinePatch = np != null && android.graphics.NinePatch.isNinePatchChunk(np); if (opts.inScaled || isNinePatch) { float scale = targetDensity / (float)density; // TODO: This is very inefficient and should be done in native by Skia android.graphics.Bitmap oldBitmap = bm; bm = android.graphics.Bitmap.createScaledBitmap(oldBitmap, (int)(bm.getWidth() * scale + 0.5f), (int)(bm.getHeight() * scale + 0.5f), true); oldBitmap.recycle(); if (isNinePatch) { np = nativeScaleNinePatch(np, scale, outPadding); bm.setNinePatchChunk(np); } bm.setDensity(targetDensity); } return(bm); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: @Override public void renderFrame(final com.twilio.video.I420Frame i420Frame) public override void renderFrame(I420Frame i420Frame) { // Capture bitmap and post to main thread if (snapshotRequsted.compareAndSet(true, false)) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final android.graphics.Bitmap bitmap = captureBitmap(i420Frame); Bitmap bitmap = captureBitmap(i420Frame); handler.post(() => { // Update the bitmap of image view imageView.ImageBitmap = bitmap; // Frames must be released after rendering to free the native memory i420Frame.release(); }); } else { i420Frame.release(); } }
private static android.graphics.Bitmap nativeDecodeAsset(android.content.res.AssetManager.AssetInputStream.NativeAsset asset, android.graphics.Rect padding, android.graphics.BitmapFactory.Options opts ) { System.IntPtr padding_ptr = System.IntPtr.Zero; System.IntPtr opts_ptr = System.IntPtr.Zero; try { padding_ptr = android.graphics.Rect.Rect_Helper.ManagedToNative(padding); opts_ptr = android.graphics.BitmapFactory.Options.Options_Helper.ManagedToNative( opts); android.graphics.Bitmap _retval = new android.graphics.Bitmap(libxobotos_BitmapFactory_nativeDecodeAsset (asset, padding_ptr, opts_ptr)); android.graphics.BitmapFactory.Options.Options_Helper.MarshalOut(opts_ptr, opts); return(_retval); } finally { android.graphics.Rect.Rect_Helper.FreeManagedPtr(padding_ptr); android.graphics.BitmapFactory.Options.Options_Helper.FreeManagedPtr(opts_ptr); } }
// If we are getting ready to gc after going to the background, well // we are back active so skip it. // If the window hasn't yet been added to the window manager, // and this guy didn't finish itself or start another activity, // then go ahead and add the window. // If the window has already been added, but during resume // we started another activity, then don't yet make the // window visible. // Get rid of anything left hanging around. // The window is now visible if it has been added, we are not // simply finishing, and we are not starting another activity. // If an exception was thrown when trying to resume, then // just end this activity. internal android.graphics.Bitmap createThumbnailBitmap(android.app.ActivityThread .ActivityClientRecord r) { android.graphics.Bitmap thumbnail = mAvailThumbnailBitmap; try { if (thumbnail == null) { int w = mThumbnailWidth; int h; if (w < 0) { android.content.res.Resources res = r.activity.getResources(); mThumbnailHeight = h = res.getDimensionPixelSize([email protected]_height ); mThumbnailWidth = w = res.getDimensionPixelSize([email protected]_width ); } else { h = mThumbnailHeight; } // On platforms where we don't want thumbnails, set dims to (0,0) if ((w > 0) && (h > 0)) { thumbnail = android.graphics.Bitmap.createBitmap(w, h, THUMBNAIL_FORMAT); thumbnail.eraseColor(0); } } if (thumbnail != null) { android.graphics.Canvas cv = mThumbnailCanvas; if (cv == null) { mThumbnailCanvas = cv = new android.graphics.Canvas(); } cv.setBitmap(thumbnail); if (!r.activity.onCreateThumbnail(thumbnail, cv)) { mAvailThumbnailBitmap = thumbnail; thumbnail = null; } cv.setBitmap(null); } } catch (System.Exception e) { if (!mInstrumentation.onException(r.activity, e)) { throw new java.lang.RuntimeException("Unable to create thumbnail of " + r.intent. getComponent().toShortString() + ": " + e.ToString(), e); } thumbnail = null; } return thumbnail; }
public virtual void onImageReceived(Bitmap arg0) { outerInstance.outerInstance.mOutputImageView.Background = new BitmapDrawable(Resources, arg0); }
public Item(Bitmap img, string txt) { this.image = img; this.text = txt; }
public override void onPageStarted(WebView view, string url, Bitmap favicon) { Log.d(outerInstance.TAG, "Page started: " + url); base.onPageStarted(view, url, favicon); }
/// <summary>Specify a bitmap for the canvas to draw into.</summary> /// <remarks> /// Specify a bitmap for the canvas to draw into. As a side-effect, also /// updates the canvas's target density to match that of the bitmap. /// </remarks> /// <param name="bitmap">Specifies a mutable bitmap for the canvas to draw into.</param> /// <seealso cref="setDensity(int)">setDensity(int)</seealso> /// <seealso cref="getDensity()">getDensity()</seealso> public virtual void setBitmap(android.graphics.Bitmap bitmap) { if (isHardwareAccelerated()) { throw new java.lang.RuntimeException("Can't set a bitmap device on a GL canvas"); } android.graphics.Bitmap.NativeBitmap pointer = null; if (bitmap != null) { if (!bitmap.isMutable()) { throw new System.InvalidOperationException(); } throwIfRecycled(bitmap); mDensity = bitmap.mDensity; pointer = bitmap.nativeInstance; } native_setBitmap(mNativeCanvas, pointer); mBitmap = bitmap; }
private static android.graphics.Bitmap nativeDecodeByteArray(byte[] data, int offset , int length, android.graphics.BitmapFactory.Options opts) { Sharpen.INativeHandle data_handle = null; System.IntPtr opts_ptr = System.IntPtr.Zero; try { data_handle = XobotOS.Runtime.MarshalGlue.Array_byte_Helper.GetPinnedPtr(data); opts_ptr = android.graphics.BitmapFactory.Options.Options_Helper.ManagedToNative( opts); android.graphics.Bitmap _retval = new android.graphics.Bitmap(libxobotos_BitmapFactory_decodeByteArray (data_handle.Address, offset, length, opts_ptr)); android.graphics.BitmapFactory.Options.Options_Helper.MarshalOut(opts_ptr, opts); return _retval; } finally { if (data_handle != null) { data_handle.Free(); } android.graphics.BitmapFactory.Options.Options_Helper.FreeManagedPtr(opts_ptr); } }
private static android.graphics.Bitmap nativeDecodeAsset(android.content.res.AssetManager.AssetInputStream.NativeAsset asset, android.graphics.Rect padding, android.graphics.BitmapFactory.Options opts ) { System.IntPtr padding_ptr = System.IntPtr.Zero; System.IntPtr opts_ptr = System.IntPtr.Zero; try { padding_ptr = android.graphics.Rect.Rect_Helper.ManagedToNative(padding); opts_ptr = android.graphics.BitmapFactory.Options.Options_Helper.ManagedToNative( opts); android.graphics.Bitmap _retval = new android.graphics.Bitmap(libxobotos_BitmapFactory_nativeDecodeAsset (asset, padding_ptr, opts_ptr)); android.graphics.BitmapFactory.Options.Options_Helper.MarshalOut(opts_ptr, opts); return _retval; } finally { android.graphics.Rect.Rect_Helper.FreeManagedPtr(padding_ptr); android.graphics.BitmapFactory.Options.Options_Helper.FreeManagedPtr(opts_ptr); } }
internal BitmapState(android.graphics.Bitmap bitmap) { mBitmap = bitmap; }