Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Help me! The type or namespace name 'Platform' does not exist in the namespace 'Microsoft.Maui.Graphics' #457

Closed
leNam199320xx opened this issue Jun 22, 2022 · 2 comments · Fixed by #464 or dotnet/maui#14816
Assignees
Labels
bug Something isn't working

Comments

@leNam199320xx
Copy link

The type or namespace name 'Platform' does not exist in the namespace 'Microsoft.Maui.Graphics'

pls i cannot find Platform Class when build MAUI windows app

code :

public void Draw(ICanvas canvas, RectF dirtyRect)
{
// Drawing code goes here

    IImage image;
    Assembly assembly = GetType().GetTypeInfo().Assembly;
    using (Stream stream = assembly.GetManifestResourceStream("MemeCreator.Resources.Images.dotnet_bot.svg"))
    {
        image = PlatformImage.FromStream(stream); // error here

    }

    if (image != null)
    {
        IImage newImage = image.Resize(100, 60, ResizeMode.Stretch, true);
        canvas.DrawImage(newImage, 10, 10, newImage.Width, newImage.Height);
    }
}

Screenshot 2022-06-22 213120

@lindexi
Copy link
Member

lindexi commented Jun 25, 2022

@leNam199320xx See

using System;
using System.IO;
using System.Threading.Tasks;
namespace Microsoft.Maui.Graphics.Platform
{
#if NETSTANDARD || NETSTANDARD2_0 || NETSTANDARD2_1 || TIZEN || TIZEN40
public class PlatformImage : IImage
{
private readonly byte[] _bytes;
private readonly int _width;
private readonly int _height;
private readonly ImageFormat _originalFormat;
public PlatformImage(byte[] bytes, ImageFormat originalFormat = ImageFormat.Png)

Do you forget to reference the Microsoft.Maui.Graphics?

@janseris
Copy link

janseris commented Jun 26, 2022

Platform is Android version. I reported the issue with the documentation like 2 months ago but last 6 months all updates on MAUI Graphics have been just package version updates.

#402

On Windows it is not possible to use IImage at all (only using a hack, see in the comments)

#422

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.