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. an other-other image processing

an other-other image processing

Scheduled Pinned Locked Moved C#
questionworkspace
3 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.
  • S Offline
    S Offline
    Sajjad Izadi
    wrote on last edited by
    #1

    excuse me firends, have you ever seen what happens when you open 'start' from taskbar and then 'turn off computer' or 'log off'? when you click on them, the environment start to become white and black. and i have an image in my form and i want to make a similar process to make that image start becoming white and black like you have seen in turning off your computer. how can i do that please? thanks

    L 1 Reply Last reply
    0
    • S Sajjad Izadi

      excuse me firends, have you ever seen what happens when you open 'start' from taskbar and then 'turn off computer' or 'log off'? when you click on them, the environment start to become white and black. and i have an image in my form and i want to make a similar process to make that image start becoming white and black like you have seen in turning off your computer. how can i do that please? thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      This requires some math, albeit some very simple math. You need two pictures (actually, you can calculate the luma value on the fly inside the lerp method, but this one is a bit simpler and faster, but uses twice the memory): 1) the colored version 2) the grayscale/bw version Then, based on a timer for the fading transition (let's say 5 seconds from colored to BW) you simply do a linear interpolation[^] between the colored pixel value to the BW pixel value on a time range from 0 to 1. In a timer, you could do this (pseudocode):

      const float transitionTime = 5000f; // 5 seconds
      float normalizedTransitionTime = millsecondsSinceTransitionStart / transitionTime;

      red = (byte)Lerp(normalizedTransitionTime , coloredPixelR, bwPixelR);
      green = (byte)Lerp(normalizedTransitionTime , coloredPixelG, bwPixelG);
      blue = (byte)Lerp(normalizedTransitionTime , coloredPixelB, bwPixelB);

      What the method Lerp[^] does is simply a interpolation in the form

      value1 + (value2 - value1) * amount

      as used in the XNA framework (for example)

      float Lerp(float amount, float value1, float value2)
      {
      return value1 + (value2 - value1) * amount;
      }

      regards

      modified on Sunday, June 8, 2008 12:51 PM

      S 1 Reply Last reply
      0
      • L Lost User

        This requires some math, albeit some very simple math. You need two pictures (actually, you can calculate the luma value on the fly inside the lerp method, but this one is a bit simpler and faster, but uses twice the memory): 1) the colored version 2) the grayscale/bw version Then, based on a timer for the fading transition (let's say 5 seconds from colored to BW) you simply do a linear interpolation[^] between the colored pixel value to the BW pixel value on a time range from 0 to 1. In a timer, you could do this (pseudocode):

        const float transitionTime = 5000f; // 5 seconds
        float normalizedTransitionTime = millsecondsSinceTransitionStart / transitionTime;

        red = (byte)Lerp(normalizedTransitionTime , coloredPixelR, bwPixelR);
        green = (byte)Lerp(normalizedTransitionTime , coloredPixelG, bwPixelG);
        blue = (byte)Lerp(normalizedTransitionTime , coloredPixelB, bwPixelB);

        What the method Lerp[^] does is simply a interpolation in the form

        value1 + (value2 - value1) * amount

        as used in the XNA framework (for example)

        float Lerp(float amount, float value1, float value2)
        {
        return value1 + (value2 - value1) * amount;
        }

        regards

        modified on Sunday, June 8, 2008 12:51 PM

        S Offline
        S Offline
        Sajjad Izadi
        wrote on last edited by
        #3

        thanks for your consideratoin. i know i'm too lazy but could you explain a bit more for me? the links couldn't help (:)) i want sth that makes a smooth conversion with an optimum speed and timings. my problem is what should the fields 'red', 'green' and 'blue' assigned to? what are them? i wonder if you help me a bit more clear. thanks again

        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