-
Notifications
You must be signed in to change notification settings - Fork 13
/
PictureBitmapDrawable.cs
81 lines (67 loc) · 1.59 KB
/
PictureBitmapDrawable.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Graphics;
using Android.Graphics.Drawables;
namespace XamSvg
{
public class PictureBitmapDrawable : Drawable
{
Bitmap currentBitmap;
public PictureBitmapDrawable(IntPtr handle, JniHandleOwnership transfer)
: base(handle, transfer) { }
public PictureBitmapDrawable (Picture pic)
{
Picture = pic;
}
public Picture Picture {
get;
private set;
}
public override void Draw (Canvas canvas)
{
if (currentBitmap != null)
canvas.DrawBitmap (currentBitmap, 0, 0, null);
}
public override int Opacity {
get {
return (int)Format.Translucent;
}
}
protected override void OnBoundsChange (Rect bounds)
{
var width = bounds.Width ();
var height = bounds.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 {
get {
return Picture != null ? Picture.Width : 0;
}
}
public override int IntrinsicHeight {
get {
return Picture != null ? Picture.Height : 0;
}
}
public override void SetFilterBitmap (bool filter)
{
}
public override void SetDither (bool dither)
{
}
public override void SetColorFilter (ColorFilter cf)
{
}
public override void SetAlpha (int alpha)
{
}
}
}