mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-13 03:31:22 +00:00
Enabled Jpeg support.
This commit is contained in:
parent
2b63ba4859
commit
595ccd8865
6 changed files with 56 additions and 0 deletions
|
|
@ -984,5 +984,33 @@ namespace Orvid.Graphics
|
|||
{
|
||||
Parent.DrawImage(new Vec2(base.X, base.Y), this);
|
||||
}
|
||||
|
||||
#region Operators
|
||||
public static explicit operator System.Drawing.Bitmap(Image i)
|
||||
{
|
||||
System.Drawing.Bitmap b = new System.Drawing.Bitmap(i.Width, i.Height);
|
||||
for (uint x = 0; x < i.Width; x++)
|
||||
{
|
||||
for (uint y = 0; y < i.Height; y++)
|
||||
{
|
||||
b.SetPixel((int)x, (int)y, i.GetPixel(x, y));
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static explicit operator Image(System.Drawing.Bitmap b)
|
||||
{
|
||||
Image i = new Image(b.Width, b.Height);
|
||||
for (uint x = 0; x < b.Width; x++)
|
||||
{
|
||||
for (uint y = 0; y < b.Height; y++)
|
||||
{
|
||||
i.SetPixel(x, y, b.GetPixel((int)x, (int)y));
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ namespace Orvid.Graphics.ImageFormats
|
|||
public FormatManager()
|
||||
{
|
||||
Formats.Add(new OIFImage());
|
||||
//Formats.Add(new PngImage());
|
||||
Formats.Add(new VbpImage());
|
||||
Formats.Add(new JpgImage());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using BitMiracle.LibJpeg;
|
||||
|
||||
namespace Orvid.Graphics.ImageFormats
|
||||
{
|
||||
public class JpgImage : ImageFormat
|
||||
{
|
||||
public override void Save(Image i, Stream dest)
|
||||
{
|
||||
JpegImage j = JpegImage.FromBitmap((System.Drawing.Bitmap)i);
|
||||
j.WriteJpeg(dest);
|
||||
}
|
||||
|
||||
public override Image Load(Stream s)
|
||||
{
|
||||
JpegImage j = new JpegImage(s);
|
||||
return (Image)j.ToBitmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -54,8 +54,11 @@
|
|||
<Compile Include="Image.cs" />
|
||||
<Compile Include="ImageFormats\FormatManager.cs" />
|
||||
<Compile Include="ImageFormats\ImageFormat.cs" />
|
||||
<Compile Include="ImageFormats\JpegSupport.cs" />
|
||||
<Compile Include="ImageFormats\Jpeg Support\LibJpeg.cs" />
|
||||
<Compile Include="ImageFormats\OifSupport.cs" />
|
||||
<Compile Include="ImageFormats\VbpSupport.cs" />
|
||||
<Compile Include="ImageFormats\Jpeg Support\zLib.cs" />
|
||||
<Compile Include="ImageManipulator.cs" />
|
||||
<Compile Include="Monitor.cs" />
|
||||
<Compile Include="OForms\OControl.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue