private unsafe int GetAlias(PIActionList list, uint index, Handle *data) { if (data == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { byte[] bytes = (byte[])items[(int)index].Value; * data = HandleSuite.Instance.NewHandle(bytes.Length); if (*data == Handle.Null) { return(PSError.kSPOutOfMemoryError); } Marshal.Copy(bytes, 0, HandleSuite.Instance.LockHandle(*data, 0), bytes.Length); HandleSuite.Instance.UnlockHandle(*data); return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private static unsafe short CreateComplexPropertyHandle(Handle *complexProperty, byte[] bytes) { if (complexProperty == null) { return(PSError.paramErr); } *complexProperty = HandleSuite.Instance.NewHandle(bytes.Length); if (*complexProperty == Handle.Null) { return(PSError.memFullErr); } Marshal.Copy(bytes, 0, HandleSuite.Instance.LockHandle(*complexProperty, 0), bytes.Length); HandleSuite.Instance.UnlockHandle(*complexProperty); return(PSError.noErr); }
private unsafe short PropertyGetProc(uint signature, uint key, int index, IntPtr *simpleProperty, Handle *complexProperty) { #if DEBUG DebugUtils.Ping(DebugFlags.PropertySuite, string.Format("Sig: {0}, Key: {1}, Index: {2}", DebugUtils.PropToString(signature), DebugUtils.PropToString(key), index.ToString())); #endif if (signature != PSConstants.kPhotoshopSignature) { return(PSError.errPlugInPropertyUndefined); } short error = PSError.noErr; byte[] bytes = null; switch (key) { case PSProperties.BigNudgeH: case PSProperties.BigNudgeV: error = GetSimpleProperty(simpleProperty, new Fixed16(PSConstants.Properties.BigNudgeDistance).Value); break; case PSProperties.Caption: if (complexProperty != null) { *complexProperty = HandleSuite.Instance.NewHandle(0); } break; case PSProperties.ChannelName: string name = string.Empty; switch (index) { case 0: name = Resources.RedChannelName; break; case 1: name = Resources.GreenChannelName; break; case 2: name = Resources.BlueChannelName; break; case 3: name = Resources.AlphaChannelName; break; default: return(PSError.errPlugInPropertyUndefined); } bytes = Encoding.ASCII.GetBytes(name); error = CreateComplexPropertyHandle(complexProperty, bytes); break; case PSProperties.Copyright: case PSProperties.Copyright2: error = GetSimpleProperty(simpleProperty, false); break; case PSProperties.EXIFData: case PSProperties.XMPData: if (complexProperty != null) { // If the complexProperty is not IntPtr.Zero we return a valid zero byte handle, otherwise some filters will crash with an access violation. *complexProperty = HandleSuite.Instance.NewHandle(0); } break; case PSProperties.GridMajor: error = GetSimpleProperty(simpleProperty, new Fixed16(PSConstants.Properties.GridMajor).Value); break; case PSProperties.GridMinor: error = GetSimpleProperty(simpleProperty, PSConstants.Properties.GridMinor); break; case PSProperties.ImageMode: error = GetSimpleProperty(simpleProperty, PSConstants.plugInModeRGBColor); break; case PSProperties.InterpolationMethod: error = GetSimpleProperty(simpleProperty, PSConstants.Properties.InterpolationMethod.NearestNeghbor); break; case PSProperties.NumberOfChannels: error = GetSimpleProperty(simpleProperty, numberOfChannels); break; case PSProperties.NumberOfPaths: error = GetSimpleProperty(simpleProperty, 0); break; case PSProperties.WorkPathIndex: case PSProperties.ClippingPathIndex: case PSProperties.TargetPathIndex: error = GetSimpleProperty(simpleProperty, PSConstants.Properties.NoPathIndex); break; case PSProperties.RulerUnits: error = GetSimpleProperty(simpleProperty, PSConstants.Properties.RulerUnits.Pixels); break; case PSProperties.RulerOriginH: case PSProperties.RulerOriginV: error = GetSimpleProperty(simpleProperty, new Fixed16(0).Value); break; case PSProperties.SerialString: bytes = Encoding.ASCII.GetBytes(HostSerial); error = CreateComplexPropertyHandle(complexProperty, bytes); break; case PSProperties.URL: if (complexProperty != null) { *complexProperty = HandleSuite.Instance.NewHandle(0); } break; case PSProperties.Title: case PSProperties.UnicodeTitle: string title = "temp.pdn"; // some filters just want a non empty string if (key == PSProperties.UnicodeTitle) { bytes = Encoding.Unicode.GetBytes(title); } else { bytes = Encoding.ASCII.GetBytes(title); } error = CreateComplexPropertyHandle(complexProperty, bytes); break; case PSProperties.WatchSuspension: error = GetSimpleProperty(simpleProperty, false); break; case PSProperties.DocumentWidth: error = GetSimpleProperty(simpleProperty, documentWidth); break; case PSProperties.DocumentHeight: error = GetSimpleProperty(simpleProperty, documentHeight); break; case PSProperties.ToolTips: error = GetSimpleProperty(simpleProperty, true); break; case PSProperties.HighDpi: error = GetSimpleProperty(simpleProperty, highDpi); break; default: return(PSError.errPlugInPropertyUndefined); } return(error); }