Exemple #1
0
            public static void ChangeCurrentPictureNew(ClientScreenShotData data, byte[] fileBytes, List <int> blocks, int widthResolution, int heightResolution)
            {
                if (blocks == null)
                {
                    return;
                }
                System.Drawing.Size rectSize = Utils.GetRectangleSize(widthResolution, heightResolution);
                int countHorizontalBlocks    = widthResolution / rectSize.Width;
                int countVerticalBlocks      = heightResolution / rectSize.Height;
                int pixelInBlock             = rectSize.Height * rectSize.Width * 3;
                int pixelInLine     = pixelInBlock * countHorizontalBlocks;
                int totalBlockCount = countHorizontalBlocks * countVerticalBlocks;
                int cnt             = 0;

                for (int b = 0; b < blocks.Count; b++)
                {
                    int blockFullLines     = blocks[b] / countHorizontalBlocks;
                    int blockInNotFullLine = blocks[b] % countHorizontalBlocks;
                    int startByte          = blockFullLines * pixelInLine + blockInNotFullLine * rectSize.Width * 3;

                    for (int i = startByte; i < startByte + rectSize.Height * widthResolution * 3 - 1; i += widthResolution * 3)
                    {
                        for (int j = 0; j < rectSize.Width * 3; j++)
                        {
                            try
                            {
                                data.colorPackage[i + j] = fileBytes[cnt];
                                cnt++;
                            }
                            catch (Exception ex)
                            { }
                        }
                    }
                }
            }
Exemple #2
0
 public static BitmapSource CreateNewImage(ClientScreenShotData shot)
 {
     try
     {
         int          bitsPerPixel  = ((int)137224 & 0xff00) >> 8;
         int          bytesPerPixel = (bitsPerPixel + 7) / 8;
         int          stride        = 4 * ((shot.widthResolution * bytesPerPixel + 3) / 4);
         BitmapSource img           = BitmapSource.Create(shot.widthResolution, shot.heightResolution, 96, 96, System.Windows.Media.PixelFormats.Bgr24, null, shot.colorPackage, stride);
         return(img);
     }
     catch (Exception ex)
     {
         return(CreateNewImage(shot));
     }
 }
Exemple #3
0
            public static List <int> getChanges(int widthResolution, int heightResolution, int blockPixelWidth, int blockPixelHeight,
                                                int widthCountOfBlocks, int heightCountOfBlocks, int totalCountOfBlocks, byte[] newPictureBuffer, ClientScreenShotData screenShotData)
            {
                List <int> arr          = new List <int>();
                int        pixelInBlock = blockPixelHeight * blockPixelWidth * 3;
                int        pixelInLine  = pixelInBlock * widthCountOfBlocks;

                for (int block = 0; block < totalCountOfBlocks; block++)
                {
                    int blockFullLines     = block / widthCountOfBlocks;
                    int blockInNotFullLine = block % widthCountOfBlocks;
                    int startByte          = blockFullLines * pixelInLine + blockInNotFullLine * blockPixelWidth * 3;

                    for (int i = startByte; i < startByte + blockPixelHeight * widthResolution * 3 - 1; i += widthResolution * 3)
                    {
                        for (int j = 0; j < blockPixelWidth * 3; j++)
                        {
                            if ((screenShotData.colorPackage[i + j] ^ newPictureBuffer[i + j]) != 0)
                            {
                                arr.Add(block);
                                goto nextStep;
                            }
                        }
                    }
                    nextStep :;
                }
                return(arr);
            }