Displaying Twitter profile picture with tweet

Jan 26, 2014 at 7:49 PM
Trying to figure out how to display the tweet creators profile image with out actually downloading a .jpg

currently have it like this
            WebClient wc = new WebClient();
            byte[] bytes = wc.DownloadData(tweet.Creator.DownloadProfileImage(token));
            MemoryStream ms = new MemoryStream(bytes);
            System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
            uc.UserPicture = img;
But when it runs it gets the picture fine, but it saves it in the current directory.
Any way to display without downloading
Coordinator
Jan 27, 2014 at 10:02 AM
Hi,

Currently there is no way of doing this but I added a task for this feature.
Please subscribe to it to be notified when it will be released.

In the meantime please consider the cost of downloading the picture each time you run the application.

Regards,
Linvi
Jan 31, 2014 at 11:23 AM
Hi, superhaze421
i have solution for you.
first, get profile image url from(i'm using WPF application C#) :
string pathUrl=tweet.Creator.ProfileImageUrl; 
string pathUrlBig=pathUrl.Remove("_normal","");//use this string if you want real profile image
and then call this method:

loadImage(pathUrl); or loadImage(pathUrlBig);
        public void loadImage(string addrs = "https://pbs.twimg.com/profile_images/429211155605639168/S598ewWG_bigger.jpeg")
        {
            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(addrs, UriKind.RelativeOrAbsolute);
            bi.CacheOption = BitmapCacheOption.OnLoad;
            bi.EndInit();
            SecondForm.Img.Source = bi;
            //SecondForm is FORM object
            //Img is Image object that source will show profile image 
        }
This method will not save the image to current directory but load it directly when you connected to internet.

Tell me if this method work for you.. :)

Regards,
Isman Santoso
Coordinator
Jan 31, 2014 at 12:19 PM
Hi Isman,

Thank you for sharing this code :)
If you don't mind can I use it or at least part of it in Tweetinvi?

Regards,
Linvi
Jan 31, 2014 at 2:38 PM
Hi Linvi,

Of course you can. :)
i'm happy if my code could be useful.

Regards,
Isman Santoso
Coordinator
Jan 31, 2014 at 7:14 PM
Hi,

I have just added 2 ways to get the ProfileImage in the memory. This is available with the latest source code but has not yet been fully tested.
Stream GenerateProfileImageStream();
Bitmap GenerateProfileImageBitmap();
This should allow you to do any task you want with the memory.

Kind Regards,
Linvi
Feb 1, 2014 at 2:47 AM
Ok thanks for the help