зеркало из https://github.com/mono/mail-archives.git
98 строки
3.4 KiB
HTML
98 строки
3.4 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [Mono-osx] Save jpg with compression.
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:mono-osx%40lists.ximian.com?Subject=Re%3A%20%5BMono-osx%5D%20Save%20jpg%20with%20compression.&In-Reply-To=%3C1351264223943-4657135.post%40n4.nabble.com%3E">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
<style type="text/css">
|
|
pre {
|
|
white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */
|
|
}
|
|
</style>
|
|
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
|
<LINK REL="Previous" HREF="005110.html">
|
|
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[Mono-osx] Save jpg with compression.</H1>
|
|
<B>GordyGordy</B>
|
|
<A HREF="mailto:mono-osx%40lists.ximian.com?Subject=Re%3A%20%5BMono-osx%5D%20Save%20jpg%20with%20compression.&In-Reply-To=%3C1351264223943-4657135.post%40n4.nabble.com%3E"
|
|
TITLE="[Mono-osx] Save jpg with compression.">gordontruslove at hotmail.com
|
|
</A><BR>
|
|
<I>Fri Oct 26 15:10:23 UTC 2012</I>
|
|
<P><UL>
|
|
<LI>Previous message: <A HREF="005110.html">[Mono-osx] MonoMac on OSX 10.5
|
|
</A></li>
|
|
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#5111">[ date ]</a>
|
|
<a href="thread.html#5111">[ thread ]</a>
|
|
<a href="subject.html#5111">[ subject ]</a>
|
|
<a href="author.html#5111">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE>This is my code for saving a jpg with compression. It's pretty simple, just
|
|
set the NSImageCompressionFactor apparently.
|
|
|
|
public void SaveImage(NSImage MyNSImage,string Location, float Quality)
|
|
{
|
|
NSBitmapImageRep BRep=(NSBitmapImageRep)MyNSIMage.Representations[0];
|
|
NSDictionary Dic= NSDictionary.FromObjectAndKey(new
|
|
NSNumber(Quality),new NSString("NSImageCompressionFactor"));
|
|
NSData
|
|
D=BRep.RepresentationUsingTypeProperties(NSBitmapImageFileType.Jpeg,Dic);
|
|
System.IO.Stream S=D.AsStream();
|
|
SaveStream(Location,S);
|
|
S.Dispose();
|
|
D.Dispose();
|
|
}
|
|
|
|
void SaveStream(string FileName, Stream Source)
|
|
{
|
|
|
|
FileStream FS=File.OpenWrite(FileName);
|
|
int Read=0;
|
|
byte[] Buffer=new byte[1024];
|
|
Source.Seek(0, SeekOrigin.Begin);
|
|
do{
|
|
Read = Source.Read(Buffer, 0, 1024);
|
|
FS.Write(Buffer, 0, Read);
|
|
}while(Read>0);
|
|
|
|
FS.Close();
|
|
}
|
|
|
|
It always saves as 100% though, what am I doing wrong? Hope some clever
|
|
person knows the answer.
|
|
|
|
|
|
|
|
--
|
|
View this message in context: <A HREF="http://mono.1490590.n4.nabble.com/Save-jpg-with-compression-tp4657135.html">http://mono.1490590.n4.nabble.com/Save-jpg-with-compression-tp4657135.html</A>
|
|
Sent from the Mono - OSX mailing list archive at Nabble.com.
|
|
</PRE>
|
|
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
<LI>Previous message: <A HREF="005110.html">[Mono-osx] MonoMac on OSX 10.5
|
|
</A></li>
|
|
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#5111">[ date ]</a>
|
|
<a href="thread.html#5111">[ thread ]</a>
|
|
<a href="subject.html#5111">[ subject ]</a>
|
|
<a href="author.html#5111">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
|
|
<hr>
|
|
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx">More information about the Mono-osx
|
|
mailing list</a><br>
|
|
</body></html>
|