Example #1
0
        private void ChangeProfilePictureTwitter()
        {
            if (pictureChanged)
                return;

            pictureReset = false;
            pictureChanged = true;
            var profilePicStream = twitterUsername.GetProfileImageStream();
            var tempStream = new MemoryStream();
            profilePicStream.CopyTo(tempStream);
            byte[] profilePic = new byte[tempStream.Length];
            Rectangle portionOfImage = new Rectangle(0, 0, 400, 400);

            profilePicStream.Read(profilePic, 0, (int)tempStream.Length);
            Image currentProfilePicture = Image.FromFile( "profilepicture.jpg");
            Image liveUpdateTemplate = Image.FromFile("CoreTwitterBot/CoreTwitterBot/redcircle.png");
            using (Graphics grfx = Graphics.FromImage(currentProfilePicture))
            {
                grfx.DrawImage(liveUpdateTemplate, portionOfImage);
            }
            System.IO.MemoryStream newStream = new System.IO.MemoryStream();
            currentProfilePicture.Save(newStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] xByte = ReadToEnd(newStream);
            Account.UpdateProfileImage(xByte);
        }