コード例 #1
0
		/// <summary>
		/// Read this GraphicsSurface color buffer.
		/// </summary>
		/// <param name="ctx">
		/// A <see cref="GraphicsContext"/>
		/// </param>
		/// <param name="rBuffer">
		/// A <see cref="ReadBufferMode"/> that specify the read buffer where the colors are read from.
		/// </param>
		/// <param name="x">
		/// A <see cref="Int32"/> that specify the x coordinate of the lower left corder of the rectangle area to read.
		/// </param>
		/// <param name="y">
		/// A <see cref="Int32"/> that specify the y coordinate of the lower left corder of the rectangle area to read.
		/// </param>
		/// <param name="width">
		/// A <see cref="Int32"/> that specify the width of the rectangle area to read.
		/// </param>
		/// <param name="height">
		/// A <see cref="Int32"/> that specify the height of the rectangle area to read.
		/// </param>
		/// <param name="pType">
		/// A <see cref="PixelLayout"/> which determine the pixel storage of the returned image.
		/// </param>
		/// <returns>
		/// It returns an <see cref="Image"/> representing the current read buffer <paramref name="rBuffer"/>.
		/// </returns>
		protected Image ReadBuffer(GraphicsContext ctx, ReadBufferMode rBuffer, uint x, uint y, uint width, uint height, PixelLayout pType)
		{
			Image image = null;

			if ((x + width > Width) || (y + height > Height))
				throw new ArgumentException("specified region lies outside the GraphicsSurface");

			// Bind for reading
			BindRead(ctx);
			// Set for reading
			Gl.ReadBuffer(rBuffer);

			// Allocate image holding data read
			image = new Image();
			image.Create(pType, width, height);

			// Set pixel transfer
			foreach (int alignment in new int[] { 8, 4, 2, 1 }) {
				if (image.Stride % alignment == 0) {
					Gl.PixelStore(PixelStoreParameter.PackAlignment, alignment);
					break;
				}
			}

			// Grab frame buffer pixels
			PixelFormat rFormat = Pixel.GetGlFormat(pType);
			PixelType rType = Pixel.GetPixelType(pType);

			Gl.ReadPixels((int)x, (int)y, (int)width, (int)height, rFormat, rType, image.ImageBuffer);

			// Unbind from reading
			UnbindRead(ctx);

			return (image);
		}
コード例 #2
0
ファイル: ClientSvc.asmx.cs プロジェクト: cocoon/crucibleWDS
 public void AddImage(Image image)
 {
     image.Create(image);
     string imageID = image.GetImageID(image.Name);
     HttpContext.Current.Response.Write(imageID + "," + Utility.Message);
 }