Displaying pictures from the internet

N1c0_ds

Active Member
Licensed User
What would be the best way to display pictures from the internet?

I have GIF, JPG, BMP and PNG screenshots of various sizes (QVGA, SQVGA and VGA, mostly) that I'd like to display. There would be a thumbnail and when it's clicked it would display the full picture.

All the files are at an address specified in an SQL database. Any clue on how this could be done really quickly?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can download images with the HTTP library.
The door library is required if you want to create a new bitmap object from the data stream, without first saving the image to a file.
See the attached file.
B4X:
Sub Globals
    
End Sub

Sub App_Start
    Form1.Show
    WebResponse.New1
    obj.New1(False)
    objArray.New1(1)
    ShowImage("http://www.b4x.com/images/logo.bmp")
End Sub

Sub ShowImage (URL)
    WebRequest.New1(URL)
       WebResponse.Value = WebRequest.GetResponse 'Download the image
    objArray.SetObject(0,WebResponse.GetStream) 
    obj.CreateNew2("System.Drawing.Bitmap" & obj.System_Drawing,objArray.Value) 'Create a bitmap image from the
    'data stream.
    Form1.Image = obj.Value 'Assign the image to Form1.
End Sub
 

Attachments

  • 1.sbp
    806 bytes · Views: 318

Cableguy

Expert
Licensed User
Longtime User
The device does show the image but will not show transparet (ALPHA CHANNEL) collors and in some images simply error out.
 

N1c0_ds

Active Member
Licensed User
I'm trying to make thumbnails with the pictures but my code doesn't work

img is my Imageclass object (dzImage) used to get image dimensions and select the thumbnail size based on it. imge is a picture control.
B4X:
Sub Globals
  Dim Type(Width, Height) ImgSize
End Sub

Sub App_Start
img.New1
    Form1.Show
    WebResponse.New1
    obj.New1(False)
    objArray.New1(1)
    
    ShowImage("http://battellemedia.com/images/goog%20no%20count.jpg")
End Sub

Sub ShowImage (URL)

    WebRequest.New1(URL)
       WebResponse.Value = WebRequest.GetResponse 'Download the image
    objArray.SetObject(0,WebResponse.GetStream) 
    obj.CreateNew2("System.Drawing.Bitmap" & obj.System_Drawing,objArray.Value) 'Create a bitmap image from the
    'data stream.
    Img.ImageSize(obj.Value)
    Img.ZoomImage(obj.Value,20)
    Img.RotateImage(obj.Value,90)
    Imge.Image=obj.Value
End Sub

The image is shown but modifications never apply.
 
Top