public unsafe IntPtr CreateReadImageDocumentPointer(FilterCase filterCase, bool hasSelection) { IntPtr readDocumentPtr = Memory.Allocate(Marshal.SizeOf(typeof(ReadImageDocumentDesc)), true); try { ReadImageDocumentDesc *doc = (ReadImageDocumentDesc *)readDocumentPtr.ToPointer(); doc->minVersion = PSConstants.kCurrentMinVersReadImageDocDesc; doc->maxVersion = PSConstants.kCurrentMaxVersReadImageDocDesc; doc->imageMode = PSConstants.plugInModeRGBColor; doc->depth = 8; doc->bounds.top = 0; doc->bounds.left = 0; doc->bounds.right = documentWidth; doc->bounds.bottom = documentHeight; doc->hResolution = new Fixed16((int)(dpiX + 0.5)); doc->vResolution = new Fixed16((int)(dpiY + 0.5)); IntPtr channel = CreateReadChannelDesc(PSConstants.ChannelPorts.Red, Resources.RedChannelName, doc->depth, doc->bounds); ReadChannelDesc *ch = (ReadChannelDesc *)channel.ToPointer(); for (int i = PSConstants.ChannelPorts.Green; i <= PSConstants.ChannelPorts.Blue; i++) { string name = null; switch (i) { case PSConstants.ChannelPorts.Green: name = Resources.GreenChannelName; break; case PSConstants.ChannelPorts.Blue: name = Resources.BlueChannelName; break; } IntPtr ptr = CreateReadChannelDesc(i, name, doc->depth, doc->bounds); ch->next = ptr; ch = (ReadChannelDesc *)ptr.ToPointer(); } doc->targetCompositeChannels = doc->mergedCompositeChannels = channel; if (filterCase == FilterCase.EditableTransparencyNoSelection || filterCase == FilterCase.EditableTransparencyWithSelection) { IntPtr alphaPtr = CreateReadChannelDesc(PSConstants.ChannelPorts.Alpha, Resources.AlphaChannelName, doc->depth, doc->bounds); doc->targetTransparency = doc->mergedTransparency = alphaPtr; } if (hasSelection) { IntPtr selectionPtr = CreateReadChannelDesc(PSConstants.ChannelPorts.SelectionMask, Resources.MaskChannelName, doc->depth, doc->bounds); doc->selection = selectionPtr; } } catch (Exception) { if (readDocumentPtr != IntPtr.Zero) { Memory.Free(readDocumentPtr); } throw; } return(readDocumentPtr); }
public Fixed16DebugView(Fixed16 fixed16) { this.fixed16 = fixed16; }