|
Ok, so I discovered that some of the encoders (possibly all of them?), has a rotation property where I can specify whether a rotation should occur when saving the image. Still it only supports increments of 90 degrees which is inadequate for me, so I simply do the rotation manually.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
Hey. I need some help determining the image format of an, well, image.
I have a small WPF program where I can open and display images. I load a BitmapImage objec,t and display it on an Image control in a window, and that all works fine.
Now I would like to save the image when changes are done to it, and I would like to save it in the format which was originally opened. So if I opened a JPEG image I would like to encode the BitmapImageSource as an JPEG using the JpegBitmapEncoder and that's all nice and works.
But when I load the BitmapImage it automatically determines the decoder to use, and when it's time to save the image I can't find an easy way of determining which encoder to use. I guess I could save the file name when I open it, and the from that deduce the file type and from that the image type and from that the encoder to use. It just seems so messy. I kind hoped the BitmapSource would save this information in some metadata, but doesn't (or so it seems).
Any advice as how to easy determine what encoder to use? Did I miss some obvious approach?
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
|
Hi Chandra,
No, I did actually find that page during my research. Believe my Google is my main research tool
My problem is that it seems kind of stupid that I would have to go through all that manually, when WPF does it as well since it decides on the correct decoder when I loads the image. I would just like to get to that information so I can easily decide on what encoder to use.
But thanks none the less.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
Rohde wrote: No, I did actually find that page during my research. Believe my Google is my main research tool
Hi
I wasn't trying to be a smartass - deciphering the header was what I had implemented in one my apps (though not WPF).
I am a complete ignoramus as regards WPF... If as you say WPF already does the decoding when loading the file, maybe there is a property that says what type of image it is? Or does the load image method return an image type?
|
|
|
|
|
Hi,
ChandraRam wrote: I wasn't trying to be a smartass
I know, I know. I didn't mean to imply that you were
ChandraRam wrote: If as you say WPF already does the decoding when loading the file, maybe there is a property that says what type of image it is?
You would think, but I just cannot find it. I will keep researching, I'm sure there's some logical way of doing it.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
This opens and saves a copy using the same format. I think decoder.CodecInfo has the info you need.
var uri = new Uri(@"C:\input.jpg");
BitmapDecoder decoder = BitmapDecoder.Create(uri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapEncoder enc = BitmapEncoder.Create(decoder.CodecInfo.ContainerFormat);
enc.Frames.Add(BitmapFrame.Create(decoder.Frames[0]));
enc.Save(new FileStream(@"C:\output.jpg",FileMode.Create));
|
|
|
|
|
Thank you Dave. That's exactly what I was looking for.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
modified on Thursday, May 29, 2008 1:49 PM
|
|
|
|
|
I want to start making my wpf user interfaces more interactive.
i am starting with a spring animation similar to
http://www.myphysicslab.com/spring2d.html
download my project: "FirstAnimation" here:
http://files.mixhacks.com/FirstAnimation.zip[^]
There are 3 attempts in the project:
1) is based off RungeKutta4 class found in "Practical WPF Graphics Programming by Jack Xu" ...
i'm missing something which after days of reading and hours of troubleshooting i haven't been able to fix.... anyone?
2) is an attempt to create my own solution using something i can more easily digest... vectors.
however again it has a problem. It does oscillate but .... take a look
note: it uses the vector3 class found here on codeproject.
3) the last one works .. which is based off Keith Peters flash book.... although the animation looks good its not real physics.... Foundation Actionscript 3.0 Animation: Making Things Move!
it doesn't compare to the 2d spring example above.
I'm posting this here in hopes that someone can shed some light to a newbie in animation and game programming with wpf.
Lastly....
are there any wpf projects attempting to bring compiz to normal devs?
http://compiz.org/Home/Screenshots
to normal devs in wpf?
http://www.youtube.com/watch?v=wOPOXSoArWQ
http://news.opensuse.org/2007/09/04/sneak-peeks-at-opensuse-103-compiz-and-compiz-fusion/
http://en.opensuse.org/Compiz_Fusion - see the alternative projects section for projects similar to compiz
|
|
|
|
|
|
Hi,
I would like to ask anyone have any ideas how to create own set of tool palette such as pen tool,brushes using Silverlight?
Thx.
Regards,
Katelva
|
|
|
|
|
katelva wrote: I would like to ask anyone have any ideas how to create own set of tool palette such as pen tool,brushes using Silverlight?
You mean, you want to create your own pen tool or brushes in Silverlight? Why? Silverlight already have path and brushes so why don't you use them?
|
|
|
|
|
Do you mean I can use the path in Silverlight? Can you teach me how to access the path and brushes of silverlight? Coz I would like to create something like paint application online? When user clicks on the pen tool, then the user can draw online?
Thanks
Regards,
Katelva
|
|
|
|
|
katelva wrote: I would like to create something like paint application online? When user clicks on the pen tool, then the user can draw online?
Yes. Actually, there are one online application for that. Please take a look at SilverInk[^] and tutorial[^]
I think you are very new to Silverlight. Otherwise, you won't ask how to use the path and brushes in Silverlight.
Please take a look at Silverlight Quick Start[^]. You can learn how to use Silverlight from that page. then, you can focus on how to drag and drop in Silverlight. after that, you will be able to create Silverlight paint.
|
|
|
|
|
Hi All,
Just need a couple of pointers as to why something isn't working ...
Say I have a textbox on my WPF 'form' thus:
<TextBox x:Name="EnabledTextBox" Style="{DynamicResource TextBox.Default}" ToolTip="TextBox" Text="Hello World!" TextWrapping="NoWrap" Margin="4,4,4,4" IsEnabled="True"/>
Then in my code I'm walking the visual tree and grabbing various bits of information like:
if (obj.ReadLocalValue(NameProperty) != DependencyProperty.UnsetValue)
{
_elementName = obj.ReadLocalValue(NameProperty).ToString();
}
this results in _elementName being "EnabledTextBox" ... great all good. But when I do the same for the Style:
if (obj.ReadLocalValue(StyleProperty).ToString() != null)
{
_styleProperty = obj.ReadLocalValue(StyleProperty).ToString();
}
Style always results in "System.Windows.ResourceReferenceExpression" I've been looking through the object explorer windows on a breakpoint. How do I drill down further to get the bound style ResourceKey ...
hmm ...
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi All,
I've been going round in circles on this now for nearly two days ... I've exhausted my ideas completely. Any help with this would be great.
Thanks,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
obj.GetValue(StyleProperty) returns a style, if you use a StaticResource your method works.
MSDN says
You should use GetValue for most typical "get" operations for a dependency property. ReadLocalValue does not return the effective value for a variety of circumstances where the value was not locally set.
Values that are set by styles, themes, templates, the default value from metadata, or property value inheritance are not considered to be local values. However, bindings and other expressions are considered to be local values, after they have been evaluated.
Mole is a lot more useful that the watch/locals window for WPF.
|
|
|
|
|
Hi Dave,
Indeed ... my method returns a string of System.Windows.Style ...
My style is set as Style="{DynamicResource TextBox.Default}" even looking through the visual tree using Mole/Woodstock doesn't get the value I'm interested in!!!
Mole shows a null reference and Woodstock has an empty box for the Style property. Yet when I hover over my obj and walk around the debug popups I can find "TextBox.Default" in the list of effective values ...
If Mole and Wodstock can't get at these values it makes me wonder if its even possible ...
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
What is the value you are after?
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<Style x:Key="TextBox.Default" TargetType="{x:Type TextBox}">
<Setter Property="FontFamily" Value="Century Gothic"/>
<Setter Property="FontSize" Value="40" />
</Style>
</Window.Resources>
<Grid>
<TextBox x:Name="EnabledTextBox" Style="{DynamicResource TextBox.Default}" ToolTip="TextBox" Text="Hello World!" TextWrapping="NoWrap" Margin="4,4,4,4" IsEnabled="True"/>
</Grid>
</Window>
var value = EnabledTextBox.GetValue(StyleProperty) as Style;
if (value != null)
{
foreach(Setter s in value.Setters)
{
Console.WriteLine(s.Property + " = " + s.Value);
}
}
Outputs
FontFamily = Century Gothic
FontSize = 40
|
|
|
|
|
I'm actually after all the properties of any given control. So that would start at TextBox.Default and then a tree of all the colours and property values for that instance of TextBox.
So I guess your code is going to be very useful, thanks for that. I also need to grab the actual name of the style that has been applied to the control at run time.
maybe this?
var value = EnabledTextBox.GetValue(StyleProperty) as Style;
if (value != null)
{
_styleName = value.ResourceKey
}
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
I made a project in which i have to use web camera.
I have to make a Interview process in asp.net2.0.
i don't know how to configure or code web camera in asp.net.
It means i want to make a interview process in which both side have a web camera, both can see the live movement from both side.
how it is possible????
please help me.....
|
|
|
|
|
You won't be able to access the user's microphone or webcam from Silverlight application.. So, what you can do is that you can upload a few pieces of video to server and steam it from Silverlight...
but if you are asking ASP.NET question, you can post it here[^]
|
|
|
|
|
|
Hi All,
I was using mx.messaging.MessageAgent package for developing Actionscript3. Now i want to convert project into SilverLight so i want to know which is alternative namespace or Class is available in .Net Silverlight.
Regards
Atul
|
|
|
|
|
Atul23 wrote: I was using mx.messaging.MessageAgent package for developing Actionscript3.
I already replied you in your previous message. What does that namespace do?
|
|
|
|