Пример #1
0
 public static extern TwainResult DsImageLayout([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageLayout imglyt);
Пример #2
0
        private bool NegotiateArea(ScanSettings scanSettings)
        {
            var area = scanSettings.Area;

            if (area == null)
            {
                return false;
            }

            var cap = new Capability(Capabilities.IUnits, TwainType.Int16, _applicationId, SourceId);
            if ((Units)cap.GetBasicValue().Int16Value != area.Units)
            {
                Capability.SetCapability(Capabilities.IUnits, (short)area.Units, _applicationId, SourceId);
            }

            var imageLayout = new ImageLayout
            {
                Frame = new Frame
                {
                    Left = new Fix32(area.Left),
                    Top = new Fix32(area.Top),
                    Right = new Fix32(area.Right),
                    Bottom = new Fix32(area.Bottom)
                }
            };

            var result = Twain32Native.DsImageLayout(
                _applicationId,
                SourceId,
                DataGroup.Image,
                DataArgumentType.ImageLayout,
                Message.Set,
                imageLayout);

            if (result != TwainResult.Success)
            {
                throw new TwainException("DsImageLayout.GetDefault error", result);
            }

            return true;
        }
Пример #3
0
        private bool NegotiateArea(ScanSettings scanSettings)
        {
            var area = scanSettings.Area;

            if (area == null)
            {
                return false;
            }

			try
            {
                var cap = new Capability(Capabilities.IUnits, TwainType.Int16, _applicationId, SourceId);
                if ((Units)cap.GetBasicValue().Int16Value != area.Units)
                {
                    Capability.SetCapability(Capabilities.IUnits, (short)area.Units, _applicationId, SourceId);
                }
            }
            catch
            {
                // Do nothing if the data source does not support the requested capability
	            return false;
            }

	        float right;
	        float bottom;
			
			float physicalHeight = 0;
			var physicalHeightCap = Capability.GetCapability(Capabilities.PhysicalHeight, _applicationId, SourceId);

			if (physicalHeightCap != null && physicalHeightCap.Count == 1)
			{
				physicalHeight = ValueConverter.ConvertToFix32(physicalHeightCap[0]);
			}

			float physicalWidth = 0;
			var physicalWidthCap = Capability.GetCapability(Capabilities.PhysicalWidth, _applicationId, SourceId);

			if (physicalWidthCap != null && physicalWidthCap.Count == 1)
			{
				physicalWidth = ValueConverter.ConvertToFix32(physicalWidthCap[0]);
			}

			right = physicalWidth < area.Right ? physicalWidth : area.Right;
			bottom = physicalHeight < area.Bottom ? physicalHeight : area.Bottom;

            var imageLayout = new ImageLayout
            {
                Frame = new Frame
                {
                    Left = new Fix32(area.Left),
                    Top = new Fix32(area.Top),
                    Right = new Fix32(right),
                    Bottom = new Fix32(bottom)
                }
            };

	 

            var result = Twain32Native.DsImageLayout(
                _applicationId,
                SourceId,
                DataGroup.Image,
                DataArgumentType.ImageLayout,
                Message.Set,
                imageLayout);

            if (result != TwainResult.Success && result != TwainResult.CheckStatus)
            {
				var condition = DataSourceManager.GetConditionCode(_applicationId, SourceId);
	            return false;
				//throw new TwainException("DsImageLayout.GetDefault error", result, condition);
            }

            return true;
        }