|
try adding
g.InterpolationMode = InterpolationMaode.HighQualityBicubic;
|
|
|
|
|
Hi
You can use a quality parameter when saving as a jpeg:
...
int quality = 90;
EncoderParameters parameters = new EncoderParameters( 1 );
parameters.Param[ 0 ] = new EncoderParameter( Encoder.Quality, quality );
ImageCodecInfo codec = GetImageCodecInfo( ImageFormat.Jpeg );
canvas.Save("C:\\Inetpub\\wwwroot\\1.jpg", codec, parameters );
...
public static ImageCodecInfo GetImageCodecInfo( ImageFormat format )
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
foreach ( ImageCodecInfo codec in codecs )
if ( codec.FormatID == format.Guid )
return codec;
return null;
}
----------------------------
Be excellent to each other
EasiReports[^] My free reporting component for WinForms.
|
|
|
|
|
<br />
<br />
public static ImageCodecInfo GetImageCodecInfo(ImageFormat format)<br />
{<br />
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();<br />
foreach(ImageCodecInfo codec in codecs)<br />
{<br />
if(codec.FormatID == format.Guid)<br />
{<br />
return codec;<br />
return null;<br />
}<br />
}<br />
}<br />
<br />
void makeThumbnail()<br />
{<br />
System.Drawing.Image image = System.Drawing.Image.FromFile("C:\\Inetpub\\wwwroot\\heli.jpg");<br />
Bitmap canvas = new Bitmap(200, 283, image.PixelFormat);<br />
<br />
Graphics g = Graphics.FromImage(canvas);<br />
<br />
g.DrawImage(image, 0, 0, 200, 283);<br />
<br />
int quality = 90;<br />
EncoderParameters parameters = new EncoderParameters(1);<br />
parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);<br />
<br />
ImageCodecInfo codec = GetImageCodecInfo(ImageFormat.Jpeg);<br />
canvas.Save("C:\\Inetpub\\wwwroot\\1.jpg", codec, parameters);<br />
<br />
image.Dispose();<br />
canvas.Dispose();<br />
}<br />
<br />
Gives the following error:
Compiler Error Message: CS0161: 'ASP.image_aspx.GetImageCodecInfo(System.Drawing.Imaging.ImageFormat)': not all code paths return a value
On line:
<br />
public static ImageCodecInfo GetImageCodecInfo(ImageFormat format)<br />
-- modified at 10:29 Saturday 18th March, 2006
|
|
|
|
|
Watch your brackets
----------------------------
Be excellent to each other
EasiReports[^] My free reporting component for WinForms.
|
|
|
|
|
|
You can try setting the quality to 100%.
If that still is not good enough, then you could try saving in a loseless format such as png ( then you don't need the quality parameter ).
----------------------------
Be excellent to each other
EasiReports[^] My free reporting component for WinForms.
|
|
|
|
|
Not a bad idea actually ..
Cheers
|
|
|
|
|
Actually that doesn't solve a thing. It still makes it crappy quality. It's not the loss that's the problem, it's the antialiasing .. it doesn't do it when I resize the image.
Still get the same result. :-/
|
|
|
|
|
Have you tried using Image.GetThumbnailImage ?
I'm running out of ideas here
----------------------------
Be excellent to each other
EasiReports[^] My free reporting component for WinForms.
|
|
|
|
|
I don't know how to use it but I'll figure it out!
Thank you for the input. I'll get back on the thread when I've got the time to investigate it more =)
|
|
|
|
|
Have a look at this[^] article.
|
|
|
|
|
I have a .NET C# application that connects to databases and creates tables and such and works on MSSqlServer and an Oracle Server I've tested it on and now I would like to get it sorking on DB2 as well. I've noticed there aren't the same components for DB2 as there are for Oracle and Sql so I did some research and it seems the only good looking components come from IBM and/or cost $. I've tried using the code already in place with an OleDbConnection and Command and it works for creating the tables but I haven't gotten it to insert without throwing an error. I think the error is has to do with the parameter field of the command. I have tried it with @ before the column names as with SQL and : as with Oracle, but neither solution works. If anyone has any experience with similar problems I would appreciate any help.
|
|
|
|
|
IIRC OleDbCommand does not support named parameters. Use a ? character as a parameter placeholder, and add OleDbParameter s to the Parameters collection in the order that they appear in the query text.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I've tried this solution, and I think it makes sense for select statements, but for inserts the syntax doesn't look right and it doesn't work.
Ex:
Insert into table(col1, col2, col3), (?, ?, ?)
parameters:
@col1, value, type
@col2, value, type
@col3, value, type
I have tried this with @before the column names, :before them and nothing but the column names.
These statments have worked for me (with the column names instead of ?'s) in SQL and Oracle, so I have a hard time believing it can't be done in Db2.
|
|
|
|
|
It seems that if I use dataview in my app, and a change is made to the dataset, and I call Update(ds). It does not update the datasource.
Here is my code in the form_load section:
<br />
sqlDataAdapter1.Fill(dataSet11);<br />
<br />
SqlCommandBuilder cb = new SqlCommandBuilder(sqlDataAdapter1);<br />
<br />
dt = dataSet11.Tables[0];<br />
dataView1.Table = dt;<br />
<br />
cm = (CurrencyManager)this.BindingContext[dataView1];<br />
<br />
cm.CurrentChanged += new System.EventHandler(OnCurrentChanged);<br />
lblRecord.Text = "Record " + (cm.Position + 1) + " of " + cm.Count;<br />
and the code in my save record section:
<br />
if (dataSet11.HasChanges())<br />
{<br />
cm.EndCurrentEdit();<br />
<br />
sqlDataAdapter1.Update(dataSet11);<br />
}<br />
<br />
I'm not sure why it does not update. If I remove the dataview then it updates the datasource. Suggestions?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
What do you mean "it does not update the datasource"? Have you inspected the DataSet with the debugger to see if the data has truly been changed and therefore needs to sync against the source? A common problem I see is that someone mishandles validation, transfer, etc where they think the input changed the data but in actuality it ignored or threw it out. If dataSet11 never changed, as far as the system is concerned there is nothing to update.
|
|
|
|
|
See the code that says..."if (dataSet11.HasChanges())" I would think that it would not drop into this "IF" statement if nothing had changed.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Okay Time to eat crow.....I stepped thru the code and the dataset is not refelcting the changed made. If I just assume that there are changes it updates the datasource just fine. So now the question is why doesn't the dataset see the changes?
Tom
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
i am trying to load user control and aspx pages from different namespace (project), in my namespace Template i have my user control and aspx files, and i am trying to load those files from namespace Test1.
Thanks
|
|
|
|
|
using Template;
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i try that, but i could only read the class in that namespace but not user control, when i try to load the user control from 2nd namespace i the get error saying file not found. i have those two projects in different folder. when i try to load the user control it looks in my Test1 folder not in Template.
Thanks for you help
|
|
|
|
|
Hi.
I have a band object on my taskbar. it works fine, but the problem is that when I restart, it kinds of resets the startbar, I loose all the taskbars (including the quicklaunch), and I have to re-open them every time.
I imagine there is something that is forcing windows to reset the taskbar, but can't figure where to start looking.
tahnks
|
|
|
|
|
Is this a C# related question?
Ed
|
|
|
|
|
well, the program was done in c#. I'm asuming the bug is c# related. I'm not sure, well, because I don't know what's causing it. If someone thinks the problem lies elswere, please let me know.
|
|
|
|
|
I have a program which creates multiple threads. Each thread sends a WebService request.
What I am finding using sniffer is that even if I have 10 threads sending request, all requests are sent from one or two ports. I would like to have each thread use different port to send the WebService request.
Is there any ways to accomplish this?
Thank you for help.
|
|
|
|