Skip to content

Commit

Permalink
Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheesebaron committed Sep 19, 2014
1 parent 5a7789d commit 3fc63cb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions PictureBitmapDrawable.cs
Expand Up @@ -13,6 +13,9 @@ namespace XamSvg
public class PictureBitmapDrawable : Drawable
{
Bitmap currentBitmap;

public PictureBitmapDrawable(IntPtr handle, JniHandleOwnership transfer)
: base(handle, transfer) { }

public PictureBitmapDrawable (Picture pic)
{
Expand All @@ -26,7 +29,8 @@ public PictureBitmapDrawable (Picture pic)

public override void Draw (Canvas canvas)
{
canvas.DrawBitmap (currentBitmap, 0, 0, null);
if (currentBitmap != null)
canvas.DrawBitmap (currentBitmap, 0, 0, null);
}

public override int Opacity {
Expand All @@ -39,8 +43,11 @@ protected override void OnBoundsChange (Rect bounds)
{
var width = bounds.Width ();
var height = bounds.Height ();
if (currentBitmap == null || currentBitmap.Height != height || currentBitmap.Width != width)
currentBitmap = SvgFactory.MakeBitmapFromPicture (Picture, width, height);
if (width <= 0 || height <= 0)
return;

if (Picture != null && (currentBitmap == null || currentBitmap.Height != height || currentBitmap.Width != width))
currentBitmap = SvgFactory.MakeBitmapFromPicture(Picture, width, height);
}

public override int IntrinsicWidth {
Expand Down

0 comments on commit 3fc63cb

Please sign in to comment.