Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well I managed to figure this out myself.</p> <p>You can get a base uri by using Me.Uri; or in C# This.Uri.</p> <p>Here is the finished code that will enable anyone to load a bitmap image into a canvas; and even rotate it.</p> <p>I wrote this myself, so anyone who discovers it having the same problem can feel free to use it as they please.</p> <p>Image must take the format "FilePath/Image.extension"</p> <pre><code>Public Class Sprite 'Public Shared Baseuri As Uri Public Img As ImageBrush Public Bitmap As BitmapImage Public Sub New(Image As String, Base As Uri) 'Debug.Print("BASE:" &amp; Base.ToString) 'Debug.Print("USING:" &amp; Image) 'Debug.Print("RESULT:" &amp; New Uri(Base, Image).ToString) Img = New ImageBrush() Bitmap = New BitmapImage(New Uri(Base, Image)) End Sub Public Overloads Sub Render(X As Integer, Y As Integer, Width As Integer, Height As Integer, Canv As Canvas) Img.ImageSource = Bitmap Dim Sprite As New Shapes.Rectangle Sprite.Width = CDbl(Width) Sprite.Height = CDbl(Height) Sprite.Fill = Img Sprite.SetValue(Canvas.TopProperty, CDbl(Y)) Sprite.SetValue(Canvas.LeftProperty, CDbl(X)) Canv.Children.Add(Sprite) End Sub Public Overloads Sub Render(X As Integer, Y As Integer, Width As Integer, Height As Integer, Canv As Canvas, Angle As Integer) Img.ImageSource = Bitmap Dim Sprite As New Shapes.Rectangle Sprite.Width = CDbl(Width) Sprite.Height = CDbl(Height) Sprite.Fill = Img Sprite.SetValue(Canvas.TopProperty, CDbl(Y)) Sprite.SetValue(Canvas.LeftProperty, CDbl(X)) Dim v As New Windows.UI.Xaml.Media.RotateTransform v.Angle = CDbl(Angle) v.CenterX = Width / 2 v.CenterY = Height / 2 Sprite.RenderTransform = v Canv.Children.Add(Sprite) End Sub End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload