Skip to content

Commit

Permalink
Merge pull request #68 from d2phap/develop
Browse files Browse the repository at this point in the history
Develop v3.2.0.16
  • Loading branch information
d2phap committed Feb 5, 2016
2 parents 36d82ac + 64b91e7 commit 6654ea1
Show file tree
Hide file tree
Showing 84 changed files with 1,066 additions and 358 deletions.
3 changes: 3 additions & 0 deletions Source/Components/ImageGlass.Core/ImageGlass.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
<Reference Include="IconLib">
<HintPath>..\..\ImageGlass\bin\Debug\IconLib.dll</HintPath>
</Reference>
<Reference Include="Imazen.WebP">
<HintPath>..\..\ImageGlass\Imazen.WebP.dll</HintPath>
</Reference>
<Reference Include="Svg">
<HintPath>..\..\ImageGlass\Svg.dll</HintPath>
</Reference>
Expand Down
2 changes: 1 addition & 1 deletion Source/Components/ImageGlass.Core/Img.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Load()
Image im = null;
try
{
im = Interpreter.load(path);
im = Interpreter.Load(path);
}
catch (Exception ex)
{ }
Expand Down
58 changes: 46 additions & 12 deletions Source/Components/ImageGlass.Core/Interpreter.cs
Original file line number Diff line number Diff line change
@@ -1,56 +1,60 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Drawing.IconLib;
using Paloma;
using System.Drawing.Drawing2D;
using FreeImageAPI;
using Svg;
using Imazen.WebP;

namespace ImageGlass.Core
{
public class Interpreter
{
private const int TAG_ORIENTATION = 0x0112;

public static Bitmap load(string path)
public static Bitmap Load(string path)
{
path = path.ToLower();
Bitmap bmp = null;

//file *.hdr
if (path.ToLower().EndsWith(".hdr"))
if (path.EndsWith(".hdr"))
{
FIBITMAP hdr = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_HDR, path, FREE_IMAGE_LOAD_FLAGS.RAW_DISPLAY);
bmp = FreeImage.GetBitmap(FreeImage.ToneMapping(hdr, FREE_IMAGE_TMO.FITMO_DRAGO03, 2.2, 0));
FreeImage.Unload(hdr);
}
//file *.exr
else if (path.ToLower().EndsWith(".exr"))
else if (path.EndsWith(".exr"))
{
FIBITMAP exr = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_EXR, path, FREE_IMAGE_LOAD_FLAGS.RAW_DISPLAY);
bmp = FreeImage.GetBitmap(FreeImage.ToneMapping(exr, FREE_IMAGE_TMO.FITMO_DRAGO03, 2.2, 0));
FreeImage.Unload(exr);
}
//file *.svg
else if (path.ToLower().EndsWith(".svg"))
else if (path.EndsWith(".svg"))
{
SvgDocument svg = SvgDocument.Open(path);
bmp = svg.Draw();
}
//TARGA file *.tga
else if (path.ToLower().EndsWith(".tga"))
else if (path.EndsWith(".tga"))
{
using (Paloma.TargaImage tar = new Paloma.TargaImage(path))
{
bmp = new Bitmap(tar.Image);
}
}
//WEBP file *.webp
else if (path.EndsWith(".webp"))
{
bmp = ReadWebpFile(path);
}
//PHOTOSHOP file *.PSD
else if (path.ToLower().EndsWith(".psd"))
else if (path.EndsWith(".psd"))
{
System.Drawing.PSD.PsdFile psd = (new System.Drawing.PSD.PsdFile()).Load(path);
bmp = System.Drawing.PSD.ImageDecoder.DecodeImage(psd);
Expand Down Expand Up @@ -83,12 +87,15 @@ public static Bitmap load(string path)
}
}



return bmp;
}


