Preliminary support for PSD data format, untested and far from complete

This commit is contained in:
Michael Becker 2019-09-17 01:43:27 -04:00
parent f4e14c04e5
commit eb8607f3ed
16 changed files with 1413 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Adobe Photoshop document">
<FileNameFilters>
<FileNameFilter>*.psd</FileNameFilter>
</FileNameFilters>
<MagicByteSequences>
<MagicByteSequence>
<MagicByte Type="String">8BPS</MagicByte>
</MagicByteSequence>
</MagicByteSequences>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia.Picture.PictureObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop.PSDDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -640,6 +640,7 @@
<Content Include="Extensions\FileSystem\Associations\NewWorldComputing\AGG.uexml" />
<Content Include="Extensions\FileSystem\Associations\Apogee\DLT.uexml" />
<Content Include="Extensions\GraphicDesigner\Associations\Picture\PCX.uexml" />
<Content Include="Extensions\GraphicDesigner\Associations\Picture\PSD.uexml" />
</ItemGroup>
<ItemGroup>
<Content Include="Configuration\Application.upl" />

View File

@ -0,0 +1,35 @@
//
// PSDHeader.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop.Internal
{
internal struct PSDHeader
{
public string signature;
public short version;
public byte[] reserved;
public short channelCount;
public int imageHeight;
public int imageWidth;
public short bitDepth;
public PSDColorMode colorMode;
}
}

View File

@ -0,0 +1,37 @@
//
// PSDImageResourceBlock.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop.Internal
{
/// <summary>
/// Image resource blocks are the basic building unit of several file formats, including Photoshop's native file format, JPEG, and TIFF. Image resources are used to store non-pixel data associated with images, such as pen tool paths. They are referred to as resource blocks because they hold data that was stored in the Macintosh's resource fork in early versions of Photoshop.
/// </summary>
public struct PSDImageResourceBlock
{
public string signature; // Signature: '8BIM'
public short id; // Unique identifier for the resource.Image resource IDs contains a list of resource IDs used by Photoshop.
public string name; // Name: Pascal string, padded to make the size even (a null name consists of two bytes of 0)
public int datalength; // Actual size of resource data that follows
public byte[] data; // The resource data, described in the sections on the individual resource types.It is padded to make the size even.
public PSDKnownImageResourceBlockId KnownId { get { return (PSDKnownImageResourceBlockId)id; } set { id = (short)value; } }
}
}

View File

