0

ASP.NET can call Direct2D by C#. However after I create bitmap, can we show the bitmap on web?

protected void Page_Load(object sender, EventArgs e)
    {
        m_renderBitmap = m_wicFactory.CreateImagingBitmap(m_imageWidth, m_imageHeight, PixelFormats.Bgr32Bpp, BitmapCreateCacheOption.CacheOnLoad);

        RenderTargetProperties renderProps = new RenderTargetProperties
        {
            PixelFormat = new PixelFormat(
                 Microsoft.WindowsAPICodePack.DirectX.Graphics.Format.B8G8R8A8UNorm,
                 AlphaMode.Ignore),
            Usage = RenderTargetUsages.None,
            RenderTargetType = RenderTargetType.Software
        };

        m_renderTarget = m_d2dFactory.CreateWicBitmapRenderTarget(m_renderBitmap, renderProps);
    }

The rendertarget I created is WICBitmapRenderTarget. If I can show the bitmap on the web?

ernst
  • 5
  • 4

1 Answers1

0

There are a couple of ways you could achieve this.

1 - Render the image into a byte array and encode it directly into the page; see the answer for this

Use a System.Drawing.Image in an HTML tag

Note - will be very inefficient and will only work with small images.

2 - Stream the image to the browser in the appropriate MIME type i.e. image/jpg or whatever. Create a page or HTTP handler whose only job is to respond to requests for images, see the answer to this: -

Render HTML as an Image

.. as a starter.

Community
  • 1
  • 1
sh1rts
  • 1,874
  • 1
  • 13
  • 14