public Wipe(string name, GDIDIBSection dstBitmap, GDIDIBSection srcBitmap, Rectangle frame, double duration, int direction) : base(name, frame, dstBitmap, srcBitmap, duration) { fDirection = direction; }
public override void PixBltPixelBuffer24(GDIDIBSection fPixMap, int x, int y) { MemoryStream ms = new MemoryStream(); PixelAccessorBGRb accessor = new PixelAccessorBGRb(fPixMap.Width, fPixMap.Height, fPixMap.Orientation, fPixMap.Pixels, fPixMap.BytesPerRow); // 2. Run length encode the image to a memory stream NewTOAPIA.Imaging.TargaRunLengthCodec rlc = new NewTOAPIA.Imaging.TargaRunLengthCodec(); rlc.Encode(accessor, ms); // 3. Get the bytes from the stream byte[] imageBytes = ms.GetBuffer(); int dataLength = (int)imageBytes.Length; // 4. Allocate a buffer chunk to accomodate the bytes, plus some more BufferChunk chunk = new BufferChunk(dataLength + 128); // 5. Put the command, destination, and data size into the buffer first chunk += (int)UICommands.PixBltRLE; ChunkUtils.Pack(chunk, x, y); ChunkUtils.Pack(chunk, accessor.Width, accessor.Height); chunk += dataLength; // 6. Put the image bytes into the chunk chunk += imageBytes; // 6. Finally, send the packet SendCommand(chunk); }
public static PixelArray<Lumb> Copy(PixelArray<Lumb> dst, GDIDIBSection src) { if (dst.Orientation != src.Orientation) return null; int imageSize = src.Width * src.Height; //Lumb* dstPointer = (Lumb*)dst.Pixels.ToPointer(); //BGRb* srcPointer = (BGRb*)src.Pixels.ToPointer(); for (int row = 0; row < src.Height; row++) for (int column =0; column < src.Width; column++) { dst.SetColor(column, row, src.GetColor(column, row)); //*dstPointer = new Lumb(NTSCGray.ToLuminance(*srcPointer)); //dstPointer++; //srcPointer++; } //for (int row = 0; row < src.Height; row++) // for (int column = 0; column < src.Width; column++) // { // BGRb srcPixel = srcPointer[src.CalculateOffset(column, row)]; // byte lum = NTSCGray.ToLuminance(srcPointer[src.CalculateOffset(column, row)]); // dstPointer[dst.CalculateOffset(column, row)] = new Lumb(lum); // } return dst; }
public PLCView(string name, string heading, int x, int y, int width, int height) : base(name, x, y, width, height) { //this.GraphicsUnit = GraphicsUnit.Inch; fTeamLogo = new TextBox("Team Logo","Tahoma",14,GDIFont.FontStyle.Regular,0,0,160,60,RGBColor.Black); fLegend = null; fCS = new PLCColorScheme(); //fTransitionAnimator = new CrossFade(); fDataBinder = null; fBackingPixelBuffer = new GDIDIBSection(width, height); fBackingGraphics = fBackingPixelBuffer.GraphPort; //fBackingGraphics.PageUnit = GraphicsUnit.Inch; fHeading = heading; // These are the set of virtual calls // That any subclasser will implement AddMasterHeading(); AddPhaseArrows(); AddPhaseHeadings(); AddStageHeadings(); AddDeliveryContainers(); AddImages(); AddLegend(); AddTeamLogo(); //DrawSelf(fBackingGraphics); }
public Cover(string name, GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration, int direction) : base(name, frame, dstPixelBuffer, srcPixelBuffer, duration) { fDirection = direction; }
public SketchWindow(int width, int height) :base() { InitializeComponent(); fBlackPen = new GDIPen(RGBColor.Black); this.Size = new System.Drawing.Size(width, height); this.Text = "Sketcher"; this.AllowDrop = true; fPointList = new List<Point>(); // Create the backing buffer to retain the image // Make it bigger than any likely displays backingBuffer = GDIDIBSection.Create(1600, 1200); GDIContext bufferContext = GDIContext.CreateForBitmap(backingBuffer); bufferContext.ClearToWhite(); fBackingGraphPort = new GDIRenderer(bufferContext); fRetainedGraphPort = new GraphPortDelegate(); fRetainedGraphPort.AddGraphPort(fBackingGraphPort); fRetainedGraphPort.AddGraphPort(GraphPort); CreateSession(); }
public GraphPortChunkDecoder(GDIDIBSection pixMap, PayloadChannel channel) { fGrayImage = new PixelArray<Lumb>(pixMap.Width, pixMap.Height); fChannel = channel; if (fChannel != null) { fChannel.FrameReceivedEvent += FrameReceived; } fPixMap = pixMap; }
public ImageTransition(string name, Rectangle frame, GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, double duration) { fTimer = new NewTOAPIA.Kernel.PrecisionTimer(); fDestinationPixelBuffer = dstPixelBuffer; fSourcePixelBuffer = srcPixelBuffer; fDuration = duration; fGraphPort = null; // Do this last because others properties may need to be // setup first. Frame = frame; DestinationPixelBuffer = fDestinationPixelBuffer; SourcePixelBuffer = fSourcePixelBuffer; }
public ReceivingTexture(GraphicsInterface gi, int width, int height) { // Create the backing buffer to retain the image backingBuffer = new GDIDIBSection(width, height); backingBuffer.DeviceContext.ClearToBlack(); fDynamicTexture = new DynamicTexture(gi, width, height, 3); // 3. Setup the chunk decoder so we can receive new images // when they come in //fChunkDecoder = new GraphPortChunkDecoder(backingBuffer); fChunkDecoder = new GraphPortChunkDecoder(backingBuffer, null); fChunkDecoder.PixBltPixelBuffer24Handler += this.PixBltPixelBuffer24; fChunkDecoder.PixBltLumbHandler += this.PixBltLum24; }
/// <summary> /// Copy from a Luminance image to the BGRb pixel buffer. /// </summary> /// <param name="dst">The destination of the copy.</param> /// <param name="src">The source of the copy.</param> public static GDIDIBSection Copy(GDIDIBSection dst, PixelArray<Lumb> src) { //Lumb* srcPointer = (Lumb*)src.Pixels.ToPointer(); //BGRb* dstPointer = (BGRb*)dst.Pixels.ToPointer(); for (int row = 0; row < src.Height; row++) for (int column = 0; column < src.Width; column++) { dst.SetColor(column, row, src.GetColor(column, row)); //Lumb lumPixel = srcPointer[src.CalculateOffset(column, row)]; //byte lum = lumPixel.Lum; //dstPointer[dst.Accessor.CalculateOffset(column, row)] = new BGRb(lum, lum, lum); } return dst; }
void DoFlyIn(ITPhaseControl control, int steps) { // Create a pixmap to represent the control to be animated GDIDIBSection srcPixelBuffer = new GDIDIBSection((int)(control.Frame.Width), (int)(control.Frame.Height)); IGraphPort srcGraphics = srcPixelBuffer.GraphPort; srcPixelBuffer.DeviceContext.ClearToWhite(); // Draw the control into its bitmap DrawEvent sde = new DrawEvent(srcGraphics, Frame); control.OnDraw(sde); srcGraphics.Flush(); // Get the current image of what's being displayed GDIDIBSection dstPixelBuffer = this.BackingImage; IGraphPort dstGraphics = dstPixelBuffer.GraphPort; dstPixelBuffer.DeviceContext.ClearToWhite(); DrawEvent dde = new DrawEvent(dstGraphics, Frame); this.Draw(dde); // At this point we have two bitmaps that hold the images of the // background, and the graphic that will fly in. // Get a hold of our window's graphics port IGraphPort grfx = Window.ClientAreaGraphPort; // Draw the current destination image into the graphport grfx.PixBlt(dstPixelBuffer, 0, 0); Rectangle startFrame = new Rectangle(0, (int)(control.Frame.Top), (int)(control.Frame.Width), (int)(control.Frame.Height)); //Rectangle startFrame = new Rectangle(0, 0, (int)(control.Frame.Width), (int)(control.Frame.Height)); Rectangle endFrame = new Rectangle((control.Frame.Left), (control.Frame.Top), (control.Frame.Width), (control.Frame.Height)); FlyIn transition = new FlyIn(startFrame, endFrame, steps); transition.SourcePixelBuffer = srcPixelBuffer; transition.DestinationPixelBuffer = dstPixelBuffer; transition.Run(grfx); //FlyAGraphic(grfx, srcPixelBuffer, startFrame, dstPixelBuffer, endFrame, steps); // Cleanup srcPixelBuffer.Dispose(); }
public SketchView(MultiSession session, int width, int height) { fSession = session; // Create the backing buffer to retain the image backingBuffer = GDIDIBSection.Create(width, height); GDIContext bufferContext = GDIContext.CreateForBitmap(backingBuffer); bufferContext.ClearToWhite(); fBackingGraphPort = new GDIRenderer(bufferContext); //fBackingGraphPort.ClearToWhite(); // Add the channel for graphics commands fSketchChannel = fSession.CreateChannel(PayloadType.Whiteboard); fChunkDecoder = new GraphPortChunkDecoder(); fChunkDecoder.AddGraphPort(fBackingGraphPort); fSketchChannel.FrameReceivedEvent += new RtpStream.FrameReceivedEventHandler(GDICommandReceived); }
public TwoPartTransition(string name, GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration, int direction) : base(name, frame, dstPixelBuffer, srcPixelBuffer, duration) { fDirection = direction; fRevealed = 0; switch (direction) { case RIGHT: case LEFT: fDistance = frame.Width; break; case UP: case DOWN: fDistance = frame.Height; break; } }
public Stretch(string name, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration, int direction) : base(name, frame, null, srcPixelBuffer, duration) { // Calculate the increment in OnReset because it depends on the direction // And the direction will not have been set yet. fDirection = direction; switch (fDirection) { case RIGHT: case LEFT: fDistance = Frame.Width; break; case UP: case DOWN: fDistance = Frame.Height; break; } }
GraphPortChunkEncoder fCommandDispatcher; // Used to do PixBlt to the net #endregion public DesktopCapture(ConferenceAttendee attendee) { fAttendee = attendee; fContext = GDIContext.CreateForDefaultDisplay(); //fCommandDispatcher = new GraphPortChunkEncoder(attendee); int width = 800; int height = 600; fResolution = new Resolution(width, height); fScreenImage = new GDIDIBSection(width, height); fGrayImage = new PixelArray<Lumb>(width, height, fScreenImage.Orientation, new Lumb()); // Start the thread that will take snapshots of the screen fGlobalTimer = new PrecisionTimer(); fFrameRate = 10; // Frames per second fSnapperRunning = true; fSnapperThread = new Thread(RunSnaps); // WAA //fSnapperThread.Start(); }
void SnapClientArea() { Rectangle cRect = new Rectangle(new Point(0, 0), new Size(fResolution.Columns, fResolution.Rows)); // If we have resized since last picture, then // resize the capture buffer before taking // the next snapshot. if (fNeedsResize) { fScreenImage = new GDIDIBSection(cRect.Width, cRect.Height); fGrayImage = new PixelArray<Lumb>(cRect.Width, cRect.Height, fScreenImage.Orientation, new Lumb()); fNeedsResize = false; } // Now we actually take the snapshot. // We pass in the client area, based in screen coordinates // and the PixelBuffer object to capture into. SnapAPicture(new Rectangle(0, 0, fScreenImage.Width, fScreenImage.Height), fScreenImage); }
public virtual void PixBlt(int x, int y, GDIDIBSection pixmap) { TOAPI.Types.BITMAPINFO bmi = new TOAPI.Types.BITMAPINFO(); bmi.Init(); bmi.bmiHeader.biBitCount = (ushort)pixmap.BitsPerPixel; bmi.bmiHeader.biWidth = pixmap.Width; bmi.bmiHeader.biHeight = pixmap.Height; bmi.bmiHeader.biSizeImage = (uint)(Math.Abs(pixmap.BytesPerRow) * Math.Abs(pixmap.Height)); bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biClrImportant = 0; bmi.bmiHeader.biClrUsed = 0; bmi.bmiHeader.biCompression = 0; //int result = GDI32.StretchDIBits(fDeviceContext, x, y, pixmap.Width, pixmap.Height, // 0, 0, pixmap.Width, pixmap.Height, // pixmap.Pixels, ref bmi, // GDI32.DIB_RGB_COLORS, (uint)TernaryRasterOps.SRCCOPY); fDeviceContext.PixelBlt(new System.Drawing.Rectangle(0, 0, pixmap.Width, pixmap.Height), new System.Drawing.Rectangle(x, y, pixmap.Width, pixmap.Height), pixmap.Pixels, pixmap.BitCount); }
public WipeLeft(GDIDIBSection dstBitmap, GDIDIBSection srcBitmap, Rectangle frame, double steps) : base("WipeLeft", dstBitmap, srcBitmap, frame, steps, TwoPartTransition.LEFT) { }
public CoverDown(GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("CoverDown", dstPixelBuffer, srcPixelBuffer, frame, duration, TwoPartTransition.DOWN) { }
public StretchUp(GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("StretchUp", srcPixelBuffer, frame, duration, Stretch.UP) { }
public StretchDown(GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("StretchDown", srcPixelBuffer, frame, duration, Stretch.DOWN) { }
public StretchRight(GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("StretchRight", srcPixelBuffer, frame, duration, Stretch.RIGHT) { }
public StretchLeft(GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("StretchLeft", srcPixelBuffer, frame, duration, Stretch.LEFT) { }
void FlyAGraphic(IGraphPort graphPort, GDIDIBSection srcPixelBuffer, Rectangle startFrame, GDIDIBSection dstPixelBuffer, Rectangle endFrame, int steps) { double xIncrement = (float)(endFrame.X - startFrame.X) / steps; double yIncrement = (float)(endFrame.Y - startFrame.Y) / steps; Rectangle lastFrame = startFrame; int startX = startFrame.X; int startY = startFrame.Y; int x; int y; for (int i = 0; i < steps; i++) { // Draw a section of the destination pixel buffer to // cover where the graphic was sitting before it draws // itself in the new location. if (i > 0) { graphPort.AlphaBlend(lastFrame.X, lastFrame.Y, srcPixelBuffer.Width, srcPixelBuffer.Height, dstPixelBuffer, lastFrame.X, lastFrame.Y, srcPixelBuffer.Width, srcPixelBuffer.Height, 255); } x = (int)Math.Floor((double)startX + (i * xIncrement) + 0.5); y = (int)Math.Floor((double)startY + (i * yIncrement) + 0.5); //aGraphic.MoveTo(x, y); //DrawEvent devent = new DrawEvent(graphPort, Frame); //aGraphic.Draw(devent); graphPort.PixBlt(srcPixelBuffer, x, y); //graphPort.AlphaBlend(x, y, srcPixelBuffer.Width, srcPixelBuffer.Height, srcPixelBuffer, // 0, 0, srcPixelBuffer.Width, srcPixelBuffer.Height, 127); lastFrame = new Rectangle(x, y, srcPixelBuffer.Width, srcPixelBuffer.Height); } //aGraphic.MoveTo(endFrame.X, endFrame.Y); graphPort.PixBlt(srcPixelBuffer, endFrame.X, endFrame.Y); }
public WipeDown(GDIDIBSection dstBitmap, GDIDIBSection srcBitmap, Rectangle frame, double steps) : base("WipeDown", dstBitmap, srcBitmap, frame, steps, TwoPartTransition.DOWN) { }
public virtual void ReceiveChunk(BufferChunk aRecord) { // First read out the record type int recordType = aRecord.NextInt32(); // Then deserialize the rest from there switch (recordType) { //case (int)UICommands.PixBlt: // { // // Get the X, Y // int x = aRecord.NextInt32(); // int y = aRecord.NextInt32(); // // get the length of the image bytes buffer // int dataSize = aRecord.NextInt32(); // byte[] imageBytes = (byte[])aRecord; // // Create a memory stream from the imageBytes // MemoryStream ms = new MemoryStream(imageBytes, false); // // Create a pixelArray from the stream // Bitmap bm = (Bitmap)Bitmap.FromStream(ms); // PixelArray<BGRAb> pixMap = PixelBufferHelper.CreatePixelArrayFromBitmap(bm); // // And finally, call the PixBlt function // PixBltBGRAb(pixMap, x, y); // } // break; case (int)UICommands.PixBltRLE: { // Get the X, Y int x = aRecord.NextInt32(); int y = aRecord.NextInt32(); int width = aRecord.NextInt32(); int height = aRecord.NextInt32(); // get the length of the image bytes buffer int dataSize = aRecord.NextInt32(); byte[] imageBytes = (byte[])aRecord; // Create a memory stream from the imageBytes MemoryStream ms = new MemoryStream(imageBytes, false); // Create a pixelArray from the stream if ((width != fPixMap.Width) || (height != fPixMap.Height)) fPixMap = new GDIDIBSection(width, height); TargaRunLengthCodec rlc = new TargaRunLengthCodec(); PixelAccessorBGRb accessor = new PixelAccessorBGRb(fPixMap.Width, fPixMap.Height, fPixMap.Orientation, fPixMap.Pixels, fPixMap.BytesPerRow); rlc.Decode(ms, accessor); // And finally, call the local PixBlt function PixBltPixelBuffer24(fPixMap, x, y); } break; case (int)UICommands.PixBltLuminance: { // Get the X, Y int x = aRecord.NextInt32(); int y = aRecord.NextInt32(); int width = aRecord.NextInt32(); int height = aRecord.NextInt32(); // get the length of the image bytes buffer int dataSize = aRecord.NextInt32(); byte[] imageBytes = (byte[])aRecord; // Create a memory stream from the imageBytes MemoryStream ms = new MemoryStream(imageBytes, false); // Create a pixelArray from the stream if ((width != fGrayImage.Width) || (height != fGrayImage.Height)) fGrayImage = new PixelArray<Lumb>(width, height); TargaLuminanceRLE rlc = new TargaLuminanceRLE(); rlc.Decode(ms, fGrayImage); // And finally, call the local PixBlt function PixBltLumb(fGrayImage, x, y); } break; case (int)UICommands.Showcursor: { ShowCursor(); } break; case (int)UICommands.HideCursor: { HideCursor(); } break; case (int)UICommands.MoveCursor: { int x = aRecord.NextInt32(); int y = aRecord.NextInt32(); MoveCursor(x, y); } break; default: //if (CommandReceived != null) // CommandReceived(aRecord); break; } }
public virtual void PixBltPixelBuffer24(GDIDIBSection pixMap, int x, int y) { if (null != PixBltPixelBuffer24Handler) PixBltPixelBuffer24Handler(pixMap, x, y); }
public virtual void PixBltPixelBuffer24(GDIDIBSection pixMap, int x, int y) { PixelAccessorBGRb accessor = new PixelAccessorBGRb(pixMap.Width, pixMap.Height, pixMap.Orientation, pixMap.Pixels, pixMap.Width * 3); fDynamicTexture.UpdateImage(accessor); }
public CoverLeft(GDIDIBSection dstPixelBuffer, GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("CoverLeft", dstPixelBuffer, srcPixelBuffer, frame, duration, TwoPartTransition.LEFT) { }
public SplitVerticalOut(GDIDIBSection srcPixelBuffer, Rectangle frame, double duration) : base("SplitVerticalOut", frame, null, srcPixelBuffer, duration) { }