|
OK - given that an image exists in memory as pixel data, and not as JPEG compressed data, I'd have assumed that any rotation is lossless in memory, but that you need to apply JPEG compression in order to save the image. You're saying this is not the case ? How odd.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian Graus wrote: given that an image exists in memory as pixel data, and not as JPEG compressed data
This assumption is wrong, that's your conceptual mistake. There has to be a way of reading the image data into memory intact, without using a decoder. Then you do the bit-twittling necessary to transform the raw image data. Nothing is ever decompressed or compressed in this process.
Christian Graus wrote: but that you need to apply JPEG compression in order to save the image
You're thinking in terms of the very classes that I said cannot be used.
Christian Graus wrote: You're saying this is not the case ? How odd.
That's precisely what I'm saying, and it's not so odd if you understand what I'm talking about. Evidentally you've never heard of lossless JPEG rotation, but what do you think Photoshop does, or any other self-respecting image processing software?
I mean if I have to go to GDI+ to accomplish this, I'll do it, but that would really rub me the wrong way. I didn't sign up to WPF to go outside of it every time I turn around.
modified on Wednesday, June 10, 2009 4:01 PM
|
|
|
|
|
fjparisIII wrote: This assumption is wrong, that's your conceptual mistake.
Well, no. Once your image is in a bitmap, it's raw data, it's not JPEG compressed.
fjparisIII wrote: There has to be a way of reading the image data into memory intact, without using a decoder.
OK, I get it now. You rotate it, as a JPEG, in memory, not as a bitmap. Thus keeping the artefacts you have, but not creating new ones ?
fjparisIII wrote: Evidentally you've never heard of lossless JPEG rotation, but what do you think Photoshop does, or any other self-respecting image processing software?
I was aware they did that, but I'd never taken the time to wonder what it meant. I believe the Atalasoft library we use for DICOM compression offers what you're talking about.
fjparisIII wrote: I mean if I have to I'll go to GDI+ to accomplish this, I'll do it, but that would really rub me the wrong way. I didn't sign up to WPF to go outside of it every time I turn around.
I wrote a program in WPF, it's basically an image viewer. Our images are huge, and memory management in WPF is a joke ( in fact, we hard reset the GC regularly, or WPF just flat out dies ). So, when we load images from our DB, we resize them to the size of the screen, and then reload as we zoom, to save memory. We have two types of image, illustrations that are pngs, and photos that are jpgs. I don't know if it's the format, or the type of data, but our jpegs, when resized, would get all sorts of horrible artefacts. I was a Microsoft MVP at the time, so I theoretically had a fast track to support. I reported this, they responded that there was no problem. I sent a sample app to show the issue, got the same response. I wrote back and insisted, they finally looked at it and admitted it was broken. This was .NET 3.0, two years ago. The bug is still there, and WPF still does not expose Dispose methods, or clean up after images properly. So, get used to horrible imaging support in WPF. We resize our images using GDI+.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian Graus wrote: You rotate it, as a JPEG, in memory, not as a bitmap. Thus keeping the artefacts you have, but not creating new ones ?
Exactly. Now you get it.
Regarding your WPF application that resizes images to fit the display, my application does the same thing. I don't know if you'd call my images huge (they're from 12 MPixel Nikon cameras, so 4288x2848), but WPF scales them in about two seconds.
Are you using the CroppedBitmap class to do this? I don't bother with this. Instead I just set the Margin property of the Grid object that holds the System.Windows.Controls.Image object that lives inside the grid. It works pretty well. I even use the same technique for zooming around an image at 1:1. The margin just propagates down to the image. I never touch the original bitmap once it decoded. I just let WPF worry about it and since WPF goes directly to DirectX it's pretty fast.
In fact one of my beta testers (actually pre-alpha) is amazed by how fast my new app based on WPF rotates images compared to the original C++/MFC app that used GDI+, which I guess goes through gobs of layers. My new app basically rotates an image instantly even on his slow machine, whereas my original GDI+ app takes a couple seconds on his machine.
I also support saving resized images to disk. I haven't noticed the "horrible artifacts" that you report. I'm using .NET 3.5.
I'm also somewhat disconcerted by the lack of low level control over garbage collection under .NET, especially since my app offers batch operations that can process thousands of images in a background thread. But it seems to do okay, not really any worse than my original C++ app based on GDI+.
What I've found is that the time to load a program can be a problem if it needs dozens of pages it has to render during startup. It's that JIT compiling that's the bottleneck. I'm still in pre-alpha testing so I'm not too worried about performance yet, but eventually I'll have to load pages on a demand basis so that the app displays instantly, instead of rendering all 70 pages that are in the app currently before it gives control to the user. On my 64-bit machine with 8 GBytes of RAM, the program displays in 2 seconds, but on my beta tester's machine with 1 GByte of RAM, it takes 30 seconds to render the app. Ugh!
Where WPF really shines and blows old rendering technologies away is individual image processing operations: displaying (say) an image that is 1920x1440 on a monitor that size is instantaneous, whereas with my old C++ app using GDI+ it would take a couple seconds to render such an image.
There's huge promise in WPF. I just hope Microsoft doesn't give up on it.
modified on Wednesday, June 10, 2009 5:01 PM
|
|
|
|
|
fjparisIII wrote:
Are you using the CroppedBitmap class to do this? I don't bother with this. Instead I just set the Margin property of the Grid object that holds the System.Windows.Controls.Image object that lives inside the grid. It works pretty well. I even use the same technique for zooming around an image at 1:1. The margin just propagates down to the image. I never touch the original bitmap once it decoded. I just let WPF worry about it and since WPF goes directly to DirectX it's pretty fast.
Yeah, we did that. But, our images are actually bigger than that, and as the use of our app means swapping images a lot, WPF basically would crap out and crash in time. Initially, it worked great, we moved to this to try to get out of memory issues.
fjparisIII wrote: I also support saving resized images to disk. I haven't noticed the "horrible artifacts" that you report. I'm using .NET 3.5.
I just ran my test app, the one I sent Microsoft, and it still happens. Radiographs were the images that showed it the worst, others, you had to look for. Also, it only happens on certain resizings, that is, you could resize several times before suddenly it would go bad. My test app remembers a setting that destroyed this particular picture, and applies it every time.
fjparisIII wrote: I'm also somewhat disconcerted by the lack of low level control over garbage collection under .NET, especially since my app offers batch operations that can process thousands of images in a background thread. But it seems to do okay, not really any worse than my original C++ app based on GDI+.
If you ever find that your app crashes, just ask, I'll post the code to fix that. In fact, I'll post it on my new blog some time soon, anyhow.
fjparisIII wrote: What I've found is that the time to load a program can be a problem if it needs dozens of pages it has to render during startup.
Yeah, and WPF is so slow to load to start with, we use a Win32 app as our splash screen, b/c otherwise it just was not responsive, it took ages to appear.
fjparisIII wrote: On my 64-bit machine with 8 GBytes of RAM, the program displays in 2 seconds, but on my beta tester's machine with 1 GByte of RAM, it takes 30 seconds to render the app. Ugh!
Yeah, we have users with 256 MB, although we say 512 is the minimum. I HAVE been pleasantly surprised at how the app performs on notebooks with shared video, I expected that to be a non starter.
fjparisIII wrote: There's huge promise in WPF. I just hope Microsoft doesn't give up on it.
I believe WPF is what they wanted Winforms 1.0 to be. I doubt they will give up on it. I agree, it has a lot of promise, and certainly the apps we write with it are way cooler than anything we could easily do in Winforms.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi
I'm trying to create a 3D modeling app in WPF, my app reads values from a database and generates 3D models based on the dimensions read out from the database, everything works fine, except for my models looking a bit dull. Also, when I rotate the camera at a certain angle, I can't differentiate between the different models because they overlap and there's no clear distinction between them, as they're all the same color.
I've tried playing around with specular materials as well as different kinds of lighting, but I can't seem to get it right.
If anyone has already created a similar application, or any application where you worked with 3D models, please help me find the correct combination of materials and lighting.
|
|
|
|
|
I have a silverlight application which uses wcf service hosted in a wpf application, but when I try to connect more
then one client the second client always waits until the first client
completes the call.How can I make
WCF to accept calls from multiple clients at the same time?
|
|
|
|
|
See Here[^]
There's no need to post to multiple message boards. This is a WCF question,
this is the correct board.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have a silverlight application which uses wcf service hosted in a wpf application, but when I try to connect more
then one client the second client always waits until the first client
completes the call.How can I make
WCF to accept calls from multiple clients at the same time?
|
|
|
|
|
I would start by setting the service ConcurrencyMode to Multiple
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple]
public class MyService : IMyService
{
...
If you have operations that take time and/or block (like pretty much any device
I/O operation does), which apparently you do, you should implement the service
operation(s) asynchronously:
Synchronous and Asynchronous Operations[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the answer,But I already used [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple],but the problem still exists,Also implemented the service as asynchronously,Could you suggest any other solutions?
|
|
|
|
|
I have no idea what's wrong.
It could be in host configuration, service configuration, or the service implementation.
I can't reproduce this, even without the [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)].
Even a synchronously implemented operation like
public string EchoStringSynchronous(string msg)
{
Thread.Sleep(10000);
return msg;
}
can be executed by multiple clients without a client having to wait for
another client's operation to complete.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I am working on WPF application. In this I have to save images into a folder named Slides which is in the application and I have to retrieve these images. But I am getting error with the path. I am able to access folder in some other drive but I am getting error when I directly access the folder.
string CanvasFile = "d:\\canvas" + Canvasnum + ".png";
util.SaveCanvas(this, this.canvasDesigner, 136, CanvasFile);
Image img = new Image();
img.Source = new BitmapImage(new System.Uri(@"D:\canvas.png"));
panel.Children.Add(img);
If anyone have idea to access the folder in the application directly lease reply me.
Thanks in advance.
|
|
|
|
|
Do you want to retrive the images from disk at runtime or use images that are part of the assembly?
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Nekkantidivya wrote: I am working on WPF application. In this I have to save images into a folder named Slides which is in the application and I have to retrieve these images. But I am getting error with the path.
What is the error ?
It's not clear as to exactly what is the issue. Can you rephrase the question ?
|
|
|
|
|
Try this i am sure this will help u.
1.In Visual Studio, click the Project menu, and select Add Existing Item. Find and select the image you want to add to your project.
2.In the Solution Explorer window, right-click the image file you just added to your project, and select Properties from the popup menu. The Properties tool window appears.
3.In the Properties window (see picture below), change the Build Action property to Embedded Resource.
4.Build the project. The image will be compiled into your project's assembly.
Load Image Resource
Be sure to include the following namespaces in your project:
using System.IO;
using System.Reflection;
To load the image resource programmatically, use the following code:
Assembly myAssembly = Assembly.GetExecutingAssembly();
Stream myStream = myAssembly.GetManifestResourceStream( "MyNamespace.SubFolder.MyImage.bmp" );
Bitmap bmp = new Bitmap( myStream );
The trickiest part of loading an embedded resource is getting the correct path. A resource path takes this form:
<namespace>.<subfolders>.<image name>.<extension>
where:
namespace is the namespace for the project
subfolders is the folder path within the project, with each folder separated by a period instead of a slash
image name is the name of the image file
extension is the image file extension (for example, "bmp" or "jpg")
|
|
|
|
|
Hello,
What i am doing is, i am creating a Datatable based on values that user fills up in the form.
Further i am assigning that datatable to the WPF datagrid to display the Grid.
dgMatrix.ItemsSource = GetDataSource.DefaultView
Now, as the user edits the grid and presses the SAVE button under the grid, I would like to save all the rows of the Grid into a new table in the database.
Is there a way to loop through each row of the Grid and then inserting each record into the database??
In ASP.net i was using the following function:
'For Each row As GridViewRow In dgMatrix.Rows
'
' Dim checkbox As CheckBox = CType(row.FindControl("cbRows"), CheckBox)
' If checkbox.Checked Then
' Try
' Dim txtFromPorts As TextBox = CType(row.FindControl("txtPortsFrom"), TextBox)
' Dim txtToPorts As TextBox = CType(row.FindControl("txtPortsTo"), TextBox)
' Dim txtFType As TextBox = CType(row.FindControl("txtFareType"), TextBox)
' Dim txtFClass As TextBox = CType(row.FindControl("txtFareClass"), TextBox)
' Dim txtLowGAmt As TextBox = CType(row.FindControl("txtGrossAmtLow"), TextBox)
' Dim txtLowNAmt As TextBox = CType(row.FindControl("txtNettAmtLow"), TextBox)
' Dim txtHighGAmt As TextBox = CType(row.FindControl("txtGrossAmtHigh"), TextBox)
' Dim txtHighNAmt As TextBox = CType(row.FindControl("txtNettAmtHigh"), TextBox)
' Dim txtPeakGAmt As TextBox = CType(row.FindControl("txtGrossAmtPeak"), TextBox)
' Dim txtPeakNAmt As TextBox = CType(row.FindControl("txtNettAmtPeak"), TextBox)
' ' Dim dr As DataRow = dtNew.NewRow
' strFrom = txtFromPorts.Text
' strTo = txtToPorts.Text
' strFareType = txtFType.Text
' If txtFClass.Text.Trim <> "" Then
' strFareClass = txtFClass.Text
' End If
' If txtLowGAmt.Text <> "" Then
' strGrossLow = txtLowGAmt.Text
' End If
' If txtLowNAmt.Text <> "" Then
' strNettLow = txtLowNAmt.Text
' End If
' If txtHighGAmt.Text <> "" Then
' strGrossHigh = txtHighGAmt.Text
' End If
' If txtHighNAmt.Text <> "" Then
' strNettHigh = txtHighNAmt.Text
' End If
' If txtPeakGAmt.Text <> "" Then
' strGrossPeak = txtPeakGAmt.Text
' End If
' If txtPeakNAmt.Text <> "" Then
' strNettPeak = txtPeakNAmt.Text
' End If
' 'Check if the checkbox is checked.
' strSQL = "INSERT INTO FareInfo (" + _
' "FareId," + _
' "PortsFrom," + _
' "PortsTo," + _
' "FareType," + _
' "FareClass," + _
' "GrossAmtLow," + _
' "NettAmtLow," + _
' "GrossAmtHigh," + _
' "NettAmtHigh," + _
' "GrossAmtPeak," + _
' "NettAmtPeak" + _
' ") VALUES ("
' If (strFareId <> "") Then
' strSQL = strSQL + "'" + strFareId + "',"
' strSQL = strSQL + "'" + strFrom + "',"
' strSQL = strSQL + "'" + strTo + "',"
' strSQL = strSQL + "'" + strFareType + "',"
' strSQL = strSQL + "'" + strFareClass + "',"
' If strGrossLow <> "" Then
' strSQL = strSQL + " " & strGrossLow & " ,"
' Else
' strSQL = strSQL + " " & "null" & " ,"
' End If
' If strNettLow <> "" Then
' strSQL = strSQL + "" + strNettLow + ","
' Else
' strSQL = strSQL + " " & "null" & " ,"
' End If
' If strGrossHigh <> "" Then
' strSQL = strSQL + "" + strGrossHigh + ","
' Else
' strSQL = strSQL + " " & "null" & " ,"
' End If
' If strNettHigh <> "" Then
' strSQL = strSQL + "" + strNettHigh + ","
' Else
' strSQL = strSQL + " " & "null" & " ,"
' End If
' If strGrossPeak <> "" Then
' strSQL = strSQL + "" + strGrossPeak + ","
' Else
' strSQL = strSQL + " " & "null" & " ,"
' End If
' If strNettPeak <> "" Then
' strSQL = strSQL + "" + strNettPeak + ""
' Else
' strSQL = strSQL + " " & "null" & " "
' End If
' strSQL = strSQL + ")"
' End If
' DBClass.ExecuteQuery(strSQL)
' gvMatrix.Visible = False
' 'Insert 1 row in Progress grid
' Catch ex As Exception
' End Try
' End If
'Next
Can someone suggest me the right way to do so in WPF. I would really appreciate that, Thanks.
|
|
|
|
|
I believe the idea is that updates to the grid automatically update the data source, and so you should iterate over that.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Thanks for reply Christian.This is what i have done,
dvMatrix = GetDataSource.DefaultView
dgMatrix.ItemsSource = dvMatrix
Datasource1 = GetDataSource()
So, I am assigning itemsource using GetDataSource method which returns me a datatable. I will store it in a public datatable variable(DataSource1).
So inside the btnSave_click event,
Dim dt As DataTable
Dim dr1 As DataRow
dt = Datasource1 'i am using the datatable- DataSource1
Dim jk = dt.Rows.Count
For Each dr1 In dt.Rows
strFrom = dr1("PortsFrom")
strTo = dr1("PortsTo")
....
next
Problem is, i am still getting original grid content not the modified content.
Is there something i need to do inside dgMatrix_RowEditEnding function to update the datasource??
|
|
|
|
|
Your datasource needs to be an observablecollection for this to work. Perhaps it's not.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Excellent,with observablecollection its working. Thanks a ton for guiding me!!!
|
|
|
|
|
Just because i thought it will help me in future. If we fetch data from some table in database, into a observable collection.
And then display that data in the grid.
When the user edits the grid, changes are reflected in observable collection, is there a quick way to commit those changes in the database as well??
|
|
|
|
|
I don't really know, to be honest. I've not done any database work with WPF yet, that is nothing to a SQL database, all to my own file formats. I would imagine you'd want to make an observablecollection of a class type, and write code in there to update the DB if data is changed, or new data added, but that could be old school thought, there may be something better built in.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
I have the same feeling,there must be a better way of doing it. Thanks for your help though!
|
|
|
|
|
Any time you add an item into an observable collection, or remove an item, the collection raises a CollectionChanged event. You can use this to identify records that have been added or deleted. If you are updating a record though, the collection won't help you because it doesn't monitor changes to items in the collection; it only monitors changes to the collection itself.
What you need to do, in this case, is have your model expose INotifyPropertyChanged, and then (whenever a property is changed), raise a change notification on the item itself. This[^] article gives a bit more detail about notifications.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|