question

Scout-9714 avatar image
0 Votes"
Scout-9714 asked Scout-1150 edited

How can Small Basic access pictures under Q&A

How can a Small Basic program to be published access images.
So far it was possible via the forum link (msdn) of the picture.
Can this also be carried out under Q&A (docs) or is the JPG file with 1.8MB not permitted?

 'cow = Shapes.AddImage("https://docs.microsoft.com/answers/storage/attachments/54924--igp0075-mini.jpg")
      
   cow = Shapes.AddImage("https://social.msdn.microsoft.com/Forums/getfile/1353849")


small-basic
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Even a small GIF file cannot be accessed.

54955-crazyhorse.jpg


0 Votes 0 ·
crazyhorse.jpg (25.2 KiB)

Is there another way or location to load program resources?

0 Votes 0 ·
NonkiTakahashi avatar image
1 Vote"
NonkiTakahashi answered

Hi @scout-9714, I guess Small Basic can't access SSL/TLS. If you have your own http site, that will be fine. If you are using Small Basic Desktop and LitDev Extension, LDNetwork.DownloadFile() may download some https files but your three images have still security problems. Thanks.

url = "https://docs.microsoft.com/answers/storage/attachments/54924--igp0075-mini.jpg"
url = "https://docs.microsoft.com/answers/storage/attachments/54954-wn54.gif"
url = "https://docs.microsoft.com/answers/storage/attachments/54955-crazyhorse.jpg"
url = "https://social.msdn.microsoft.com/Forums/getfile/1353849"
path = Program.Directory + "\" + LDFile.GetFile(url) + "." + LDFile.GetExtension(url)
LDNetwork.DownloadFile(path, url)
GraphicsWindow.DrawImage(path, 10, 10)



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Scout-1150 avatar image
0 Votes"
Scout-1150 answered Scout-1150 edited

Thanks for the infos about SSL/TLS @NonkiTakahashi

Here are some attempts to load image data with SmallBasic:

' MSDN getfile resource : access possible
Size = LDNetwork.DownloadFile(Program.Directory + "test","https://social.msdn.microsoft.com/Forums/getfile/1353849")
TextWindow.WriteLine("Size=" + Size)

' Q & A no access
Size1 = LDNetwork.DownloadFile(Program.Directory + "test1","https://docs.microsoft.com/answers/storage/attachments/54955-crazyhorse.jpg")
TextWindow.WriteLine("Size1=" + Size1)

' Flickr Random Picture
url = Flickr.GetPictureOfMoment()
TextWindow.WriteLine("Flickr-URL=" + url)
Size2 = LDNetwork.DownloadFile(Program.Directory + "test2", url)
TextWindow.WriteLine("Size2=" + Size2)

' Flickr Random Picture with Tags : unique Tag necessary
url = Flickr.GetRandomPicture("Pictogram")
TextWindow.WriteLine("Flickr-URL=" + url)
Size3 = LDNetwork.DownloadFile(Program.Directory + "test3", url)
TextWindow.WriteLine("Size3=" + Size3)

' Q & A no access
Size4 = LDNetwork.DownloadFile(Program.Directory + "test4", "https://docs.microsoft.com/answers/storage/attachments/58517-marionette.png")
TextWindow.WriteLine("Size4=" + Size4)

' MSDN getfile resources : million of images but 99% screenshots
For nxt = 1353777 to 1353888 Step 1
Size5 = LDNetwork.DownloadFile(Program.Directory + "test"+nxt,"https://social.msdn.microsoft.com/Forums/getfile/" + nxt)
TextWindow.WriteLine("Size"+nxt+"=" + Size5)
Im1 = ImageList.LoadImage(Program.Directory + "test"+nxt)
GraphicsWindow.DrawImage(Im1,0,0)
EndFor


The pearls (patterns and small objects) still have to be fished out of the MSDN resources.

It might be easier with a public ICON library.

Alternatively, the objects can also be created with the integrated drawing tools:

  • SmallBasic ................................. Simple 2D

  • SmallBasic+litdev(LD) .......... Nice 2D + 3D

As in the example of the current challenge: challenge-of-the-month-january-2021.html





Update May 2021: The Small Basic Command "Flickr" no longer works !
98756-no-flickr.png




no-flickr.png (24.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Scout-1150 avatar image
0 Votes"
Scout-1150 answered Scout-1150 commented

It begins in one hour !
Unfortunately, SmallBasic cannot download the picture as a background. 69773-icon-confused.gif

69706-3-ellipse-map-v3-partialannotation.png

tmpFile = File.GetTemporaryFilePath()
'imageURL = "https://mars.nasa.gov/system/downloadable_items/45663_E_dsn-madrid.jpg"
imageURL = "https://mars.nasa.gov/imgs/mars2020/jezero-overview.jpg"
LDNetwork.DownloadFile(tmpFile,imageURL)
P = ImageList.LoadImage(tmpFile)
'PF = Network.DownloadFile("https://mars.nasa.gov/system/downloadable_items/45532_3-Ellipse_Map_v3_PartialAnnotation.png")
'PF = Network.GetWebPageContents("https://mars.nasa.gov/system/downloadable_items/45532_3-Ellipse_Map_v3_PartialAnnotation.png")
'P = ImageList.LoadImage("https://mars.nasa.gov/system/downloadable_items/45663_E_dsn-madrid.jpg")
'P = ImageList.LoadImage("https://mars.nasa.gov/system/downloadable_items/45468_LandingSitesContextMap_featPerseverance.jpg")
'P = ImageList.LoadImage("https://mars.nasa.gov/system/downloadable_items/45532_3-Ellipse_Map_v3_PartialAnnotation.png")
'P = ImageList.LoadImage("http://litdev.co.uk/game_images/rubic.png")
Height = ImageList.GetHeightOfImage(P)
TextWindow.WriteLine(" Imagelist: " + P)
TextWindow.WriteLine(" Height: " + Height)
GraphicsWindow.DrawImage(P,0,0)



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Scout-1150 avatar image
0 Votes"
Scout-1150 answered

With the help of the LitDev extension and the LDImage.GetPixel () and .SetPixel () methods, image data can also be written in string arrays.
The array can be saved as a SmallBasic file and thus integrated into SmallBasic programs.
These images can thus also be made available for further use with the publish / import function.
If the picture is saved directly in the SmallBasic program, the program code has to be subtracted from the 64kB limit.
With 9 bytes per pixel, however, the image size is very limited with approx. 7000 pixels or approx. 80x80 pixels.

Here is a small demo with the import ID PSD845

70371-bigpic2.png



bigpic2.png (1.7 MiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Scout-1150 avatar image
0 Votes"
Scout-1150 answered

The method of the high resolution small picture within the SmallBasic program has its limits.
When expanding to larger formats, it becomes either smooth (zoom) or pixelated.
ProgramID: PWL034
72566-zoomversusdoublepixel.png
For the window background or for larger objects, I recommend uploading the picture to Q&A. The user cannot download it directly from SmallBasic, but it can be downloaded to the program directory and loaded as a file.

So the method via array remains only for smaller shapes or with less color depth.

The future for SmallBasic graphics is more with shape editors (Nonki, Litdev) and for backgrounds CF or similar.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.