fade to black and white

In XP when you go to shut down, windows fades to black and white. I think that's a nice effect.

How would i go about fading a color image (image box stretched - like a screen saver) to black and white...

Has this ever been done Is their a code snippet that already exsists Any thoughts A push in the right direction



Answer this question

fade to black and white

  • michealdm

    No worries, glad to help.



  • magicali

    The FotoVision sample has code in it to do greyscale using color matrices, to be honest, I knew that would work, but I've not really played with it.

     

    Having said that, it's img you want to save, not bmp. 

     



  • Daniela Torres

    www.codeproject.com has my image processing articles. They show how to access the bits of an image directly, how to do a greyscale filter ( although it's quicker to do one using the color matrix, my approach is more generic ), and you could easily make a grey copy of an image, and animate the steps between the pixel values. I would not be surprised if XP builds a cache of images to do the animation in the moments before it starts, tho.



  • LeBlah

    // bmp.Save("c:\")

    Replace this with an actual path and see what happens :-)



  • Hassmann

     cgraus wrote:

    www.codeproject.com has my image processing articles.  They show how to access the bits of an image directly, how to do a greyscale filter ( although it's quicker to do one using the color matrix, my approach is more generic ), and you could easily make a grey copy of an image, and animate the steps between the pixel values.  I would not be surprised if XP builds a cache of images to do the animation in the moments before it starts, tho.

     

    ok, this is what i have, everything seems to be running ok, but the image does not save to c:\...am i missing something obvious

    Dim strpath1Image As Image = Image.FromFile(strPath1)

    grayscale(strpath1Image)

    End Sub

    Public Function grayscale(ByVal img As Image) As Boolean

    Dim cm As Imaging.ColorMatrix = New Imaging.ColorMatrix(New Single()() _

    {New Single() {0.299, 0.299, 0.299, 0, 0}, _

    New Single() {0.587, 0.587, 0.587, 0, 0}, _

    New Single() {0.114, 0.114, 0.114, 0, 0}, _

    New Single() {0, 0, 0, 1, 0}, _

    New Single() {0, 0, 0, 0, 1}})

     

    Return draw_adjusted_image(img, cm)

    End Function

    Private Function draw_adjusted_image(ByVal img As Image, _

    ByVal cm As Imaging.ColorMatrix) As Boolean

     

    Try

    Dim bmp As New Bitmap(img) ' create a copy of the source image

    Dim imgattr As New Imaging.ImageAttributes()

    Dim rc As New Rectangle(0, 0, img.Width, img.Height)

    Dim g As Graphics = Graphics.FromImage(img)

    ' associate the ColorMatrix object with an ImageAttributes object

    imgattr.SetColorMatrix(cm)

    ' draw the copy of the source image back over the original image,

    'applying the ColorMatrix

    g.DrawImage(bmp, rc, 0, 0, img.Width, img.Height, _

    GraphicsUnit.Pixel, imgattr)

    bmp.Save("c:\")

    g.Dispose()

    Return True

    Catch

    Return False

    End Try

    End Function


  • Joshua Scholar

    works great, now I'm going to tweak the color settings to do a transitional fade...Thanks for your help
  • DaveChapman

     cgraus wrote:

    // bmp.Save("c:\")

    Replace this with an actual path and see what happens :-)

     

     

    stupid me...so I added the rest of the path lol and it gives me an image, but it's not grey like it's supposed to be...


  • fade to black and white