@ -0,0 +1,414 @@
//
// PSDKnownImageResourceBlockId.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop.Internal
{
public enum PSDKnownImageResourceBlockId : short
{
/// <summary>
/// (Obsolete--Photoshop 2.0 only ) Contains five 2-byte values: number of channels, rows, columns, depth, and mode
/// </summary>
PSD2ImageHeader = 1000,
/// <summary>
/// Macintosh print manager print info record
/// </summary>
MacintoshPrintManagerInfoRecord = 1001,
/// <summary>
/// Macintosh page format information. No longer read by Photoshop. (Obsolete)
/// </summary>
MacintoshPageFormat = 1002,
/// <summary>
/// (Obsolete--Photoshop 2.0 only ) Indexed color table
/// </summary>
IndexedColorTable = 1003,
/// <summary>
/// ResolutionInfo structure. See Appendix A in Photoshop API Guide.pdf.
/// </summary>
ResolutionInfo = 1005,
/// <summary>
/// Names of the alpha channels as a series of Pascal strings.
/// </summary>
AlphaChannelNames = 1006,
/// <summary>
/// (Obsolete) See ID 1077. DisplayInfo structure. See Appendix A in Photoshop API Guide.pdf.
/// </summary>
[Obsolete("see 1077: DisplayInfoCS3")]
DisplayInfo = 1007,
/// <summary>
/// The caption as a Pascal string.
/// </summary>
Caption = 1008,
/// <summary>
/// Border information. Contains a fixed number (2 bytes real, 2 bytes fraction) for the border width, and 2 bytes for border units (1 = inches, 2 = cm, 3 = points, 4 = picas, 5 = columns).
/// </summary>
BorderInformation = 1009,
/// <summary>
/// Background color. See See Color structure.
/// </summary>
BackgroundColor = 1010,
/// <summary>
/// A series of one-byte boolean values (see Page Setup dialog): labels, crop marks, color bars, registration marks, negative, flip, interpolate, caption, print flags.
/// </summary>
PrintFlags = 1011,
/// <summary>
/// Grayscale and multichannel halftoning information
/// </summary>
GrayscaleHalftoning = 1012,
/// <summary>
/// Color halftoning information
/// </summary>
ColorHalftoning = 1013,
/// <summary>
/// Duotone halftoning information
/// </summary>
DuotoneHalftoning = 1014,
/// <summary>
/// Grayscale and multichannel transfer function
/// </summary>
GrayscaleTransferFunction = 1015,
/// <summary>
/// Color transfer functions
/// </summary>
ColorTransferFunction = 1016,
/// <summary>
/// Duotone transfer functions
/// </summary>
DuotoneTransferFunction = 1017,
/// <summary>
/// Duotone image information
/// </summary>
DuotoneImageInformation = 1018,
/// <summary>
/// Two bytes for the effective black and white values for the dot range
/// </summary>
EffectiveMonochromeDotRange = 1019,
/// <summary>
/// (Obsolete)
/// </summary>
Obsolete1020 = 1020,
/// <summary>
/// EPS options
/// </summary>
EPSOptions = 1021,
/// <summary>
/// 2 bytes containing Quick Mask channel ID; 1- byte boolean indicating whether the mask was initially empty.
/// </summary>
QuickMask = 1022,
/// <summary>
/// (Obsolete)
/// </summary>
Obsolete1023 = 1023,
/// <summary>
/// Layer state information. 2 bytes containing the index of target layer (0 = bottom layer).
/// </summary>
LayerState = 1024,
/// <summary>
/// Working path (not saved). See See Path resource format.
/// </summary>
WorkingPath = 1025,
/// <summary>
/// 2 bytes per layer containing a group ID for the dragging groups. Layers in a group have the same group ID.
/// </summary>
LayersGroup = 1026,
/// <summary>
/// (Obsolete)
/// </summary>
Obsolete1027 = 1027,
/// <summary>
/// IPTC-NAA record. Contains the File Info... information. See the documentation in the IPTC folder of the Documentation folder.
/// </summary>
IptcNaa = 1028,
/// <summary>
/// Image mode for raw format files
/// </summary>
ImageMode = 1029,
/// <summary>
/// JPEG quality. Private.
/// </summary>
JPEGQuality = 1030,
/// <summary>
/// (Photoshop 4.0) Grid and guides information. See See Grid and guides resource format.
/// </summary>
PSD4GridGuidesInformation = 1032,
/// <summary>
/// (Photoshop 4.0) Thumbnail resource for Photoshop 4.0 only. See See Thumbnail resource format.
/// </summary>
PSD4ThumbnailResource = 1033,
/// <summary>
/// Copyright flag. Boolean indicating whether image is copyrighted. Can be set via Property suite or by user in File Info...
/// </summary>
PSD4CopyrightFlag = 1034,
/// <summary>
/// (Photoshop 4.0) URL. Handle of a text string with uniform resource locator. Can be set via Property suite or by user in File Info...
/// </summary>
PSD4URL = 1035,
/// <summary>
/// (Photoshop 5.0) Thumbnail resource (supersedes resource 1033). See See Thumbnail resource format.
/// </summary>
PSD5ThumbnailResource = 1036,
/// <summary>
/// (Photoshop 5.0) Global Angle. 4 bytes that contain an integer between 0 and 359, which is the global lighting angle for effects layer. If not present, assumed to be 30.
/// </summary>
PSD5GlobalAngle = 1037,
/// <summary>
/// (Obsolete) See ID 1073 below. (Photoshop 5.0) Color samplers resource. See See Color samplers resource format.
/// </summary>
[Obsolete("See ID 1073")]
ColorSamplersPSD5 = 1038,
/// <summary>
/// (Photoshop 5.0) ICC Profile. The raw bytes of an ICC (International Color Consortium) format profile. See ICC1v42_2006-05.pdf in the Documentation folder and icProfileHeader.h in Sample Code\Common\Includes .
/// </summary>
PSD5ICCProfile = 1039,
/// <summary>
/// (Photoshop 5.0) Watermark. One byte.
/// </summary>
PSD5Watermark = 1040,
/// <summary>
/// (Photoshop 5.0) ICC Untagged Profile. 1 byte that disables any assumed profile handling when opening the file. 1 = intentionally untagged.
/// </summary>
PSD5ICCUntaggedProfile = 1041,
/// <summary>
/// (Photoshop 5.0) Effects visible. 1-byte global flag to show/hide all the effects layer. Only present when they are hidden.
/// </summary>
PSD5EffectsHidden = 1042,
/// <summary>
/// (Photoshop 5.0) Spot Halftone. 4 bytes for version, 4 bytes for length, and the variable length data.
/// </summary>
PSD5SpotHalftone = 1043,
/// <summary>
/// (Photoshop 5.0) Document-specific IDs seed number. 4 bytes: Base value, starting at which layer IDs will be generated (or a greater value if
/// existing IDs already exceed it). Its purpose is to avoid the case where we add layers, flatten, save, open, and then add more layers that end
/// up with the same IDs as the first set.
/// </summary>
PSD5DocumentSpecificIDSeedNumber = 1044,
/// <summary>
/// (Photoshop 5.0) Unicode Alpha Names. Unicode string
/// </summary>
PSD5UnicodeAlphaNames = 1045,
/// <summary>
/// (Photoshop 6.0) Indexed Color Table Count. 2 bytes for the number of colors in table that are actually defined
/// </summary>
PSD6IndexedColorTableCount = 1046,
/// <summary>
/// (Photoshop 6.0) Transparency Index. 2 bytes for the index of transparent color, if any.
/// </summary>
TransparencyIndex = 1047,
/// <summary>
/// (Photoshop 6.0) Global Altitude. 4 byte entry for altitude
/// </summary>
GlobalAltitude = 1049,
/// <summary>
/// (Photoshop 6.0) Slices. See See Slices resource format.
/// </summary>
Slices = 1050,
/// <summary>
/// (Photoshop 6.0) Workflow URL. Unicode string
/// </summary>
WorkflowURL = 1051,
/// <summary>
/// (Photoshop 6.0) Jump To XPEP. 2 bytes major version, 2 bytes minor version, 4 bytes count. Following is repeated for count: 4 bytes block size, 4 bytes key, if key = 'jtDd', then next is a Boolean for the dirty flag; otherwise it's a 4 byte entry for the mod date.
/// </summary>
JumpToXpep = 1052,
/// <summary>
/// (Photoshop 6.0) Alpha Identifiers. 4 bytes of length, followed by 4 bytes each for every alpha identifier.
/// </summary>
AlphaIdentifiers = 1053,
/// <summary>
/// (Photoshop 6.0) URL List. 4 byte count of URLs, followed by 4 byte long, 4 byte ID, and Unicode string for each count.
/// </summary>
URLList = 1054,
/// <summary>
/// (Photoshop 6.0) Version Info. 4 bytes version, 1 byte hasRealMergedData, Unicode string: writer name, Unicode string: reader name, 4 bytes file version.
/// </summary>
VersionInfo = 1057,
/// <summary>
/// (Photoshop 7.0) EXIF data 1. See http://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf
/// </summary>
ExifData1 = 1058,
/// <summary>
/// (Photoshop 7.0) EXIF data 3. See http://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf
/// </summary>
ExifData3 = 1059,
/// <summary>
/// (Photoshop 7.0) XMP metadata. File info as XML description. See http://www.adobe.com/devnet/xmp/
/// </summary>
XMPMetadata = 1060,
/// <summary>
/// (Photoshop 7.0) Caption digest. 16 bytes: RSA Data Security, MD5 message-digest algorithm
/// </summary>
CaptionDigest = 1061,
/// <summary>
/// (Photoshop 7.0) Print scale. 2 bytes style (0 = centered, 1 = size to fit, 2 = user defined). 4 bytes x location (floating point). 4 bytes y location (floating point). 4 bytes scale (floating point)
/// </summary>
PrintScale = 1062,
/// <summary>
/// (Photoshop CS) Pixel Aspect Ratio. 4 bytes (version = 1 or 2), 8 bytes double, x / y of a pixel. Version 2, attempting to correct values for NTSC and PAL, previously off by a factor of approx. 5%.
/// </summary>
PixelAspectRatio = 1064,
/// <summary>
/// (Photoshop CS) Layer Comps. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)
/// </summary>
LayerComps = 1065,
/// <summary>
/// (Photoshop CS) Alternate Duotone Colors. 2 bytes (version = 1), 2 bytes count, following is repeated for each count: [Color: 2 bytes for space followed by 4 * 2 byte color component], following this is another 2 byte count, usually 256, followed by Lab colors one byte each for L, a, b. This resource is not read or used by Photoshop.
/// </summary>
AlternateDuotoneColors = 1066,
/// <summary>
/// (Photoshop CS)Alternate Spot Colors. 2 bytes (version = 1), 2 bytes channel count, following is repeated for each count: 4 bytes channel ID, Color: 2 bytes for space followed by 4 * 2 byte color component. This resource is not read or used by Photoshop.
/// </summary>
AlternateSpotColors = 1067,
/// <summary>
/// (Photoshop CS2) Layer Selection ID(s). 2 bytes count, following is repeated for each count: 4 bytes layer ID
/// </summary>
LayerSelectionIDs = 1069,
/// <summary>
/// (Photoshop CS2) HDR Toning information
/// </summary>
HDRToning = 1070,
/// <summary>
/// (Photoshop CS2) Print info
/// </summary>
PrintInfoCS2 = 1071,
/// <summary>
/// (Photoshop CS2) Layer Group(s) Enabled ID. 1 byte for each layer in the document, repeated by length of the resource. NOTE: Layer groups have start and end markers
/// </summary>
LayerGroupsEnabledIDs = 1072,
/// <summary>
/// (Photoshop CS3) Color samplers resource. Also see ID 1038 for old format. See See Color samplers resource format.
/// </summary>
ColorSamplersCS3 = 1073,
/// <summary>
/// (Photoshop CS3) Measurement Scale. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)
/// </summary>
MeasurementScale = 1074,
/// <summary>
/// (Photoshop CS3) Timeline Information. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)
/// </summary>
TimelineInformation = 1075,
/// <summary>
/// (Photoshop CS3) Sheet Disclosure. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)
/// </summary>
SheetDisclosure = 1076,
/// <summary>
/// (Photoshop CS3) DisplayInfo structure to support floating point clors. Also see ID 1007. See Appendix A in Photoshop API Guide.pdf .
/// </summary>
DisplayInfoCS3 = 1077,
/// <summary>
/// (Photoshop CS3) Onion Skins. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure)
/// </summary>
OnionSkins = 1078,
/// <summary>
/// (Photoshop CS4) Count Information. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) Information about the count in the document. See the Count Tool.
/// </summary>
Count = 1080,
/// <summary>
/// (Photoshop CS5) Print Information. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) Information about the current print settings in the document. The color management options.
/// </summary>
PrintInfoCS5 = 1082,
/// <summary>
/// (Photoshop CS5) Print Style. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) Information about the current print style in the document. The printing marks, labels, ornaments, etc.
/// </summary>
PrintStyle = 1083,
/// <summary>
/// (Photoshop CS5) Macintosh NSPrintInfo. Variable OS specific info for Macintosh. NSPrintInfo. It is recommened that you do not interpret or use this data.
/// </summary>
NSPrintInfo = 1084,
/// <summary>
/// (Photoshop CS5) Windows DEVMODE. Variable OS specific info for Windows. DEVMODE. It is recommened that you do not interpret or use this data.
/// </summary>
Devmode = 1085,
/// <summary>
/// (Photoshop CS6) Auto Save File Path. Unicode string. It is recommened that you do not interpret or use this data.
/// </summary>
AutoSaveFilePath = 1086,
/// <summary>
/// (Photoshop CS6) Auto Save Format. Unicode string. It is recommened that you do not interpret or use this data.
/// </summary>
AutoSaveFormat = 1087,
/// <summary>
/// (Photoshop CC) Path Selection State. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) Information about the current path selection state.
/// </summary>
PathSelectionState = 1088,
/// <summary>
/// Starting mask for Path Information (saved paths). See See Path resource format.
/// </summary>
PathInformationMaskBegin = 2000,
/// <summary>
/// Ending mask for Path Information (saved paths). See See Path resource format.
/// </summary>
PathInformationMaskEnd = 2997,
/// <summary>
/// Name of clipping path. See See Path resource format.
/// </summary>
ClippingPathName = 2999,
/// <summary>
/// (Photoshop CC) Origin Path Info. 4 bytes (descriptor version = 16), Descriptor (see See Descriptor structure) Information about the origin path data.
/// </summary>
OriginPathInfo = 3000,
/// <summary>
/// Starting mask for Plug-In resource(s). Resources added by a plug-in. See the plug-in API found in the SDK documentation
/// </summary>
PlugInResourceMaskBegin = 4000,
/// <summary>
/// Ending mask for Plug-In resource(s). Resources added by a plug-in. See the plug-in API found in the SDK documentation
/// </summary>
PlugInResourceMaskEnd = 4999,
/// <summary>
/// Image Ready variables. XML representation of variables definition
/// </summary>
ImageReadyVariables = 7000,
/// <summary>
/// Image Ready data sets
/// </summary>
ImageReadyDatasets = 7001,
/// <summary>
/// Image Ready default selected state
/// </summary>
ImageReadyDefaultSelectedState = 7002,
/// <summary>
/// Image Ready 7 rollover expanded state
/// </summary>
ImageReady7RolloverExpandedState = 7003,
/// <summary>
/// Image Ready rollover expanded state
/// </summary>
ImageReadyRolloverExpandedState = 7004,
/// <summary>
/// Image Ready save layer settings
/// </summary>
ImageReadySaveLayerSettings = 7005,
/// <summary>
/// Image Ready version
/// </summary>
ImageReadyVersion = 7006,
/// <summary>
/// (Photoshop CS3) Lightroom workflow, if present the document is in the middle of a Lightroom workflow.
/// </summary>
LightroomWorkflow = 8000,
/// <summary>
/// Print flags information. 2 bytes version ( = 1), 1 byte center crop marks, 1 byte ( = 0), 4 bytes bleed width value, 2 bytes bleed width scale.
/// </summary>
PrintFlags2 = 10000,
VanishingPointMacintosh = 18012,
VanishingPointWindows = 29806
}
}

