示例#1
0
//export webRdpBitmapDecompress
func webRdpBitmapDecompress(context *C.rdpContext, bitmap *C.rdpBitmap, data *C.BYTE,
	width C.int, height C.int, bpp C.int, length C.int,
	compressed C.BOOL, codecId C.int) C.BOOL {
	log.Printf("compressed:%d bpp:%d", compressed, bpp)
	size := width * height * 4
	if bitmap.data != nil {
		C._aligned_free(unsafe.Pointer(bitmap.data))
	}
	bitmap.data = (*C.BYTE)(C._aligned_malloc(C.size_t(size), 16))
	if compressed != false {
		if bpp < 32 {
			C.freerdp_client_codecs_prepare(context.codecs, C.FREERDP_CODEC_INTERLEAVED)
			C.interleaved_decompress(context.codecs.interleaved, data, C.UINT32(length), bpp,
				&(bitmap.data), C.PIXEL_FORMAT_XRGB32, -1, 0, 0, width, height, C.getBYTEpalette(context))
		} else {
			C.freerdp_client_codecs_prepare(context.codecs, C.FREERDP_CODEC_PLANAR)
			status := C.planar_decompress(context.codecs.planar, data, C.UINT32(length),
				&(bitmap.data), C.PIXEL_FORMAT_XRGB32, -1, 0, 0, width, height, true)
			log.Printf("webRdpBitmapDecompress status::::::%d", status)
		}
	} else {
		C.freerdp_image_flip(data, bitmap.data, width, height, bpp)
	}
	bitmap.compressed = false
	bitmap.length = C.UINT32(size)
	bitmap.bpp = 32
	return true
}
示例#2
0
//export bitmapUpdate
func bitmapUpdate(rawContext *C.rdpContext, bitmap *C.BITMAP_UPDATE) {
	context := (*rdpContext)(unsafe.Pointer(rawContext))

	var bmd *C.BITMAP_DATA
	var i int

	for i = 0; i < int(bitmap.number); i++ {
		bmd = C.nextBitmapRectangle(bitmap, C.int(i))

		buf := new(bytes.Buffer)

		meta := bitmapUpdateMeta{
			WSOP_SC_BITMAP,                           // op
			uint32(bmd.destLeft),                     // x
			uint32(bmd.destTop),                      // y
			uint32(bmd.width),                        // w
			uint32(bmd.height),                       // h
			uint32(bmd.destRight - bmd.destLeft + 1), // dw
			uint32(bmd.destBottom - bmd.destTop + 1), // dh
			uint32(bmd.bitsPerPixel),                 // bpp
			uint32(bmd.compressed),                   // cf
			uint32(bmd.bitmapLength),                 // sz
		}
		if int(bmd.compressed) == 0 {
			C.freerdp_image_flip(bmd.bitmapDataStream, bmd.bitmapDataStream, C.int(bmd.width), C.int(bmd.height), C.int(bmd.bitsPerPixel))
		}

		binary.Write(buf, binary.LittleEndian, meta)

		// Unsafe copy bmd.bitmapLength bytes out of bmd.bitmapDataStream
		var bitmapDataStream []byte
		clen := int(bmd.bitmapLength)
		bitmapDataStream = (*[1 << 30]byte)(unsafe.Pointer(bmd.bitmapDataStream))[:clen]
		(*reflect.SliceHeader)(unsafe.Pointer(&bitmapDataStream)).Cap = clen
		binary.Write(buf, binary.LittleEndian, bitmapDataStream)

		sendBinary(context.sendq, buf)
	}
}