예제 #1
0
        public RenderReply RenderBytes(Size outSize, Point topleft, Size pagesize, bool transparentBackground)
        {
            int    alpha = transparentBackground ? 0 : 255;
            object foxitMutex;

            Monitor.Enter(foxitMutex = FoxitViewer.FoxitMutex);
            RenderReply result;

            try
            {
                int bitmap = this.foxitLib.Bitmap_Create(outSize.Width, outSize.Height, 1);
                this.foxitLib.Bitmap_FillRect(bitmap, 0, 0, outSize.Width, outSize.Height, 255, 255, 255, alpha);
                this.foxitLib.RenderPageBitmap(bitmap, this.pageHandle, topleft.X, topleft.Y, pagesize.Width, pagesize.Height, 0, 0);
                IntPtr source = this.foxitLib.Bitmap_GetBuffer(bitmap);
                int    num    = outSize.Width * 4;
                byte[] array  = new byte[outSize.Height * num];
                Marshal.Copy(source, array, 0, array.Length);
                this.foxitLib.Bitmap_Destroy(bitmap);
                result = new RenderReply(array, outSize.Width * 4);
            }
            finally
            {
                Monitor.Exit(foxitMutex);
            }
            return(result);
        }
예제 #2
0
        public GDIBigLockedImage Render(Size outSize, Point topleft, Size pagesize, bool transparentBackground)
        {
            object obj = this.RobustRPC(new RenderRequest(topleft, pagesize, outSize, transparentBackground));

            if (obj is RenderReply)
            {
                RenderReply renderReply = (RenderReply)obj;
                if (renderReply.stride < 1 || renderReply.stride * outSize.Height > renderReply.data.Length)
                {
                    throw new Exception("Invalid RenderReply");
                }
                Bitmap     bitmap     = new Bitmap(outSize.Width, outSize.Height, PixelFormat.Format32bppPArgb);
                BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, outSize.Width, outSize.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppPArgb);
                try
                {
                    Marshal.Copy(renderReply.data, 0, bitmapData.Scan0, bitmapData.Stride * bitmapData.Height);
                }
                finally
                {
                    bitmap.UnlockBits(bitmapData);
                }
                return(new GDIBigLockedImage(bitmap));
            }
            else
            {
                if (obj is ExceptionMessageRecord)
                {
                    throw new Exception(((ExceptionMessageRecord)obj).message);
                }
                throw new Exception(string.Format("Unrecognized reply {0}", obj.GetType()));
            }
        }
예제 #3
0
		public RenderReply RenderBytes(Size outSize, Point topleft, Size pagesize, bool transparentBackground)
		{
			int alpha = transparentBackground ? 0 : 255;
			object foxitMutex;
			Monitor.Enter(foxitMutex = FoxitViewer.FoxitMutex);
			RenderReply result;
			try
			{
				int bitmap = this.foxitLib.Bitmap_Create(outSize.Width, outSize.Height, 1);
				this.foxitLib.Bitmap_FillRect(bitmap, 0, 0, outSize.Width, outSize.Height, 255, 255, 255, alpha);
				this.foxitLib.RenderPageBitmap(bitmap, this.pageHandle, topleft.X, topleft.Y, pagesize.Width, pagesize.Height, 0, 0);
				IntPtr source = this.foxitLib.Bitmap_GetBuffer(bitmap);
				int num = outSize.Width * 4;
				byte[] array = new byte[outSize.Height * num];
				Marshal.Copy(source, array, 0, array.Length);
				this.foxitLib.Bitmap_Destroy(bitmap);
				result = new RenderReply(array, outSize.Width * 4);
			}
			finally
			{
				Monitor.Exit(foxitMutex);
			}
			return result;
		}