/// <summary>
/// Read icon *.ICO file
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static Bitmap ReadIconFile(string path)
{
MultiIcon mIcon = new MultiIcon();
Expand Down Expand Up @@ -200,6 +207,33 @@ public static Bitmap ScaleDownRotateBitmap(Bitmap source, double scale, int angl
}


/// <summary>
/// Read non-animated WEBP format
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static Bitmap ReadWebpFile(string path)
{
var webpDecoder = new SimpleDecoder();

using (Stream inputStream = File.Open(path, FileMode.Open))
{
byte[] buffer = new byte[16 * 1024];
using (MemoryStream ms = new MemoryStream())
{
int read;
while ((read = inputStream.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}

var bytes = ms.ToArray();
Bitmap outBitmap = webpDecoder.DecodeFromBytes(bytes, bytes.LongLength);

return outBitmap;
}
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Duong Dieu Phap")]
[assembly: AssemblyProduct("ImageGlass.Core")]
[assembly: AssemblyCopyright("Copyright © 2014 - 2015 Duong Dieu Phap")]
[assembly: AssemblyCopyright("Copyright © 2014 - 2016 Duong Dieu Phap")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ImageGlass.ImageListView</RootNamespace>
<AssemblyName>ImageGlass.ImageListView</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
Expand All @@ -32,6 +32,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -76,6 +77,9 @@
<Reference Include="FreeImageNET">
<HintPath>..\..\ImageGlass\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="Imazen.WebP">
<HintPath>..\..\ImageGlass\Imazen.WebP.dll</HintPath>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
Expand Down Expand Up @@ -225,6 +229,12 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ImageGlass.Core\ImageGlass.Core.csproj">
<Project>{8540d406-e362-4ecc-9761-f978996354df}</Project>
<Name>ImageGlass.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ internal Point ViewOffset
/// </summary>
internal ScrollOrientation ScrollOrientation
{
get { return (mView == View.Gallery ? ScrollOrientation.HorizontalScroll : ScrollOrientation.VerticalScroll); }
get { return ((mView == View.Gallery) ? ScrollOrientation.HorizontalScroll : ScrollOrientation.VerticalScroll); }
}
#endregion

Expand Down
38 changes: 19 additions & 19 deletions Source/Components/ImageGlass.ImageListView/ImageListViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,32 +1547,32 @@ public virtual void DrawPane(Graphics g, ImageListViewItem item, Image image, Re
}
}
/// <summary>
/// Draws the large preview image of the focused item in Gallery mode.
/// [PHAP - Hide preview image] Draws the large preview image of the focused item in Gallery mode.
/// </summary>
/// <param name="g">The System.Drawing.Graphics to draw on.</param>
/// <param name="item">The ImageListViewItem to draw.</param>
/// <param name="image">The image to draw.</param>
/// <param name="bounds">The bounding rectangle of the preview area.</param>
public virtual void DrawGalleryImage(Graphics g, ImageListViewItem item, Image image, Rectangle bounds)
{
if (item != null && image != null)
{
// Calculate image bounds
Size itemMargin = MeasureItemMargin(ImageListView.View);
Rectangle pos = Utility.GetSizedImageBounds(image, new Rectangle(bounds.Location + itemMargin, bounds.Size - itemMargin - itemMargin));
// Draw image
g.DrawImage(image, pos);
// Draw image border
if (Math.Min(pos.Width, pos.Height) > 32)
{
using (Pen pOuterBorder = new Pen(ImageListView.Colors.ImageOuterBorderColor))
using (Pen pInnerBorder = new Pen(ImageListView.Colors.ImageInnerBorderColor))
{
g.DrawRectangle(pOuterBorder, pos);
g.DrawRectangle(pInnerBorder, Rectangle.Inflate(pos, -1, -1));
}
}
}
//if (item != null && image != null)
//{
// // Calculate image bounds
// Size itemMargin = MeasureItemMargin(ImageListView.View);
// Rectangle pos = Utility.GetSizedImageBounds(image, new Rectangle(bounds.Location + itemMargin, bounds.Size - itemMargin - itemMargin));
// // Draw image
// g.DrawImage(image, pos);
// // Draw image border
// if (Math.Min(pos.Width, pos.Height) > 32)
// {
// using (Pen pOuterBorder = new Pen(ImageListView.Colors.ImageOuterBorderColor))
// using (Pen pInnerBorder = new Pen(ImageListView.Colors.ImageInnerBorderColor))
// {
// g.DrawRectangle(pOuterBorder, pos);
// g.DrawRectangle(pInnerBorder, Rectangle.Inflate(pos, -1, -1));
// }
// }
//}
}
/// <summary>
/// Draws the extender after the last column.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ImageListView")]
[assembly: AssemblyCopyright("Copyright © 2009 Ozgur Ozcitak")]
[assembly: AssemblyCopyright("Copyright © 2009 Ozgur Ozcitak")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -49,5 +49,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("11.0.0.0")]
[assembly: AssemblyFileVersion("11.0.0.0")]
[assembly: AssemblyVersion("11.0.0.1")]
[assembly: AssemblyFileVersion("11.0.0.1")]
36 changes: 8 additions & 28 deletions Source/Components/ImageGlass.ImageListView/ThumbnailExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,43 +235,23 @@ internal static Image GetThumbnailBmp(string filename, Size size, UseEmbeddedThu

Image source = null;
Image thumb = null;

filename = filename.ToLower();

// Revert to source image if an embedded thumbnail of required size was not found.
FileStream sourceStream = null;

// Fix for the missing semicolon in GIF files
MemoryStream streamCopy = null;

//*.SVG
if (filename.ToLower().EndsWith(".svg"))
{
try
{
SvgDocument svg = SvgDocument.Open(filename);
source = svg.Draw();
}
catch { return null; }
}
//HDR
else if (filename.ToLower().EndsWith(".hdr"))
{
try
{
FIBITMAP hdr = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_HDR, filename, FREE_IMAGE_LOAD_FLAGS.RAW_PREVIEW);
source = FreeImage.GetBitmap(FreeImage.ToneMapping(hdr, FREE_IMAGE_TMO.FITMO_DRAGO03, 2.2, 0));
FreeImage.Unload(hdr);
}
catch { return null; }
}
//EXR
else if (filename.ToLower().EndsWith(".exr"))
// *.SVG, *.WEBP, *.HDR, *.EXR
if (filename.EndsWith(".svg") ||
filename.EndsWith(".webp") ||
filename.EndsWith(".hdr") ||
filename.EndsWith(".exr"))
{
try
{
FIBITMAP exr = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_EXR, filename, FREE_IMAGE_LOAD_FLAGS.RAW_PREVIEW);
source = FreeImage.GetBitmap(FreeImage.ToneMapping(exr, FREE_IMAGE_TMO.FITMO_DRAGO03, 2.2, 0));
FreeImage.Unload(exr);
source = ImageGlass.Core.Interpreter.Load(filename);
}
catch { return null; }
}
Expand All @@ -284,7 +264,7 @@ internal static Image GetThumbnailBmp(string filename, Size size, UseEmbeddedThu
using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
if (!Utility.IsImage(stream))
if (!filename.ToLower().EndsWith(".exr"))
if (!filename.EndsWith(".exr"))
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Components/ImageGlass.ImageListView/app.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup/></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
Loading

0 comments on commit 6654ea1

Please sign in to comment.