Author Topic: Place kittens in your programs  (Read 4071 times)

0 Members and 1 Guest are viewing this topic.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Place kittens in your programs
« on: July 25, 2020, 02:02:38 pm »
Imagine, if you will, the image file you need for your program doesn't exist on the client's computer. Perhaps instead of an error for an invalid image handle you show them a fluffy kitten:

 
loadkitten.png


Code: QB64: [Select]
  1.  
  2. IF _FILEEXISTS("neededimage.jpg") = 0 THEN
  3.     a = LoadKitten("720", "480")
  4.     SCREEN a
  5.  
  6. FUNCTION LoadKitten (imagewidth AS STRING, imageheight AS STRING)
  7.     DIM URL AS STRING
  8.     DIM URLFile AS STRING
  9.     DIM kitten AS STRING
  10.     DIM a%
  11.     URLFile = "kitten.jpg"
  12.     URL = "http://placekitten.com/g/" + imagewidth + "/" + imageheight
  13.     a% = API_request(URL, URLFile)
  14.     OPEN URLFile FOR BINARY AS #1
  15.     IF LOF(1) <> 0 THEN
  16.         LoadKitten = _LOADIMAGE(URLFile, 32)
  17.         CLOSE #1
  18.         KILL URLFile
  19.     ELSE
  20.         CLOSE #1
  21.         KILL URLFile
  22.     END IF
  23.  
  24.     FUNCTION URLDownloadToFileA (BYVAL pCaller AS LONG, szURL AS STRING, szFileName AS STRING, BYVAL dwReserved AS LONG, BYVAL lpfnCB AS LONG)
  25.  
  26. FUNCTION API_request (URL AS STRING, File AS STRING)
  27.     API_request = URLDownloadToFileA(0, URL + CHR$(0), File + CHR$(0), 0, 0)
« Last Edit: July 25, 2020, 02:04:35 pm by SpriggsySpriggs »
Shuwatch!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Place kittens in your programs
« Reply #1 on: July 25, 2020, 07:07:44 pm »
I am not a fan of pets. But I can see the benefit of replacing a "cold" message box with an image of a "warm" blooded quadruped. Purr-haps you could show the kitten image when the message is cat-astrophic? (Sorry. Couldn't resist...)
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Place kittens in your programs
« Reply #2 on: July 25, 2020, 07:20:27 pm »
Cat puns: me-ow!

Offline +KZ

  • Newbie
  • Posts: 21
  • an ugly avatar :)
    • View Profile
Re: Place kittens in your programs
« Reply #3 on: July 26, 2020, 06:36:57 pm »
lel
google translate :0

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Place kittens in your programs
« Reply #4 on: July 26, 2020, 06:40:25 pm »
I am not a fan of pets. But I can see the benefit of replacing a "cold" message box with an image of a "warm" blooded quadruped. Purr-haps you could show the kitten image when the message is cat-astrophic? (Sorry. Couldn't resist...)
@johnno56 I worded it wrong. What I meant to say was use these pictures of cats to fill placeholders for images in your programs when the image you need doesn't exist.
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Place kittens in your programs
« Reply #5 on: July 26, 2020, 06:59:29 pm »
Yeah like the dog deleted my image image:
 
The dog deleted my image.PNG

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Place kittens in your programs
« Reply #6 on: July 26, 2020, 08:21:10 pm »
SpriggsySpriggs,

Understood... I cringe when either the file doesn't exist or, as I most usually do, mis-spel the filename... But, with my luck, I would probably mess up the inclusion of a "file missing" image... lol

But I just couldn't let a 'pun' opportunity just slip by... lol
Logic is the beginning of wisdom.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Place kittens in your programs
« Reply #7 on: July 26, 2020, 08:23:18 pm »
bplus,

Possible "speech bubble"... "Hey guys! I found the paws button!"

You know I just 'had' to do it, right?
Logic is the beginning of wisdom.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Place kittens in your programs
« Reply #8 on: July 26, 2020, 10:29:45 pm »
bplus,

Possible "speech bubble"... "Hey guys! I found the paws button!"

You know I just 'had' to do it, right?

Dog gone; you beat me to it.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!