Exemplo n.º 1
0
        /**压缩函数*/
        private void bitmapZipToBlockingQueue()
        {
            while (isSendPic)
            {
                try
                {
                    manulResetEvent.WaitOne();
                }
                catch (ThreadInterruptedException ex)
                {
                    manulResetEvent.Reset();
                    Console.WriteLine(ex.Message);
                    ErrorInfo.getErrorWriter().writeErrorMassageToFile(ex.Message);
                    return;
                }
                while (picFlag)
                {
                    DifferentBitmapWithCursor differentBitmapWithCursor = screenCopyDifQueue.Dequeue();
                    if (differentBitmapWithCursor != null)
                    {
                        // Console.WriteLine("compressThread***********");
                        try
                        {
                            SendPacket sendPacket = new SendPacket();
                            sendPacket.setPacketType(SendPacket.PacketType.BITMAP);
                            sendPacket.setBitmapType(differentBitmapWithCursor.getBitmapType());
                            sendPacket.setCursorPoint(differentBitmapWithCursor.getCursorPoint());
                            sendPacket.setDifPointsList(differentBitmapWithCursor.getDifPointsList());
                            byte[] bmpBytes = JpegZip.jpegAndZip(differentBitmapWithCursor.getDifBitmap());

                            sendPacket.setBitByts(bmpBytes);
                            sendPacket.setBitmapBytesLength(bmpBytes.Length);
                            sendPacketQueue.Enqueue(sendPacket);
                            textBoxSDQ.Text = sendPacketQueue.getQueueSize() + "";
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            ErrorInfo.getErrorWriter().writeErrorMassageToFile(ex.Message);
                            return;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /**
         * 控制扫描块的大小,块越大,扫描速度越快,但是发送的数据量就越大;
         * 块越小,扫描速度就越慢,但是发送的数据量就小;
         * 局域网一般100*100
         * 广域网一般40*40 或 20*20
         * 是否需要协商块的大小????进一步实验决定。默认的事30*30,
         * 现在已经完全由server决定,client不需要blocksize
         **/
        //private static Size bitCmpSize = new Size(30, 30);
        /**图形恢复函数*/
        private void recoverBitmapFun()
        {
            while (isConnect)
            {
                try
                {
                    DifferentBitmapWithCursor difbitWithCur = deCompressDifQueue.Dequeue();
                    if (difbitWithCur != null)
                    {
                        RecPacket.PacketType packetType       = difbitWithCur.getPacketType();
                        BitmapWithCursor     bitmapWithCursor = new BitmapWithCursor();
                        bitmapWithCursor.setPacketType(packetType);
                        switch (packetType)
                        {
                        case RecPacket.PacketType.BITMAP:
                            RecPacket.BitmapType type        = difbitWithCur.getBitmapType();
                            ShortPoint           cursorpoint = difbitWithCur.getCursorPoint();
                            Bitmap          btm       = difbitWithCur.getDifBitmap();
                            List <ShortRec> difPoints = difbitWithCur.getDifPointsList();
                            switch (type)
                            {
                            case RecPacket.BitmapType.BLOCK:
                                //Stopwatch sw = new Stopwatch();
                                //sw.Start();
                                Bitmap recBitmap = RecoverBitmap.recoverScreenBitmap(difPoints, globalCompareBitmap, btm /*, bitCmpSize*/);
                                //sw.Stop();
                                //Console.WriteLine("client:"+sw.ElapsedMilliseconds+"ms");
                                bitmapWithCursor.setCursorPoint(cursorpoint);
                                bitmapWithCursor.setScreenBitmap(recBitmap);
                                globalCompareBitmap = (Bitmap)recBitmap.Clone();
                                /**放到显示队列*/
                                displayQueue.Enqueue(bitmapWithCursor);
                                break;

                            case RecPacket.BitmapType.COMPLETE:
                                updateKeyFrame(btm, cursorpoint);
                                break;

                            default:
                                break;
                            }
                            labeldispalyQueue.Text = "显示队列大小:" + displayQueue.getQueueSize() + "\r\n";
                            break;

                        case RecPacket.PacketType.TEXT:
                            bitmapWithCursor.setStringValue(difbitWithCur.getStringValue());
                            displayQueue.Enqueue(bitmapWithCursor);
                            labeldispalyQueue.Text = "显示队列大小:" + displayQueue.getQueueSize() + "\r\n";
                            break;

                        default:
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }