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); // 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 BufferChunk EncodeBGRb(PixelAccessor<BGRb> accessor, int x, int y) { MemoryStream ms = new MemoryStream(); // 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; // 7. Finally, return the packet return chunk; }