WPF Image Color Tint - wpf

I am loading several images in WPF and from what I have read, it keeps them all in memory.
I was wondering why it is that when I display my image, that there is a red/purple tint?
Has anyone experienced this issue before?
I set up an Image class using the Designer, then I set the Image.Source to my ImageSourceConverter.ConvertFromString("MyFilepath.png")
I also set
Image.Stretch = Stretch.Fill (if that helps)
It seems that some images have a reddish discoloration to them. I cannot figure out why...?
EDIT:
I tried to post images, but stackoverflow's convenient spam prevention said I could not post them because I just joined...

Is it possible there's a translucent overlay in your XAML causing the discoloration? It could also be an encoding issue... Can you post a sample of your code?
Also, although you can't embed images directly in your post because of your newness, you could upload the image to imgur.com, for example, and post a link to that image.

Well, I found that after I changed the images from .png to .jpg, the discoloration was no longer an issue. I am wondering what might have caused this?
I do not think it was the alpha transparency of the .png's, but rather the ImageSourceConverter itself...?

This was most likely caused by dithering effect. It should go away after you set the following property on your Image element to true:
SnapsToDevicePixels = "True"

Related

Openlayers - Image layer's source(Raster) disappears on each zoom

I'm having a case where I have to create a Hillshading Image layer on top of the original Raster WebGLTileLayer(GeoTIFF source) to show hillshading view. I'm facing an issue where
The source tile layer disappears on each zoom as the hillshade Image layer is being rendered.
Sometimes, the hillshade is not appearing even when the raster source is given correctly.
Has anyone faced this issue before. If so, can someone help me out.
I was able to solve the issues using style instead of tilelayer as raster source, as done here - https://openlayers.org/en/latest/examples/webgl-shaded-relief.html
Thanks to #Mike 's comment.

ios6 UIImageView - Loading -568h image

I've seen a couple posts about the UIImage automatically loading the filename-568.png image in the new iOS6, but I can't seem to recreate it in the UIImageView class.
I'm using the Storyboard (not my app, just having to do some checks), and I've a simple layout with just the Image View scaled to fit, no code in the view controller, and I've sure the filename.png and filename-568h.png exist (as well as -568#2x.png just in case) but when I load it up in the iOS6 simulator. This has been for iOS 4 and 5, loading the #2x image for retina, doesn't seem to work in iOS6 though. Any ideas?
The image happens to be called Default.png since it is the same as the launch image, could this be the issue?
Thanks for any help in advance
iOS6 does NOT automatically load -568h as it does with the #2x images. The only exception is the default screen, but further than that you have to manually set you 568h image yourself.
I created some code to mimic the loading behavior for -568h images when using the [UIImage imageNamed:#""] method, but from the IB I do not know the way. If you are interested in such a solution, check it out at http://angelolloqui.com/blog/20-iPhone5-568h-image-loading
Typically, you should only use 568h for the launch image. If you notice yourself using different image assets within your app for the new display height, you should consider that you might be making your UI too static.
The most obvious place people want to use 568h for images is for background images. An alternative is to just have one asset that has the largest possible dimensions and align it properly using the contentMode property of UIView.
But perhaps you have something floating in the image at the top and the bottom, so contentMode doesn't solve it. You could consider that the top and bottom floaters should probably be separate views anyway.
Remember, we have always been making apps with variable heights. Every time a keyboard pops up, its as if the size of the screen has shrunk.

Downloaded Panorama background image is cropped to screen size

If I set the Panorama.Background image brush source to a URL of a photo out on the internet, the image is centered and cropped, rather than starting at the left edge and bleeding off the screen to the right, widescreen style.
If I set the source as a local pack URI, its fine.
Smells like a bug.
Anyone got a simple workaround? Microsoft should be equipping us with a working SDK that allows us to create experiences at least as good as the phone's hubs.
Thanks!
UPDATE
The problem appears not to be images on the web, but images that are smaller than the screen size of the phone - all my web-hosted images are quite small for bandwidth reasons.
Taking my original background art 1024x768 and halving its size results in the phone cropping the right edge of the image.
UPDATE 2
Found someone else with the same problem:
http://forums.create.msdn.com/forums/p/78770/615061.aspx
UPDATE 3
http://www.lukepuplett.com/2012/05/windows-phone-panorama-background-image.html
Side-by-side images demonstrate the bug, clearly. I'll throw it over to Cliff on the team in Redmond and see what he thinks.
It's a problem I've found since my earliest days with the phone, and I assumed it'd be quite a well-known issue. So I expected people to quickly say "Oh yeah, that old chestnut, you need to do XYZ."
Thanks for the -3, everyone. Keep up the good work.
Before running around with "IT'S A BUG!" claims, I would do my research.
That being said, you are downloading an image, and most likely using a combo of BitmapImage/ImageBrush. Now, ImageBrush has a Stretch property and that is where you have to look.
The panorama background is intended to be a rich, high quality image.
I would expect what you're seeing ("inconsistent" resizing) if you're using an image smaller than the space you're filling and not specifying how it should be stretched.
If you're claiming a bug, what is the behaviour you're expecting?
Based on your blog post (liked in update 3) it seems you're expecting a different default stretch behaviour for an image when used in the background in a panorama. As a general rule, introducing inconsistencies or conditional defaults is likely to introduce more confusion and work in the long run.

Render WriteableBitmap in WPF

I have noticed a bizzare situation - in SIlverlight, when a picture is rendered using WriteableBitmap Render method, the resulting pic is very sharp. Of course in WPF Render method is not available. I have used DrawingGroup to render two images on top of each other (I have got a png with transparency and standard JPEG). However in that case the resulting bitmap is not so sharp (especially in case of text).
Could you see any reasons for that? Have you faced such a problem?
Any ideas for the solution?
I need to 'put' a png with transparency on jpeg image and get a precise resulting pic.
Thank you in advance for the replies!
Cheers
Have you tried BitmapScalingMode on RenderOptions? It's an attached property that applies to most DependencyObjects that have anything to do with drawing images. An example:
<object Name="myObject" RenderOptions.BitmapScalingMode="HighQuality" .../>
or to do this in codebehind:
RenderOptions.SetBitmapScalingMode(myObject, BitmapScalingMode.HighQuality);

Make part of an image transparent

I want to put an image on a button, but I want part of the image to be transparent. How do I do this?
Try the Image.OpacityMask property. You can give it a brush that specifies the region you want to be transparent.
EDIT: From MSDN:
There is no direct support for
color-keying a bitmap in WPF.
However, it is fairly easy to
implement on your own. Dwayne has
implemented a ColorKeyBitmap on his
blog:
http://blogs.msdn.com/dwayneneed/archive/2008/06/20/implementing-a-custom-bitmapsource.aspx
I believe it links to the code on
Codeplex as well. You could also
accomplish this simply by reading your
bitmap into system memory, iterating
through all the pixels and setting
their values yourself, and
constructing a new bitmap out of that
array.
Use a paint program (I use Paint.Net) to change the area you want transparent to an alha=0 color. Then save the image (mine was JPG) as a PNG. Seemed to work fine for me in the WPF Image control.

Resources