We help IT Professionals succeed at work.

pxel color detection ?

Last Modified: 2013-12-26
What Silverlight Currently Does Not Support

* Per pixel bitmap editing, bitmap filters (color matrix, etc) and effects (blur, glow, etc).

So I am confused about what to do with silverlight without pixel bitmap facilities like checking the color of a particular pixel. Does anyone know how to load an png ot jpg into an array of bytes and you can loop through and check the pixel cpolor this way? I need to click on an PNG,JPG image and see what color the pixel is and if it is a transparent pixel
Watch Question

Jose ParrotGraphics Expert

Dot Net is abstract enough to allow high level programming, thus resulting in very slow execution. Silverlight (probably better to call it PlumbHeavy) is an abstract layer above .net to be portable across platforms (Microsoft Windows XP, Microsoft Windows Vista Business, Microsoft Vista Home, and a lot of Microsoft Vista operating systems. Ah! Mac OS X too).

Dot Net programming and Silverlight aren't right environments for GetPixel and SetPixel functions. When possible, there is a huge time penalty.

I use C++ with CLR .NET by dividing the specialities, say, use .NET for the GUI (just the user interface) and C++ for the fast execution parts. The integration of the (excellent, powerful, as good as Borland C++ Builder) components of .NET (buttons, lists, menu, dialogs, etc.) and the "native" C++ code is somewhat difficult, but possible. By marshaling (argh!!).

Probably you can do the same, with some mixing of SL in the frontend and VB (or other speedy language) for the math and graphics.

For example, you can load a bitmap. You may want take a look at
As you see in the code, the bitmap is under VB control, so you can go ahead from this point with VB. Anyway, it is poor approach, because VB or .net pixel functions are very slow.

Think about Silverlight as Flash. Not as GDI.



i already  know how to load a bitmap no problems
   Dim url As Uri
        url = New Uri("spaceship.png", UriKind.Relative)
        Dim uu As New BitmapImage()
        uu.UriSource = url

        Canvas.SetTop(img1, sShipY)
        Canvas.SetLeft(img1, sShipX)
        img1.Width = sShipW
        img1.Height = sShipH
        img1.Source = uu

q1)the problem is i am using SIlverlight and it has limited bitmap functions. I read you can load the bitmap elements into an array of bytes but i dont know how you do this for png,jpg files.

q2)I didnt really follow you solution
>Probably you can do the same, with some mixing of SL in the frontendand VB (or other speedy language) for the math and graphics.
What do you mean ?


this claims it can use set/get pixels on bitmaps in editImage class which i cant make sense of and can be used in silverlight



i am stuck from last post problem


1)I am still stcuk
Graphics Expert
This one is on us!
(Get your first solution completely free - no credit card required)


Silverlight is good enough and recent test prove it. Also the game i am making runs fine at 24FPS and it is a arcade style game. The .net is much better to code in than actionscript I am finding but it lacks 1 feature with getpixel . COntrols slow it down and i dont use controls.


I dont want set pixel but get pixel. TO do this i read in a arrray of byted from the image and then i can do a test.

This part i cant do and i want help with
Jose ParrotGraphics Expert

I agree with you: .NET and derived products are great for coding. I use Visual Studio with .NET GUI by default due the high quality of it. But pure "native" C++ for the CPU demanding functions (I do high performance graphics research).

But, as you have noticed, we must change the way of programming, as this new environment is also a new paradigm. Something like what happens to someone that use to program in Assembler and when does to C# wants to access a CPU register...

To circumvect these restrictions, in most cases we create dirt solutions.
For example, as SilverLight doesn't directly load a bitmap image from local disks (just from the web) a trick is to upload the image to a web site than access it by its url and do the download... Can you imagine a program that uploads an image just to download it back because it is not allowed to read it directly from the disk?
(Note: SL beta has a function to do it, Look at http://msdn.microsoft.com/en-us/library/cc190881(VS.95).aspx)

Well, what I trying to say is that if we have a boat, don't expect it to run in a road, except if we accept to have a tricky boat with whells. The best to do in the case is to work with shapes, which is what SL is made to.


Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.