Hack Forums
[.NET] Image not showing - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Image not showing (/showthread.php?tid=5965757)

Pages: Pages 1 2


Image not showing - System[X] - May 1, 2019

Ok, so if i go here "https://hackforums.net/uploads/avatars/avatar_806990.png" i see my profile image right

Now then when i add that url to anything on my form that accepts the url as a string it does not show.

It also does not show in a picture box unless i download it by bytes but i need it as a url string like above.

Any ideas ?

Thanks


RE: Image not showing - HFDone - May 1, 2019

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.picturebox.imagelocation?view=netframework-4.8


RE: Image not showing - realsunjester - May 1, 2019

(May 1, 2019 01:25 PM)System[X] Wrote:  Ok, so if i go here "https://hackforums.net/uploads/avatars/avatar_806990.png" i see my profile image right

Now then when i add that url to anything on my form that accepts the url as a string it does not show.

It also does not show in a picture box unless i download it by bytes but i need it as a url string like above.

Any ideas ?

Thanks

works for me

[Image: ekk48yq.png]

maybe it's your connection.


RE: Image not showing - System[X] - May 1, 2019

(May 1, 2019 01:35 PM)realsunjester Wrote:  works for me

[Image: ekk48yq.png]

maybe it's your connection.

Read my post again, it works fine in my browser, just not in vb.net, does not show

Thanks


RE: Image not showing - realsunjester - May 1, 2019

(May 1, 2019 01:36 PM)System[X] Wrote:  Read my post again, it works fine in my browser, just not in vb.net, does not show

Thanks

there isn't much difference in loading it, so it must be your code, show us the code.


RE: Image not showing - System[X] - May 1, 2019

(May 1, 2019 01:48 PM)realsunjester Wrote:  there isn't much difference in loading it, so it must be your code, show us the code.

Nothing todo with the code, just go try it, try and load the url in a picturebox as the url string.

Thanks


RE: Image not showing - TigerBark - May 1, 2019

(May 1, 2019 02:35 PM)System[X] Wrote:  Nothing todo with the code, just go try it, try and load the url in a picturebox as the url string.

Thanks

dont waste his time retard. he is trying to help you and yet you dont do what he asks..

stupid fuck


RE: Image not showing - realsunjester - May 1, 2019

(May 1, 2019 02:35 PM)System[X] Wrote:  Nothing todo with the code, just go try it, try and load the url in a picturebox as the url string.

Thanks

yes. it has everything to do with the code. are you using the load method? imagelocation? are you reading it with webrequest into a bitmap object?


RE: Image not showing - System[X] - May 1, 2019

(May 1, 2019 02:37 PM)TigerBark Wrote:  dont waste his time retard. he is trying to help you and yet you dont do what he asks..

stupid fuck

Your the retard kid. I've been coding for many years and know around 13 different coding languages.

If i say there is nothing wrong with 1 small line of code to simply load an image from a url then that's true.

The issue lies with the url, it must be as other images load just fine.

Thanks for your useless comment. Have a good day.

(May 1, 2019 02:43 PM)realsunjester Wrote:  yes. it has everything to do with the code. are you using the load method? imagelocation? are you reading it with webrequest into a bitmap object?

webrequest into a bitmap object, i can get it to load converting it to bytes as i mentioned in the first post but only by using the credts for HF api and header, works fine.

but as you know you can not convert an object like that to a string.