View File

@ -0,0 +1,38 @@
//
// PSDLayer.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using MBS.Framework.Drawing;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop.Internal
{
public struct PSDLayer
{
public Rectangle Rectangle;
public short ChannelCount;
public PSDBlendModeKey BlendMode;
public byte Opacity;
public byte ClippingMode;
public PSDLayerFlags Flags;
public string Name;
}
}

View File

@ -0,0 +1,56 @@
//
// PSDBlendModeKey.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop
{
public enum PSDBlendModeKey : int
{
// all values are in big-endian
PassThrough = 1885434739, // 'pass'
Normal = 1852797549, // 'norm'
Dissolve = 1684632435, // 'diss'
Darken = 1684107883, // 'dark'
Multiply = 1836411936, // 'mul '
ColorBurn = 1768188278, // 'idiv'
LinearBurn = 1818391150, // 'lbrn'
DarkerColor = 1684751212, // 'dkCl'
Lighten = 1818850405, // 'lite'
Screen = 1935897198, // 'scrn'
ColorDodge = 1684633120, // 'div '
LinearDodge = 1818518631, // 'lddg'
LighterColor = 1818706796, // 'lgCl'
Overlay = 1870030194, // 'over'
SoftLight = 1934387572, // 'sLit'
HardLight = 1749838196, // 'hLit'
VividLight = 1984719220, // 'vLit'
LinearLight = 1816947060, // 'lLit'
PinLight = 1884055924, // 'pLit'
HardMix = 1749903736, // 'hMix'
Difference = 1684629094, // 'diff'
Exclusion = 1936553316, // 'smud'
Subtraction = 1718842722, // 'fsub'
Divide = 1717856630, // 'fdiv'
Hue = 1752524064, // 'hue '
Saturation = 1935766560, // 'sat '
Color = 1668246642, // 'colr'
Luminosity = 1819634976 // 'lum '
}
}

