|
<br />
System.Drawing.Imaging.EncoderParameters encParams = new System.Drawing.Imaging.EncoderParameters();<br />
encParams.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, Quality);<br />
MemoryStream ms = new MemoryStream();<br />
_reformattedImage.Save(ms, System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()[1], encParams);<br />
_reformattedImage = Image.FromStream(ms);
That's raw code straight out of an app i've got infront of me it's got the quality methods you'll need though. Quality is the parameter from 1 to 100 that sets the quality level
Things like Bitmap should have load and save methods on them (you can load jpegs into bitmap objects).
HTH
Russ
|
|
|
|
|
Thanks Russell. For completeness my final solution was:
private ImageCodecInfo GetEncoderInfo(String mimeType)<br />
{<br />
int j;<br />
ImageCodecInfo[] encoders;<br />
encoders = ImageCodecInfo.GetImageEncoders();<br />
for(j = 0; j < encoders.Length; ++j)<br />
{<br />
if(encoders[j].MimeType == mimeType)<br />
return encoders[j];<br />
} <br />
return null;<br />
}<br />
<br />
Image image = Image.FromFile(sourceFile);<br />
<br />
string mimeType = "image/jpeg";<br />
ImageCodecInfo codecInfo = GetEncoderInfo(mimeType);<br />
if (codecInfo == null)<br />
raise error;<br />
<br />
Encoder qualityEncoder = Encoder.Quality;<br />
EncoderParameter ratio = new EncoderParameter(qualityEncoder, 40L);<br />
EncoderParameters encoderParams = new EncoderParameters(1);<br />
encoderParams.Param[0] = ratio;<br />
<br />
image.Save(destFile, codecInfo, encoderParams);<br />
image.Dispose();<br />
|
|
|
|
|
I am working on a project in c# windows forms. The app requires to read xml file which contains the information about control to draw on the form.
below Sample xml file information:
<control type="Label" id="label1" width="23" height="23" xPos="117" yPos="100" />
<control type="TextBox" id="textBox1" multiline="false" width="143" height="23" xPos="117" yPos="50" />
<control type="Button" id="button1" width="23" height="23" xPos="100" yPos="100" />
The scenario is if I add a new control to the xml file and re-run the windows application it should be able to draw the new control with other controls in the xmlfile on the windows form.
Please help
MSx86
|
|
|
|
|
Use reflection. type tells you what control to instantiate. the remainder of the attributes tell you what properties to set. Then all you do is add the control to the Controls collection on the form.
|
|
|
|
|
Thanks a million.
Can you give me a sample? I am new to it. I didn't understand what you mean.
|
|
|
|
|
Looks like you are reinventing the wheel a bit here. Take a look at what Marc Clifton[^]has done with MyXaml[^] and MicroXaml.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Good point but I cannot use XAML. I just need to populate some basic controls.
|
|
|
|
|
A couple of points. The first part is that Marcs implementation isn't XAML - it's his own version. Point 2 - Marc has solved the problems that you are trying to solve, so learn from him. He's one of the best on CP, and if you think you want to do something then chances are, Marc's already done it.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thank you, I will take a look at it. Any particulator article you can point me on his website.
|
|
|
|
|
Try this: http://www.marcclifton.com/tabid/67/Default.aspx[^]
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi, I want to clip a specific portion of the bitmap, and want to display that clip at certain point on the form. Can any one help me? I am looking for a c#.net solution.
Thank you
|
|
|
|
|
Save the image in a buffer and then selecting the particular part using scan and bmdata u can make a region of the required portion then paint that region on the form...... Im doing the same type of thing just a rough idea abt it..... Im also searching out abt it........ Update it if u get the problem solve
BEST OF LUCK
|
|
|
|
|
Hi, Did try Clipping in c#.net library as
Graphics g= CreateGraphics();
Rectangle clip_rect=new Rectangle(0,0,100,100);
g.Clip=new Region(clip_rect);
it can work?
|
|
|
|
|
No I dont think soo!!!!! It can only clip the image to be drawn in a particular rectangle but u cant select a particular portion in the image for doin soo u have to select pixels frm the image...using Bitmapdata and locking the bitmap.......Ya do read christian Gauss image processing articles U ll get to know lot abt image processing.... BEST OF LUCK
|
|
|
|
|
i am using csharp and i am calling a dll that was written in vb 6 and one of its methods i call has a optional parameter how do i call this function without a parameter without throwing a compiler error
Thanks,
Chad Aiena
|
|
|
|
|
I've never tried this so I'm only really guessing here, but have you tried passing in null?
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
yes and it did not work
Thanks,
Chad Aiena
|
|
|
|
|
VC# if I am correct does not support optional parameters. Have you tried creating an empty object of the type the parameter is set to be. Or you could possibly import Microsoft.VisualBasic namespace and use the vbNull constant and use that.
What is the compiler error?
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi,
I havent done this (I am not actively using VB) but I guess you cannot really do it,
unless you cheat a little by inserting a code layer in C# that offers you two methods
(one with, one without the optional out parameter), and have them both call the VB code
WITH the out parameter present (one real, one dummy).
Luc Pattyn
|
|
|
|
|
Just pass "System.Reflection.Missing.Value" for the optional parameter.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: C# to Python converter, VB to Python converter
|
|
|
|
|
if String is a class in .net then we donot use new operator with it.
as String objString=new String();
we almost did like this string newString="";
can anybody explain...
thanks
vishal
Thanks & Regards
Vishal Sharma
vishalsharma556@yahoo.co.in
|
|
|
|
|
VishalSharmaDev wrote: if String is a class in .net then we donot use new operator with it.
You can use the new operator with it. It has 8 overloads.
VishalSharmaDev wrote: as String objString=new String();
Not all classes have a default constructor (i.e. A constructor with no parameters)
VishalSharmaDev wrote: we almost did like this string newString="";
"this is a string literal" and that is how you represent string literals in C#. Just as 123 is how you represent an interger literal or true a Boolean literal and so on.
|
|
|
|
|
Hi,
strings are objects, just like Forms, Panels, Timers, etc.
Yes, you can create instances of them with new.
For ease of use, the compiler adds some goodies, such as (not complete!):
- you can create a new string by quoting some text, hence string s="hello"; is
a shorthand for sting s=new string(helloChars); where helloChars would be a char array
containing the right characters.
- you can use a string and a set of string constants as a switch variable and its case values
(does not work for objects in general, switch requires some integer or a string)
- you get improved performance when using string expressions (e.g. "aha"+"yep"+"waw"
will get highly optimized).
- and probably many more.
Luc Pattyn
|
|
|
|
|
hi all,
I have an application which has a groupbox contained in a window. I want to resize the groupbox when the window is resized.
When i anchor the groupbox to the bottom of the window, it shrinks to almost half its size while blank space is displayed corresponding to its actual size.
Any solutions to this problem?
|
|
|
|
|
Can i make the entire line got highlighted when go to that line .
e g:
if u click the error line in log window as it is highlighting the entire line .
Thank You
|
|
|
|