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. Visual Basic
  4. Give Picture a defined Shadow..

Give Picture a defined Shadow..

Scheduled Pinned Locked Moved Visual Basic
questionhelptutorial
6 Posts 3 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.
  • M Offline
    M Offline
    martinx
    wrote on last edited by
    #1

    Hi , i have the following situation. I have a picturebox with a image in it (like a normal picture with a size of 48x48 pixel) now i wanna paint a shadow to a given direction an strengt. for example i say the light comes from left and the shadow should be right and 5 pixels big (something like the shadow functions in paintshop or photostudio) the pictures are png's with alphachannel. how can i resolve the above problem ? greetings

    D T 2 Replies Last reply
    0
    • M martinx

      Hi , i have the following situation. I have a picturebox with a image in it (like a normal picture with a size of 48x48 pixel) now i wanna paint a shadow to a given direction an strengt. for example i say the light comes from left and the shadow should be right and 5 pixels big (something like the shadow functions in paintshop or photostudio) the pictures are png's with alphachannel. how can i resolve the above problem ? greetings

      D Offline
      D Offline
      Dave Sexton
      wrote on last edited by
      #2

      Shadowing the picture or the picture box?

      M 1 Reply Last reply
      0
      • D Dave Sexton

        Shadowing the picture or the picture box?

        M Offline
        M Offline
        martinx
        wrote on last edited by
        #3

        Hi, the picture in the picturebox ..

        1 Reply Last reply
        0
        • M martinx

          Hi , i have the following situation. I have a picturebox with a image in it (like a normal picture with a size of 48x48 pixel) now i wanna paint a shadow to a given direction an strengt. for example i say the light comes from left and the shadow should be right and 5 pixels big (something like the shadow functions in paintshop or photostudio) the pictures are png's with alphachannel. how can i resolve the above problem ? greetings

          T Offline
          T Offline
          Thomas Stockwell
          wrote on last edited by
          #4

          Personally, I would create a new control where you can control the painting procedures. In this control I would of course have the property of the image to shadow. Then in the paint event I would first draw the shadow of the image using ControlPaint.DrawImageDisabled(...) and then draw the slightly displaced image overtop of the shadow using the g.DrawImage routine (g is the Graphics object of the paint routine). I'll try to look for some code from a project that I just created that paints a shadowed image and post it. I would not even consider using shadows with a picturebox, it can only lead to trouble.

          Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my homepage Oracle Studios[^]

          M 1 Reply Last reply
          0
          • T Thomas Stockwell

            Personally, I would create a new control where you can control the painting procedures. In this control I would of course have the property of the image to shadow. Then in the paint event I would first draw the shadow of the image using ControlPaint.DrawImageDisabled(...) and then draw the slightly displaced image overtop of the shadow using the g.DrawImage routine (g is the Graphics object of the paint routine). I'll try to look for some code from a project that I just created that paints a shadowed image and post it. I would not even consider using shadows with a picturebox, it can only lead to trouble.

            Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my homepage Oracle Studios[^]

            M Offline
            M Offline
            martinx
            wrote on last edited by
            #5

            Hi Thomas, did you already post the code ? or could you send it me by mail. many greetings martin

            T 1 Reply Last reply
            0
            • M martinx

              Hi Thomas, did you already post the code ? or could you send it me by mail. many greetings martin

              T Offline
              T Offline
              Thomas Stockwell
              wrote on last edited by
              #6

              This code is in C#, but I am sure that it can easily be translated. This is code that is contained in a screen saver presentation that paints 3 random images with a random quote specified in a particular directory: public void DrawRandomImage(Graphics g, Rectangle rect) { if (usedIndexes.Count > currentImageIndex && bitmaps.Count >0) { if (showEffects) ControlPaint.DrawImageDisabled(g, bitmaps[usedIndexes[currentImageIndex]], rect.X + 5, rect.Y + 5, Color.Transparent); g.DrawImage(bitmaps[usedIndexes[currentImageIndex]], rect); currentImageIndex++; if (currentImageIndex == 3) currentImageIndex = 0; } else g.FillRectangle(new SolidBrush(Color.Black), rect); } The variable bitmaps is an array of bitmaps that were read in from a specified directory. Basically replace the entire array with one image if you so choose. The two key parts of this code is: ControlPaint.DrawImageDisabled() which will draw a grayscale image which then can be offsetted from the image drawn with the g.DrawImage. If you need further explanation just ask. This explanation may seem a bit jumbled.

              Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my homepage Oracle Studios[^]

              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