Search code examples
c#uwpbitmaptiff

Can't convert tiff image to a bitmap (matrix)


The function GetBitMapColorMatrix is ‏supposed to decode the tiff image and return a bitmap that describes the tiff image but for some reason, I get this exception -> System.PlatformNotSupportedException: 'System.Drawing is not supported on this platform'. Any help would be appreciated.

public Color[][] GetBitMapColorMatrix(string bitmapFilePath)
    {
        Bitmap b1 = new Bitmap(bitmapFilePath);

        int hight = b1.Height;
        int width = b1.Width;

        Color[][] colorMatrix = new Color[width][];
        for (int i = 0; i < width; i++)
        {
            colorMatrix[i] = new Color[hight];
            for (int j = 0; j < hight; j++)
            {
                colorMatrix[i][j] = b1.GetPixel(i, j);
            }
        }
        return colorMatrix;
    }

Solution

  • UWP does not use the full .net framework so the classes in System.Drawing are not available. Their are some classes like BitmapPallette and BitmapImage in the System.Media.Imaging namespace that could be useful. I would also look at Win2D or SharpDX.