The software rendering code goes in the loaded event and you apply it to the window, but im not sure it will have any effect if you are just saving the image and not displaying it. I've been working with a high res (5k by 7x) photo and haven't seen anything yet. Im using VS 2010 on vista but have tried targeting both 3.0 and 3.5 and checked they are referencing the correct version. I have also installed the platform update for vista which may have updated the windows imaging component. This thread is the only one i've found that might be applicable but I think you'll have to contact microsoft or try their wpf forums.
The software rendering code goes in the loaded event and you apply it to the window, but im not sure it will have any effect if you are just saving the image and not displaying it.
In my original application, I'm just saving it and not displaying it, but I've written a test application based on code you provided where I just display it and don't save it. I was actually surprised when I saw the bug appear even in this simplified code. I've written the following function, based on code you provided, and this function demonstrates the problem with 100% reliability in 10 different images from my Nikon D2X camera:
void ScaleBitmapImage(string imagePath, double targetSize, Image image)
Uri uri = new Uri(imagePath);
BitmapImage bitmapImage = new BitmapImage(uri);
var scale = targetSize / bitmapImage.PixelWidth;
TransformedBitmap scaledBitmap = new TransformedBitmap();
scaledBitmap.Source = bitmapImage;
scaledBitmap.Transform = new ScaleTransform(scale, scale);
image.Source = scaledBitmap;
Insincere Dave wrote:
Im using VS 2010 on vista
I'm using VS 2008 on Vista, but I have installed VS 2010. I just haven't gotten around to trying it out yet on 2010. Maybe I should try that next.
Insincere Dave wrote:
I have also installed the platform update for vista which may have updated the windows imaging component.
I've been Googling around trying to figure out how to download this update and I haven't found anything definitive. I've seen plenty of references to it but no specific link to a download page. I followed Microsoft's instructions at this link:
But when I follow the instructions, the closest thing it lists in the Windows Update List is an item called, "Update for Windows Vista for x64-based systems - English (KB937286)". Hopefully that is the same thing as the Platform Update for Vista. I'm about to do that now, which of course means rebooting my machine. I'll let you know how things turn out. I'd love to be able to tell my customers what needs to be done to solve this horrendous bug.
Well, that update I mentioned (KB937286) wasn't the Platform Update for Vista, but something that just came out today. Also, VS 2010 doesn't solve the problem. I converted my little application to VS 2010 and the problem still shows up. I guess I'll have to keep searching for the download page for the Platform Update for Vista. I don't know why the Microsoft download page doesn't show up when I Google for it, only a bunch of pages that mention that it's been released, and I haven't found any of those pages giving the link to the download page.
Yes, I found that link and followed the instructions. I didn't find a reference to the Platform Update for Vista. So I investigated further and saw that before the Platform Update can be installed, you have to have Vista SP2 installed, which I didn't! As I type, it is ready to be installed. After it gets installed, 971644 will hopefully show the Platform Update available for installation. Right now I have to shut everything down before the SP2 installation will start!
Incredible! Getting the Platform Update for Vista installed did the trick! Thank you so much for sticking with me! So this is probably not a problem under Windows 7, and I don't think there's a fix for it under XP. I'll have to document that in my application.
Im glad that fixed it, I thought that was kind of a long shot really. I tried scaling an Image control and using RenderTargetBitmap and didn't notice any quality degradation so that might be a workaround for xp, there are some other options like System.Drawing aswell.
The code you supplied does work and at least superficially (without "pixel-peeping") provides good quality. Of course the following line does not compile:
Insincere Dave wrote:
but can be replaced with code that does and the scaled image file does not contain artifacts, even on an XP system.
In Googling, I was surprised by how many people can't get RenderTargetBitmap to work, complaining of blank images. I tried some of the code posted that supposedly works and I also got blank images, and solutions posted that supposedly fixed the blank images did not work. But your code works, and I never saw anyone post that solution. Where did you get it, or did you just figure it out? The code I've seen posted is also considerably more complicated than what you posted.
In any case, I now have software rendering code that I can use for XP systems and Vista systems not up to SP2. Once again, thank you very much.
I'm not even going to try the WIC solution because I don't want to contaminate my application with COM code.
I can't remember where I first saw code using RenderTargetBitmap, you need to call measure and arrange if the item hasn't been added to the visual tree otherwise it's not necessary. WPF uses WIC so that patch might still be applicable but I don't know if it will fix the issue.
Thanks for the explanation for using Measure and Arrange. I'm still trying to get my head around those two functions.
I haven't performed any measurements, but using software rendering doesn't appear to be all that much slower than using the video card, even on my wife's entry level PC running XP. (It does have 2 GB RAM, however.) I guess modern PC CPU's rival video card GPU's for simple things like bitmap rendering. So I'm not (yet) motivated to see whether the new WIC for XP solves the problem. I suspect it does, but I'm thinking, so what? Software rendering seems to be working fine in my application.
Hi, i am not sure if this is a good place to ask the following, but...
is there a method to export/import a playlist into Windows Media Player (10 and above?)
I'm creating a media manager database in Access 2007. I will have a collection of various files (audio, video, images, .PPT, .DOC, ..). If i could build a playlist containing a collection of my files, I want a format that can be imported into Windows Media Player.
I see iTunes has a feature that allows Import/Export of a playlist and thought something might also exist in the Microsoft environment.
If anyone have any idea to do this please reply me.
I created one WPF dll usig C#.And im using that in VC++.I added that WPF control.dll through add reference.
But i nedd is, when i click the button in that WPFcontrol.dll,it should invoke the fucntion in vc++.
If i created one MFC dialog in VC++,when i press that button in WPF control,it should show the dialog created in vc++.
How can i do that. Pls help me.
I have not seen WPF so I may be wrong here.
You should, if possible, create a delegate for the button click in your WPF dll. Then, wherever you use that dll, handle the click event in the parent form/page.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
I have an object called "user" on the codebehind of a mainpage that shows if is anyone signed up on the webpage. The structure of the silverlight app is: a mainpage and a navigation:frame inside. I want to access to public object "user" from the navigation frame. the navigation frame is a xaml navigation:page.
How can i do it from the codebehind?
Last Visit: 31-Dec-99 18:00 Last Update: 26-Sep-23 15:39