System.Drawing.Bitmap alpha

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • instruo

    System.Drawing.Bitmap alpha

    I'm using the System.Drawing. Bitmap class for loading a 32-bit bmp file which
    includes an alpha channel.

    The problem is, when it gets loaded (just using the Bitmap(string filename)
    constructor), it doesn't bother bringing the alpha along with it. All of the
    pixels just show "255" as their alpha value and Bitmap.IsAlphaP ixelFormat()
    returns false.

    I know that the alpha does exist physically and has worked with this exact
    image in other contexts. So, does anyone know how I can make Bitmap behave
    and actually give me my alpha channel in the file? Thanks much.
  • Erik Molenaar

    #2
    Re: System.Drawing. Bitmap alpha

    ..png Bitmaps use the alpha channel

    I encountered no problems using them in my projects.

    Erik


    "instruo" <instruo@discus sions.microsoft .com> schrieb im Newsbeitrag
    news:90CCB48F-4F1C-4669-BCE5-671AD782BCDF@mi crosoft.com...[color=blue]
    > I'm using the System.Drawing. Bitmap class for loading a 32-bit bmp file[/color]
    which[color=blue]
    > includes an alpha channel.
    >
    > The problem is, when it gets loaded (just using the Bitmap(string[/color]
    filename)[color=blue]
    > constructor), it doesn't bother bringing the alpha along with it. All of[/color]
    the[color=blue]
    > pixels just show "255" as their alpha value and[/color]
    Bitmap.IsAlphaP ixelFormat()[color=blue]
    > returns false.
    >
    > I know that the alpha does exist physically and has worked with this exact
    > image in other contexts. So, does anyone know how I can make Bitmap behave
    > and actually give me my alpha channel in the file? Thanks much.[/color]


    Comment

    • Steve McLellan

      #3
      Re: System.Drawing. Bitmap alpha

      Hi,

      Try posting this in the framework.drawi ng NG as Bob Powell is the resident
      master on all things in the Drawing namespace.

      Steve

      "instruo" <instruo@discus sions.microsoft .com> wrote in message
      news:90CCB48F-4F1C-4669-BCE5-671AD782BCDF@mi crosoft.com...[color=blue]
      > I'm using the System.Drawing. Bitmap class for loading a 32-bit bmp file
      > which
      > includes an alpha channel.
      >
      > The problem is, when it gets loaded (just using the Bitmap(string
      > filename)
      > constructor), it doesn't bother bringing the alpha along with it. All of
      > the
      > pixels just show "255" as their alpha value and
      > Bitmap.IsAlphaP ixelFormat()
      > returns false.
      >
      > I know that the alpha does exist physically and has worked with this exact
      > image in other contexts. So, does anyone know how I can make Bitmap behave
      > and actually give me my alpha channel in the file? Thanks much.[/color]


      Comment

      • Mick Doherty

        #4
        Re: System.Drawing. Bitmap alpha

        Basicly, a new Bitmap object is 24BPP which is why you lose the Alpha
        content.
        Draw the bitmap directly to a controls graphics object and you should have
        no problems with Alpha, but when you manipulate the bitmap in a Memory
        Bitmap the Alpha is lost. What you must do to overcome this issue, is create
        the memory bitmap via a BitmapData object.

        Whilst the example at the following link is for a 32bit Icon, it will give
        you the solution to your problem.
        http://dotnetrix.co.uk/misc.html --> Get Alpha Bitmap from 32 bit Icon.

        --
        Mick Doherty
        Dotnetrix offers Nothing. Standard and Premium versions available.



        "instruo" <instruo@discus sions.microsoft .com> wrote in message
        news:90CCB48F-4F1C-4669-BCE5-671AD782BCDF@mi crosoft.com...[color=blue]
        > I'm using the System.Drawing. Bitmap class for loading a 32-bit bmp file
        > which
        > includes an alpha channel.
        >
        > The problem is, when it gets loaded (just using the Bitmap(string
        > filename)
        > constructor), it doesn't bother bringing the alpha along with it. All of
        > the
        > pixels just show "255" as their alpha value and
        > Bitmap.IsAlphaP ixelFormat()
        > returns false.
        >
        > I know that the alpha does exist physically and has worked with this exact
        > image in other contexts. So, does anyone know how I can make Bitmap behave
        > and actually give me my alpha channel in the file? Thanks much.[/color]


        Comment

        Working...