Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Image opacity in C#

Image opacity in C#

Scheduled Pinned Locked Moved C#
csharpgraphicshelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VCsamir
    wrote on last edited by
    #1

    Hi friends, Can you'll help me to find another way for this.. i have two bitmaps, one is the mask bitmap which is a grey scale image and another is actual image, i am applying this mask on the image, i use getpixel & setpixel to apply the color of mask image as the alpha of the other image.. for small images it is fast but it becomes slow as the image size increases.. Is there any alternate way to do so? Thanks in advance.. :-) Regards Samir

    N 1 Reply Last reply
    0
    • V VCsamir

      Hi friends, Can you'll help me to find another way for this.. i have two bitmaps, one is the mask bitmap which is a grey scale image and another is actual image, i am applying this mask on the image, i use getpixel & setpixel to apply the color of mask image as the alpha of the other image.. for small images it is fast but it becomes slow as the image size increases.. Is there any alternate way to do so? Thanks in advance.. :-) Regards Samir

      N Offline
      N Offline
      Nuri Ismail
      wrote on last edited by
      #2

      VCsamir wrote:

      i use getpixel & setpixel

      These methods are really VERY slow. :)

      VCsamir wrote:

      Is there any alternate way to do so?

      Yes. - One of the alternative methods is to lock the bits of your bitmap in memory and perform a direct access to the bitmap bits using unsafe block. There are plenty of examples and here[^] is a very brief one. - Another option is to hide this pointer arithmetic in a class and provide some fast GetPixel and SetPixel implementations. You can find such a class in this[^] article (it is named UnsafeBitmap). - The third option is using ColorMatrix[^]. Here are some examples of its usage: 1[^], 2[^]. You can find more... I'd also suggest you to have a look at this article and the other parts of the series: Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters[^] I hope this helps. :)

      V 1 Reply Last reply
      0
      • N Nuri Ismail

        VCsamir wrote:

        i use getpixel & setpixel

        These methods are really VERY slow. :)

        VCsamir wrote:

        Is there any alternate way to do so?

        Yes. - One of the alternative methods is to lock the bits of your bitmap in memory and perform a direct access to the bitmap bits using unsafe block. There are plenty of examples and here[^] is a very brief one. - Another option is to hide this pointer arithmetic in a class and provide some fast GetPixel and SetPixel implementations. You can find such a class in this[^] article (it is named UnsafeBitmap). - The third option is using ColorMatrix[^]. Here are some examples of its usage: 1[^], 2[^]. You can find more... I'd also suggest you to have a look at this article and the other parts of the series: Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters[^] I hope this helps. :)

        V Offline
        V Offline
        VCsamir
        wrote on last edited by
        #3

        Thanks Sir :rose: :rose: for kind Help!! Regards Samir

        N 1 Reply Last reply
        0
        • V VCsamir

          Thanks Sir :rose: :rose: for kind Help!! Regards Samir

          N Offline
          N Offline
          Nuri Ismail
          wrote on last edited by
          #4

          You're welcome! :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups