This commit is contained in:
2021-06-13 10:28:03 +02:00
parent eb70603c85
commit df2d24cbd3
7487 changed files with 943244 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Photoshop PSD FileType Plugin for Paint.NET
// http://psdplugin.codeplex.com/
//
// This software is provided under the MIT License:
// Copyright (c) 2006-2007 Frank Blumenberg
// Copyright (c) 2010-2013 Tao Yue
//
// See LICENSE.txt for complete licensing and attribution information.
//
/////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
namespace PhotoshopFile
{
/// <summary>
/// The names of the alpha channels
/// </summary>
internal class AlphaChannelNames : ImageResource
{
public override ResourceID ID
{
get { return ResourceID.AlphaChannelNames; }
}
private List<string> channelNames = new List<string>();
public List<string> ChannelNames
{
get { return channelNames; }
}
public AlphaChannelNames() : base(String.Empty)
{
}
public AlphaChannelNames(PsdBinaryReader reader, string name, int resourceDataLength)
: base(name)
{
var endPosition = reader.BaseStream.Position + resourceDataLength;
// Alpha channel names are Pascal strings, with no padding in-between.
while (reader.BaseStream.Position < endPosition)
{
var channelName = reader.ReadPascalString(1);
ChannelNames.Add(channelName);
}
}
}
}

View File

@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Photoshop PSD FileType Plugin for Paint.NET
// http://psdplugin.codeplex.com/
//
// This software is provided under the MIT License:
// Copyright (c) 2006-2007 Frank Blumenberg
// Copyright (c) 2010-2013 Tao Yue
//
// See LICENSE.txt for complete licensing and attribution information.
//
/////////////////////////////////////////////////////////////////////////////////
using System;
using System.IO;
using PDNWrapper;
namespace PhotoshopFile
{
/// <summary>
/// Stores the raw data for unimplemented image resource types.
/// </summary>
internal class RawImageResource : ImageResource
{
public byte[] Data { get; private set; }
private ResourceID id;
public override ResourceID ID
{
get { return id; }
}
public RawImageResource(ResourceID resourceId, string name)
: base(name)
{
this.id = resourceId;
}
public RawImageResource(PsdBinaryReader reader, string signature,
ResourceID resourceId, string name, int numBytes)
: base(name)
{
this.Signature = signature;
this.id = resourceId;
Data = reader.ReadBytes(numBytes);
}
}
}

View File

@@ -0,0 +1,94 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Photoshop PSD FileType Plugin for Paint.NET
// http://psdplugin.codeplex.com/
//
// This software is provided under the MIT License:
// Copyright (c) 2006-2007 Frank Blumenberg
// Copyright (c) 2010-2012 Tao Yue
//
// Portions of this file are provided under the BSD 3-clause License:
// Copyright (c) 2006, Jonas Beckeman
//
// See LICENSE.txt for complete licensing and attribution information.
//
/////////////////////////////////////////////////////////////////////////////////
using System;
namespace PhotoshopFile
{
/// <summary>
/// Summary description for ResolutionInfo.
/// </summary>
internal class ResolutionInfo : ImageResource
{
public override ResourceID ID
{
get { return ResourceID.ResolutionInfo; }
}
/// <summary>
/// Horizontal DPI.
/// </summary>
public UFixed16_16 HDpi { get; set; }
/// <summary>
/// Vertical DPI.
/// </summary>
public UFixed16_16 VDpi { get; set; }
/// <summary>
/// 1 = pixels per inch, 2 = pixels per centimeter
/// </summary>
internal enum ResUnit
{
PxPerInch = 1,
PxPerCm = 2
}
/// <summary>
/// Display units for horizontal resolution. This only affects the
/// user interface; the resolution is still stored in the PSD file
/// as pixels/inch.
/// </summary>
public ResUnit HResDisplayUnit { get; set; }
/// <summary>
/// Display units for vertical resolution.
/// </summary>
public ResUnit VResDisplayUnit { get; set; }
/// <summary>
/// Physical units.
/// </summary>
internal enum Unit
{
Inches = 1,
Centimeters = 2,
Points = 3,
Picas = 4,
Columns = 5
}
public Unit WidthDisplayUnit { get; set; }
public Unit HeightDisplayUnit { get; set; }
public ResolutionInfo() : base(String.Empty)
{
}
public ResolutionInfo(PsdBinaryReader reader, string name)
: base(name)
{
this.HDpi = new UFixed16_16(reader.ReadUInt32());
this.HResDisplayUnit = (ResUnit)reader.ReadInt16();
this.WidthDisplayUnit = (Unit)reader.ReadInt16();
this.VDpi = new UFixed16_16(reader.ReadUInt32());
this.VResDisplayUnit = (ResUnit)reader.ReadInt16();
this.HeightDisplayUnit = (Unit)reader.ReadInt16();
}
}
}

View File

@@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Photoshop PSD FileType Plugin for Paint.NET
// http://psdplugin.codeplex.com/
//
// This software is provided under the MIT License:
// Copyright (c) 2006-2007 Frank Blumenberg
// Copyright (c) 2010-2013 Tao Yue
//
// Portions of this file are provided under the BSD 3-clause License:
// Copyright (c) 2006, Jonas Beckeman
//
// See LICENSE.txt for complete licensing and attribution information.
//
/////////////////////////////////////////////////////////////////////////////////
using System;
using System.IO;
using System.Diagnostics;
using PDNWrapper;
//using PDNWrapper.Imaging;
namespace PhotoshopFile
{
/// <summary>
/// Summary description for Thumbnail.
/// </summary>
internal class Thumbnail : RawImageResource
{
public Thumbnail(ResourceID id, string name)
: base(id, name)
{
}
public Thumbnail(PsdBinaryReader psdReader, ResourceID id, string name, int numBytes)
: base(psdReader, "8BIM", id, name, numBytes)
{
using (var memoryStream = new MemoryStream(Data))
using (var reader = new PsdBinaryReader(memoryStream, psdReader))
{
const int HEADER_LENGTH = 28;
var format = reader.ReadUInt32();
//var width = reader.ReadUInt32();
//var height = reader.ReadUInt32();
//var widthBytes = reader.ReadUInt32();
//var size = reader.ReadUInt32();
//var compressedSize = reader.ReadUInt32();
//var bitPerPixel = reader.ReadUInt16();
//var planes = reader.ReadUInt16();
// Raw RGB bitmap
if (format == 0)
{
//Image = new Bitmap((int)width, (int)height, PixelFormat.Format24bppRgb);
}
// JPEG bitmap
else if (format == 1)
{
byte[] imgData = reader.ReadBytes(numBytes - HEADER_LENGTH);
using (MemoryStream stream = new MemoryStream(imgData))
{
//var bitmap = new Bitmap(stream);
//Image = (Bitmap)bitmap.Clone();
}
// Reverse BGR pixels from old thumbnail format
if (id == ResourceID.ThumbnailBgr)
{
//for(int y=0;y<m_thumbnailImage.Height;y++)
// for (int x = 0; x < m_thumbnailImage.Width; x++)
// {
// Color c=m_thumbnailImage.GetPixel(x,y);
// Color c2=Color.FromArgb(c.B, c.G, c.R);
// m_thumbnailImage.SetPixel(x, y, c);
// }
}
}
else
{
throw new PsdInvalidException("Unknown thumbnail format.");
}
}
}
}
}

View File

@@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Photoshop PSD FileType Plugin for Paint.NET
// http://psdplugin.codeplex.com/
//
// This software is provided under the MIT License:
// Copyright (c) 2006-2007 Frank Blumenberg
// Copyright (c) 2010-2014 Tao Yue
//
// See LICENSE.txt for complete licensing and attribution information.
//
/////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
namespace PhotoshopFile
{
/// <summary>
/// The names of the alpha channels.
/// </summary>
internal class UnicodeAlphaNames : ImageResource
{
public override ResourceID ID
{
get { return ResourceID.UnicodeAlphaNames; }
}
private List<string> channelNames = new List<string>();
public List<string> ChannelNames
{
get { return channelNames; }
}
public UnicodeAlphaNames()
: base(String.Empty)
{
}
public UnicodeAlphaNames(PsdBinaryReader reader, string name, int resourceDataLength)
: base(name)
{
var endPosition = reader.BaseStream.Position + resourceDataLength;
while (reader.BaseStream.Position < endPosition)
{
var channelName = reader.ReadUnicodeString();
// Photoshop writes out a null terminator for Unicode alpha names.
// There is no null terminator on other Unicode strings in PSD files.
if (channelName.EndsWith("\0"))
{
channelName = channelName.Substring(0, channelName.Length - 1);
}
ChannelNames.Add(channelName);
}
}
}
}

View File

@@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Photoshop PSD FileType Plugin for Paint.NET
// http://psdplugin.codeplex.com/
//
// This software is provided under the MIT License:
// Copyright (c) 2006-2007 Frank Blumenberg
// Copyright (c) 2010-2012 Tao Yue
//
// See LICENSE.txt for complete licensing and attribution information.
//
/////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PhotoshopFile
{
internal class VersionInfo : ImageResource
{
public override ResourceID ID
{
get { return ResourceID.VersionInfo; }
}
public UInt32 Version { get; set; }
public bool HasRealMergedData { get; set; }
public string ReaderName { get; set; }
public string WriterName { get; set; }
public UInt32 FileVersion { get; set; }
public VersionInfo() : base(String.Empty)
{
}
public VersionInfo(PsdBinaryReader reader, string name)
: base(name)
{
Version = reader.ReadUInt32();
HasRealMergedData = reader.ReadBoolean();
ReaderName = reader.ReadUnicodeString();
WriterName = reader.ReadUnicodeString();
FileVersion = reader.ReadUInt32();
}
}
}