Code
Dim MyWebClient As New System.Net.WebClient

        MyWebClient.Credentials = New NetworkCredential("My HF API Key, "")
        MyWebClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201")

        Dim Avatar_ImageInBytes() As Byte = MyWebClient.DownloadData("https://hackforums.net/uploads/avatars/avatar_806990.png")
        Dim Avatar_ImageStream As New IO.MemoryStream(Avatar_ImageInBytes)

        Form1.PictureBox1.Image = New System.Drawing.Bitmap(Avatar_ImageStream)

Thanks


RE: Image not showing - realsunjester - May 1, 2019

im going to assume it has something to do with cloudflare, but if you cant get it to work, why load the image from hf?


RE: Image not showing - System[X] - May 1, 2019

(May 1, 2019 02:53 PM)realsunjester Wrote:  im going to assume it has something to do with cloudflare, but if you cant get it to work, why load the image from hf?

Maybe cloudflare yeah.

So you suggest to download the image and use it that way ? You see i have a discord bot and going to add HF api features to it. it will return uerinfo from the UID and this includes the avatar.

A picture box was me trying to figure out a way.

This is why I need it as a string not an object or bytes.

I suppose i could download use then delete but that takes a second longer and with it being a discord bot i can not have anything that would slow it down. 1 second is not much, x by 10 users thats 10 seconds.

Thanks


RE: Image not showing - realsunjester - May 1, 2019

(May 1, 2019 03:14 PM)System[X] Wrote:  Maybe cloudflare yeah.

So you suggest to download the image and use it that way ? You see i have a discord bot and going to add HF api features to it. it will return uerinfo from the UID and this includes the avatar.

A picture box was me trying to figure out a way.

This is why I need it as a string not an object or bytes.

I suppose i could download use then delete but that takes a second longer and with it being a discord bot i can not have anything that would slow it down. 1 second is not much, x by 10 users thats 10 seconds.

Thanks

what if you stored the obj as a tmp file or a base64 obj, but ive been drinking so maybe not


RE: Image not showing - 0xDEAD10CC - May 1, 2019

(May 1, 2019 02:47 PM)System[X] Wrote:  Your the retard kid. I've been coding for many years and know around 13 different coding languages.

If i say there is nothing wrong with 1 small line of code to simply load an image from a url then that's true.

The issue lies with the url, it must be as other images load just fine.

Thanks for your useless comment. Have a good day.


webrequest into a bitmap object, i can get it to load converting it to bytes as i mentioned in the first post but only by using the credts for HF api and header, works fine.

but as you know you can not convert an object like that to a string.

Code
Dim MyWebClient As New System.Net.WebClient

        MyWebClient.Credentials = New NetworkCredential("My HF API Key, "")
        MyWebClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201")

        Dim Avatar_ImageInBytes() As Byte = MyWebClient.DownloadData("https://hackforums.net/uploads/avatars/avatar_806990.png")
        Dim Avatar_ImageStream As New IO.MemoryStream(Avatar_ImageInBytes)

        Form1.PictureBox1.Image = New System.Drawing.Bitmap(Avatar_ImageStream)

Thanks

Coding for many years but you still don't know about Dispose() or HttpClient? 13 languages is nothing to boast about if you don't know at least a few of them very well.. ❓

Not sure what you would need an API key for here... You're just cluelessly grasping at straws there -- And if you knew how to use the debugger you could also verify a cloudflare issue.

This is working entirely fine for me:
Code
using (var client = new HttpClient())
{
    client.DefaultRequestHeaders.Add("User-Agent", @"Dummy");
    var stream = await client.GetStreamAsync("https://hackforums.net/uploads/avatars/avatar_806990.png").ConfigureAwait(false);
    using (var image = Image.FromStream(stream))
        image.Save("out.png", ImageFormat.Png);
}

This is about as basic as it gets before further error handling is added.


RE: Image not showing - System[X] - May 2, 2019

(May 1, 2019 11:52 PM)0xDEAD10CC Wrote:  Coding for many years but you still don't know about Dispose() or HttpClient? 13 languages is nothing to boast about if you don't know at least a few of them very well.. ❓

Not sure what you would need an API key for here... You're just cluelessly grasping at straws there -- And if you knew how to use the debugger you could also verify a cloudflare issue.

This is working entirely fine for me:
Code
using (var client = new HttpClient())
{
   client.DefaultRequestHeaders.Add("User-Agent", @"Dummy");
   var stream = await client.GetStreamAsync("https://hackforums.net/uploads/avatars/avatar_806990.png").ConfigureAwait(false);
   using (var image = Image.FromStream(stream))
       image.Save("out.png", ImageFormat.Png);
}

This is about as basic as it gets before further error handling is added.

Yes many years and many old coders here know me. Yes i did not dispose but the code i posted was to test with, not actual code i'm using.

Also did i say i had an issue with downloading/saving the image. The issue is displaying it from the url.

Thanks


RE: Image not showing - HFDone - May 2, 2019

i gave you the answer with link in the first reply why you didnt check it