View File

@ -0,0 +1,35 @@
//
// PSDColorMode.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop
{
public enum PSDColorMode : short
{
Bitmap = 0,
Grayscale = 1,
Indexed = 2,
RGB = 3,
CMYK = 4,
Multichannel = 7,
Duotone = 8,
Lab = 9
}
}

View File

@ -0,0 +1,47 @@
//
// PSDColorSamplerColorSpace.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop
{
public enum PSDColorSamplerColorSpace
{
RGB = 0,
HSB,
CMYK,
Pantone,
Focoltone,
Trumatch,
Toyo,
Lab,
Gray,
WideCMYK,
HKS,
DIC,
TotalInk,
MonitorRGB,
Duotone,
Opacity,
Web,
GrayFloat,
RGBFloat,
OpacityFloat
}
}

View File

@ -0,0 +1,519 @@
//
// PSDDataFormat.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using UniversalEditor.IO;
using UniversalEditor.ObjectModels.Multimedia.Picture;
using UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop.Internal;
using System.Collections.Generic;
using UniversalEditor.Accessors;
using MBS.Framework.Drawing;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop
{
public class PSDDataFormat : DataFormat
{
private static DataFormatReference _dfr = null;
protected override DataFormatReference MakeReferenceInternal()
{
if (_dfr == null)
{
_dfr = base.MakeReferenceInternal();
_dfr.Capabilities.Add(typeof(PictureObjectModel), DataFormatCapabilities.All);
}
return _dfr;
}
private PSDHeader ReadPSDHeader(Reader reader)
{
PSDHeader header = new PSDHeader();
// Signature: always equal to '8BPS'.Do not try to read the file if the signature does not match this value.
header.signature = reader.ReadFixedLengthString(4);
if (header.signature != "8BPS") throw new InvalidDataFormatException();
// Version: always equal to 1.Do not try to read the file if the version does not match this value. (**PSB * *version is 2.)
header.version = reader.ReadInt16();
if (header.version > 2) throw new InvalidDataFormatException();
header.reserved = reader.ReadBytes(6); // Reserved: must be zero.
header.channelCount = reader.ReadInt16(); // The number of channels in the image, including any alpha channels.Supported range is 1 to 56.
header.imageHeight = reader.ReadInt32(); // The height of the image in pixels.Supported range is 1 to 30,000. (**PSB * *max of 300, 000.)
header.imageWidth = reader.ReadInt32(); // The width of the image in pixels.Supported range is 1 to 30,000. (*PSB * *max of 300, 000)
header.bitDepth = reader.ReadInt16(); // Depth: the number of bits per channel. Supported values are 1, 8, 16 and 32.
header.colorMode = (PSDColorMode)reader.ReadInt16(); // The color mode of the file. Supported values are: Bitmap = 0; Grayscale = 1; Indexed = 2; RGB = 3; CMYK = 4; Multichannel = 7; Duotone = 8; Lab = 9.
return header;
}
private PSDImageResourceBlock ReadPSDImageResourceBlock(Reader reader)
{
PSDImageResourceBlock block = new PSDImageResourceBlock();
block.signature = reader.ReadFixedLengthString(4);
if (block.signature != "8BIM") throw new InvalidDataFormatException("PSD image resource block does not begin with '8BIM'");
block.id = reader.ReadInt16();
block.name = reader.ReadNullTerminatedString();
reader.Align(2);
block.datalength = reader.ReadInt32();
block.data = reader.ReadBytes(block.datalength);
reader.Align(2);
return block;
}
private List<PSDImageResourceBlock> mvarImageResourceBlocks = new List<PSDImageResourceBlock>();
protected override void LoadInternal(ref ObjectModel objectModel)
{
Reader reader = base.Accessor.Reader;
reader.Endianness = Endianness.BigEndian;
PSDHeader header = ReadPSDHeader(reader);
List<PSDLayer> layers = new List<PSDLayer>();
int colorModeDataSectionLength = reader.ReadInt32();
// Indexed color images: length is 768; color data contains the color table for the image, in non-interleaved order.
// Duotone images: color data contains the duotone specification(the format of which is not documented). Other applications that read Photoshop files can treat a duotone image as a gray image, and just preserve the contents of the duotone information when reading and writing the file.
reader.Seek(colorModeDataSectionLength, SeekOrigin.Current);
int imageResourceSectionLength = reader.ReadInt32();
long end = reader.Accessor.Position + imageResourceSectionLength;
while (reader.Accessor.Position < end)
{
PSDImageResourceBlock block = ReadPSDImageResourceBlock(reader);
Reader br = new Reader(new MemoryAccessor(block.data));
if (block.KnownId == PSDKnownImageResourceBlockId.PSD4GridGuidesInformation)
{
// shop stores grid and guides information for an image in an image
// resource block. Each of these resource blocks consists of an initial 16 - byte
// grid and guide header, which is always present, followed by 5 - byte blocks of
// specific guide information for guide direction and location, which are present
// if there are guides(fGuideCount > 0)
int version = br.ReadInt32();
int horizontalGridSize = br.ReadInt32();
int verticalGridSize = br.ReadInt32();
int fGuideCount = br.ReadInt32(); // number of guide resource blocks (can be 0)
for (int i = 0; i < fGuideCount; i++)
{
// Location of guide in document coordinates. Since the guide is
// either vertical or horizontal, this only has to be one component of
// the coordinate.
int guideLocation = br.ReadInt32();
// Direction of guide. VHSelect is a system type of unsigned char where
// 0 = vertical, 1 = horizontal.
int guideDirection = br.ReadInt32();
// Grid and guide information may be modified using the Property suite. See the
// Callbacks chapter in Photoshop API Guide.pdf for more information.
}
}
else if (block.KnownId == PSDKnownImageResourceBlockId.PSD4ThumbnailResource || block.KnownId == PSDKnownImageResourceBlockId.PSD5ThumbnailResource)
{
// Adobe Photoshop (version 5.0 and later) stores thumbnail information for
// preview display in an image resource block that consists of an initial 28 - byte
// header, followed by a JFIF thumbnail in RGB(red, green, blue) order for both
// Macintosh and Windows.
// Adobe Photoshop 4.0 stored the thumbnail information in the same format
// except the data section is BGR (blue, green, red).The 4.0 format is at
// resource ID 1033 and the 5.0 format is at resource ID 1036.
// Format. 1 = kJpegRGB . Also supports kRawRGB (0).
int format = br.ReadInt32();
// Width of thumbnail in pixels.
int thumbnailWidth = br.ReadInt32();
// Height of thumbnail in pixels.
int thumbnailHeight = br.ReadInt32();
// Widthbytes: Padded row bytes = (width * bits per pixel + 31) / 32 * 4.
int thumbnailWidthBytes = br.ReadInt32();
// Total size = widthbytes * height * planes
int totalSize = br.ReadInt32();
// Size after compression. Used for consistency check.
int sizeAfterCompression = br.ReadInt32();
// Bits per pixel. = 24
short bitsPerPixel = br.ReadInt16();
// Number of planes. = 1
short planeCount = br.ReadInt16();
// JFIF data in RGB format.
// For resource ID 1033 the data is in BGR format.
if (block.KnownId == PSDKnownImageResourceBlockId.PSD4ThumbnailResource)
{
}
else if (block.KnownId == PSDKnownImageResourceBlockId.PSD5ThumbnailResource)
{
}
}
else if (block.KnownId == PSDKnownImageResourceBlockId.ColorSamplersPSD5 || block.KnownId == PSDKnownImageResourceBlockId.ColorSamplersCS3)
{
// Adobe Photoshop(version 5.0 and later) stores color samplers information for
// an image in an image resource block that consists of an initial 8 - byte color
// samplers header followed by a variable length block of specific color samplers
// information.
int version = br.ReadInt32();
int colorSamplerCount = br.ReadInt32();
for (int i = 0; i < colorSamplerCount; i++)
{
// Version of color samplers, 1 for version 3. ( Version 3 only ) .
int colorSamplerVersion = br.ReadInt32();
// The horizontal and vertical position of the point (4 bytes each).
// Version 1 is a fixed value.Version 2 is a float value.
float horizontalPosition = 0.0f; // br.ReadInt32();
float verticalPosition = 0.0f; // br.ReadInt32();
if (version == 1)
{
horizontalPosition = br.ReadInt32();
verticalPosition = br.ReadInt32();
}
else if (version >= 2)
{
horizontalPosition = br.ReadSingle();
verticalPosition = br.ReadSingle();
}
PSDColorSamplerColorSpace colorSpace = (PSDColorSamplerColorSpace)br.ReadInt16();
short depth = br.ReadInt16();
}
}
else if (block.KnownId >= PSDKnownImageResourceBlockId.PathInformationMaskBegin && block.KnownId <= PSDKnownImageResourceBlockId.PathInformationMaskEnd)
{
// Path resource format
// Photoshop stores the paths saved with an image in an image resource block.
// These resource blocks consist of a series of 26 - byte path point records, so the
// resource length should always be a multiple of 26.
// Photoshop stores its paths as resources of type 8BIM , with IDs in the range
// 2000 through 2997.These numbers should be reserved for Photoshop.The
// name of the resource is the name given to the path when it was saved.
// If the file contains a resource of type 8BIM with an ID of 2999, then this
// resource contains a Pascal - style string containing the name of the clipping
// path to use with this image when saving it as an EPS file. 4 byte fixed value
// for flatness and 2 byte fill rule. 0 = same fill rule, 1 = even odd fill rule, 2 =
// non zero winding fill rule.The fill rule is ignored by Photoshop.
// The path format returned by GetProperty() call is identical to what is described
// below. Refer to the IllustratorExport sample plug -in code to see how this
// resource data is constructed.
// Path points
// All points used in defining a path are stored in eight bytes as a pair of 32 - bit
// components, vertical component first.
// The two components are signed, fixed point numbers with 8 bits before the
// binary point and 24 bits after the binary point.Three guard bits are reserved
// in the points to eliminate most concerns over arithmetic overflow.Hence, the
// range for each component is 0xF0000000 to 0x0FFFFFFF representing a range
// of - 16 to 16.The lower bound is included, but not the upper bound.
// This limited range is used because the points are expressed relative to the
// image size.The vertical component is given with respect to the image height,
// and the horizontal component is given with respect to the image width. [0, 0]
// represents the top - left corner of the image; [ 1,1 ]
// ([0x01000000, 0x01000000])
// represents the bottom-right.
// In Windows, the byte order of the path point components are reversed; you
// should swap the bytes when accessing each 32 - bit value.
// Path records
// The data in a path resource consists of one or more 26-byte records. The first
// two bytes of each record is a selector to indicate what kind of path it is.For
// Windows, you should swap the bytes before accessing it as a short.
PSDPathType type = (PSDPathType)br.ReadInt16();
// The first 26 - byte path record contains a selector value of 6, path fill rule
// record.The remaining 24 bytes of the first record are zeroes.Paths use
// even / odd ruling.Subpath length records, selector value 0 or 3, contain the
// number of Bezier knot records in bytes 2 and 3.The remaining 22 bytes are
// unused, and should be zeroes. Each length record is then immediately
// followed by the Bezier knot records describing the knots of the subpath.
// In Bezier knot records, the 24 bytes following the selector field contain three
// path points(described above) for:
// the control point for the Bezier segment preceding the knot,
// the anchor point for the knot, and
// the control point for the Bezier segment leaving the knot.
// Linked knots have their control points linked.Editing one point modifies the
// other to preserve collinearity.Knots should only be marked as having linked
// controls if their control points are collinear with their anchor.The control
// points on unlinked knots are independent of each other.Refer to the Adobe
// Photoshop User Guide for more information.
// Clipboard records, selector = 7, contain four fixed-point numbers for the
// bounding rectangle(top, left, bottom, right), and a single fixed-point number
// indicating the resolution.
// Initial fill records, selector = 8 , contain one two byte record. A value of 1
}
else if (block.KnownId == PSDKnownImageResourceBlockId.Slices)
{
// Slices resource format
// Adobe Photoshop 6.0 stores slices information for an image in an image
// resource block.
// Adobe Photoshop 7.0 added a descriptor at the end of the block for the
// individual slice info.
// Adobe Photoshop CS and later changed to version 7 or 8 and uses a
// Descriptor to defined the Slices data.
int version = br.ReadInt32();
if (version == 6)
{
// Bounding rectangle for all of the slices: top, left, bottom, right of all
// the slices
int boundingRectangleTop = br.ReadInt32();
int boundingRectangleLeft = br.ReadInt32();
int boundingRectangleBottom = br.ReadInt32();
int boundingRectangleRight = br.ReadInt32();
// Name of group of slices: Unicode string
string groupName = br.ReadNullTerminatedString(Encoding.UTF16BigEndian);
// Number of slices to follow. See Slices resource block in the next
// table.
int sliceCount = br.ReadInt32();
for (int i = 0; i < sliceCount; i++)
{
int sliceID = br.ReadInt32();
int groupID = br.ReadInt32();
int origin = br.ReadInt32();
if (origin == 1)
{
int associatedLayerId = br.ReadInt32();
}
string sliceName = br.ReadNullTerminatedString(Encoding.UTF16BigEndian);
int sliceType = br.ReadInt32();
int sliceLeft = br.ReadInt32();
int sliceTop = br.ReadInt32();
int sliceRight = br.ReadInt32();
int sliceBottom = br.ReadInt32();
string url = br.ReadNullTerminatedString(Encoding.UTF16BigEndian);
string target = br.ReadNullTerminatedString(Encoding.UTF16BigEndian);
string message = br.ReadNullTerminatedString(Encoding.UTF16BigEndian);
string altText = br.ReadNullTerminatedString(Encoding.UTF16BigEndian);
bool cellTextIsHTML = br.ReadBoolean();
string cellText = br.ReadNullTerminatedString(Encoding.UTF16BigEndian);
int horizontalAlignment = br.ReadInt32();
int verticalAlignment = br.ReadInt32();
byte alpha = br.ReadByte();
byte red = br.ReadByte();
byte green = br.ReadByte();
byte blue = br.ReadByte();
// Additional data as length allows. See comment above.
int descriptorVersion = br.ReadInt32();
// descriptor...
}
}
else if (version >= 7)
{
// Descriptor version ( = 16 for Photoshop 6.0).
int descriptorVersion = br.ReadInt32();
}
}
else if (block.KnownId == PSDKnownImageResourceBlockId.VanishingPointMacintosh || block.KnownId == PSDKnownImageResourceBlockId.VanishingPointWindows)
{
/*
version = 101
number of relations to follow.
-- for each relation--
grid resolution for the root plane
number of planes to follow
-- for each plane in calibration order--
ID of the plane
ID of the plane that calibrates this plane 0 if none
-- for 4 rays--
origin position of the ray.Point
VP location - must be consistent across all planes in the relation unless it is an
endpoint. Point
true if the VP location is an endpoint
ID that this ray points at.
Ray DI(see below)
++++++++++++++++++++
I / O appendix
Point - two doubles; h endl, v endl
VPID - int(enum value) 0,1,2 identifing 1 of 3 possible VPs
RayID - 1, One of the primary rays directly connected to the shared origin
3, a non-primary ray parallel to 7
5, a non-primary ray parallel to 1
7, One of the primary rays directly connected to the shared origin.
*/
}
mvarImageResourceBlocks.Add(block);
}
long layerAndMaskSectionLength = (header.version >= 2 ? reader.ReadInt64() : reader.ReadInt32());
// layer info
long layerInfoLength = (header.version >= 2 ? reader.ReadInt64() : reader.ReadInt32());
short layerCount = reader.ReadInt16();
if (layerCount < 0)
{
// If it is a negative number, its absolute value is the
// number of layers and the first alpha channel contains the
// transparency data for the merged result.
layerCount = Math.Abs(layerCount);
}
for (short i = 0; i < layerCount; i++)
{
PSDLayer layer = new PSDLayer();
int layerTop = reader.ReadInt32();
int layerLeft = reader.ReadInt32();
int layerBottom = reader.ReadInt32();
int layerRight = reader.ReadInt32();
layer.Rectangle = new Rectangle(layerLeft, layerTop, layerRight - layerLeft, layerBottom - layerTop);
layer.ChannelCount = reader.ReadInt16();
for (short j = 0; j < layer.ChannelCount; j++)
{
short channelID = reader.ReadInt16(); // 0 = red, 1 = green, etc.
// -1 = transparency mask; -2 = user supplied layer mask, -3 real
// user supplied layer mask(when both a user mask and a vector
// mask are present)
long channelDataLength = (header.version >= 2 ? reader.ReadInt64() : reader.ReadInt32());
// channel data...
}
string blendModeSignature = reader.ReadFixedLengthString(4); // 8BIM
layer.BlendMode = (PSDBlendModeKey)reader.ReadInt32();
layer.Opacity = reader.ReadByte(); // 0...255
layer.ClippingMode = reader.ReadByte(); // 0=base, 1=non-base
layer.Flags = (PSDLayerFlags)reader.ReadByte();
byte zero = reader.ReadByte(); // filler
int extraDataFieldLength = reader.ReadInt32(); // the total length of the next five fields
// layer mask data
int layerMaskDataSize = reader.ReadInt32();
if (layerMaskDataSize > 0)
{
// Rectangle enclosing layer mask: Top, left, bottom, right
int enclosingLayerMaskTop = reader.ReadInt32();
int enclosingLayerMaskLeft = reader.ReadInt32();
int enclosingLayerMaskBottom = reader.ReadInt32();
int enclosingLayerMaskRight = reader.ReadInt32();
byte defaultColor = reader.ReadByte(); // 0 or 255
PSDLayerMaskFlags maskFlags = (PSDLayerMaskFlags) reader.ReadByte();
if ((maskFlags & PSDLayerMaskFlags.ContainsParameter) == PSDLayerMaskFlags.ContainsParameter)
{
PSDLayerMaskParameterFlags paramFlags = (PSDLayerMaskParameterFlags)reader.ReadByte();
}
if (layerMaskDataSize == 20)
{
short padding = reader.ReadInt16();
}
else
{
PSDLayerMaskParameterFlags realFlags = (PSDLayerMaskParameterFlags)reader.ReadByte();
byte realUserMaskBackground = reader.ReadByte(); // 0 or 255
int realEnclosingLayerMaskTop = reader.ReadInt32();
int realEnclosingLayerMaskLeft = reader.ReadInt32();
int realEnclosingLayerMaskBottom = reader.ReadInt32();
int realEnclosingLayerMaskRight = reader.ReadInt32();
}
}
// blending ranges
int layerBlendingRangesDataSize = reader.ReadInt32();
if (layerBlendingRangesDataSize > 0)
{
// Composite gray blend source. Contains 2 black values followed by 2
// white values. Present but irrelevant for Lab & Grayscale.
byte compositeGrayBlendSourceBlack1 = reader.ReadByte();
byte compositeGrayBlendSourceBlack2 = reader.ReadByte();
byte compositeGrayBlendSourceWhite1 = reader.ReadByte();
byte compositeGrayBlendSourceWhite2 = reader.ReadByte();
// Composite gray blend destination range
int compositeGrayBlendDestinationRange = reader.ReadInt32();
for (short j = 0; j > layer.ChannelCount; j++)
{
int channelSourceRange = reader.ReadInt32();
int channelDestinationRange = reader.ReadInt32();
}
}
// layer name padded to 4 bytes
layer.Name = reader.ReadNullTerminatedString();
reader.Align(4);
layers.Add(layer);
}
for (int i = 0; i < layerCount; i++)
{
PSDLayer layer = layers[i];
// Image data.
PSDLayerCompressionMode compressionMode = (PSDLayerCompressionMode) reader.ReadInt16();
switch (compressionMode)
{
case PSDLayerCompressionMode.Raw:
{
// If the compression code is 0, the image data is just the raw image
// data, whose size is calculated as: (from the first field in See Layer records).
int dataSize = (int)((layer.Rectangle.Bottom - layer.Rectangle.Y) * (layer.Rectangle.Right - layer.Rectangle.X));
break;
}
case PSDLayerCompressionMode.RLE:
{
// If the compression code is 1, the image data starts with the byte
// counts for all the scan lines in the channel(LayerBottom - LayerTop),
// with each count stored as a two - byte value.(**PSB * *each count
// stored as a four - byte value.) The RLE compressed data follows,
// with each scan line compressed separately.The RLE compression is
// the same compression algorithm used by the Macintosh ROM
// routine PackBits, and the TIFF standard.
break;
}
}
// If the layer's size, and therefore the data, is odd, a pad byte will be
// inserted at the end of the row.
// If the layer is an adjustment layer, the channel data is undefined
// (probably all white.)
}
// global layer mask info
int globalLayerMaskInfoSectionLength = reader.ReadInt32();
short globalOverlayColorSpace = reader.ReadInt16();
short[] globalColorComponents = reader.ReadInt16Array(4);
short globalOpacity = reader.ReadInt16(); // 0 = transparent, 100 = opaque
byte globalKind = reader.ReadByte();
// Kind. 0 = Color selected--i.e. inverted; 1 = Color protected;128 =
// use value stored per layer.This value is preferred.The others are
// for backward compatibility with beta versions.
// tagged blocks (PSB4.0 >)
}
protected override void SaveInternal(ObjectModel objectModel)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,31 @@
//
// PSDLayerCompressionMode.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop
{
public enum PSDLayerCompressionMode : short
{
Raw = 0,
RLE = 1,
ZIPWithoutPrediction = 2,
ZIPWithPrediction = 3
}
}

View File

@ -0,0 +1,33 @@
//
// PSDLayerFlags.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop
{
[Flags()]
public enum PSDLayerFlags
{
TransparencyProtected = 0x0,
Visible = 0x1,
Obsolete = 0x2,
Photoshop5OrLater = 0x4,
PixelDataIrrelevantToAppearanceOfDocument = 0x8 // wtf
}
}

View File

@ -0,0 +1,47 @@
//
// PSDLayerMaskFlags.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop
{
public enum PSDLayerMaskFlags
{
/// <summary>
/// position relative to layer
/// </summary>
PositionRelativeToLayer = 0x01,
/// <summary>
/// layer mask disabled
/// </summary>
LayerMaskDisabled = 0x02,
/// <summary>
/// invert layer mask when blending (Obsolete)
/// </summary>
InvertLayerMaskWhenBlending = 0x04,
/// <summary>
/// indicates that the user mask actually came from rendering other data
/// </summary>
UserMaskFromRenderingOtherData = 0x08,
/// <summary>
/// indicates that the user and/or vector masks have parameters applied to them
/// </summary>
ContainsParameter = 0x10
}
}

View File

@ -0,0 +1,43 @@
//
// PSDLayerMaskParameterFlags.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop
{
public enum PSDLayerMaskParameterFlags
{
/// <summary>
/// user mask density, 1 byte
/// </summary>
UserMaskDensity = 0x01,
/// <summary>
/// user mask feather, 8 byte, double
/// </summary>
UserMaskFeather = 0x02,
/// <summary>
/// vector mask density, 1 byte
/// </summary>
VectorMaskDensity = 0x04,
/// <summary>
/// vector mask feather, 8 bytes, double
/// </summary>
VectorMaskFeather = 0x08
}
}

View File

@ -0,0 +1,36 @@
//
// PSDPathType.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// Copyright (c) 2019 Mike Becker
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.Multimedia.Picture.Adobe.Photoshop
{
public enum PSDPathType
{
ClosedSubpathLength = 0,
ClosedSubpathBezierKnotLinked = 1,
ClosedSubpathBezierKnotUnlinked = 2,
OpenSubpathLengthRecord = 3,
OpenSubpathBezierKnotLinked = 4,
OpenSubpathBezierKnotUnlinked = 5,
PathFillRule = 6,
Clipboard = 7,
InitialFillRule = 8
}
}

View File

@ -303,6 +303,19 @@
<Compile Include="DataFormats\Multimedia\BluRay\MPLSDataFormat.cs" />
<Compile Include="DataFormats\Multimedia\Picture\ZSoft\PCXDataFormat.cs" />
<Compile Include="DataFormats\Multimedia\Picture\ZSoft\PCXHeader.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\PSDDataFormat.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\PSDColorMode.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\Internal\PSDHeader.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\Internal\PSDImageResourceBlock.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\Internal\PSDKnownImageResourceBlockId.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\PSDColorSamplerColorSpace.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\PSDPathType.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\PSDBlendModeKey.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\PSDLayerFlags.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\PSDLayerMaskFlags.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\PSDLayerMaskParameterFlags.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\PSDLayerCompressionMode.cs" />
<Compile Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\Internal\PSDLayer.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Compression\UniversalEditor.Compression.csproj">
@ -347,6 +360,9 @@
</ItemGroup>
<ItemGroup>
<Folder Include="DataFormats\Multimedia\Picture\ZSoft\" />
<Folder Include="DataFormats\Multimedia\Picture\Adobe\" />
<Folder Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\" />
<Folder Include="DataFormats\Multimedia\Picture\Adobe\Photoshop\Internal\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>