Send data image to WebGadget [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Send data image to WebGadget [Resolved]

Post by Kwai chang caine »

Hello at all :D

Is it possible to send directly an image in DATA to a WebGadget ??

Code: Select all

Enumeration
 #Form0
 #Web0
 #Bouton0
 #Image
EndEnumeration

OpenWindow(#Form0, 216, 0, 397, 340, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
WebGadget(#Web0, 12, 18, 372, 291, "about:blank")
ButtonGadget(#Bouton0, 104, 315, 182, 20, "")

Repeat
  
 Evenement = WaitWindowEvent()
 
 If Evenement = #PB_Event_Gadget
  
  Select EventGadget()
    
   Case #Bouton0
    
    ImageID = CatchImage(#Image, ?FlagImage)
    SetGadgetText(#Web0, "???")
     
  EndSelect  
  
 EndIf 
 
Until Evenement = #PB_Event_CloseWindow

End
 
DataSection
 FlagImage:
 IncludeBinary "Image.jpg"
EndDataSection
Have a good day
Last edited by Kwai chang caine on Sun Jan 15, 2012 6:27 pm, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
infratec
Always Here
Always Here
Posts: 7582
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Send data image to WebGadget

Post by infratec »

Hi,

I think it is not possible to do it 'directly'.

In my opinion it is only possible to save the 'catched' image to the harddisk
Like this:

Code: Select all

Select EventGadget()
   Case #Bouton0
     ImageID = CatchImage(#Image, ?FlagImage)
     TmpImgFilename$ = GetTemporaryDirectory() + "test.bmp"
     SaveImage(#Image, TmpImgFilename$)
     SetGadgetItemText(#Web0, #PB_Web_HtmlCode, "<img src=" + #DQUOTE$ + TmpImgFilename$ + #DQUOTE$ + "></img>")
     
   Case #Web0
     If EventType() = #PB_EventType_DownloadEnd
      If Len(TmpImgFilename$)
        DeleteFile(TmpImgFilename$)
        TmpImgFilename$ = ""
      EndIf
     EndIf
  EndSelect
Bernd
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Send data image to WebGadget

Post by Kwai chang caine »

It seemed as though it was impossible.
Even with PB, it is not used, but sometimes it is still impossible to do things :lol:
I do like you show to me :wink:

So thanks a lot INFRATEC for your precious help 8)
I wish you a good evening
ImageThe happiness is a road...
Not a destination
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Send data image to WebGadget [Resolved]

Post by wilbert »

I don't know if WebGadget supports it but there is a way
http://en.wikipedia.org/wiki/Data_URI_scheme
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Send data image to WebGadget [Resolved]

Post by Kwai chang caine »

Hello Wilbert :D
Interesting, i don't know this tips :shock:

But apparently that not works with WebGadget
I have try this Data_URI_scheme

Code: Select all

Enumeration
 #Form0
 #Web0
 #Bouton0
EndEnumeration

OpenWindow(#Form0, 216, 0, 397, 340, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
WebGadget(#Web0, 12, 18, 372, 291, "about:blank", #PB_Web_Mozilla)
ButtonGadget(#Bouton0, 104, 315, 182, 20, "Charger le DATA")

Repeat
 
 Evenement = WaitWindowEvent()
 
 Select EventGadget()
   
   Case #Bouton0
         
    SetGadgetItemText(#Web0, #PB_Web_HtmlCode, "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0 vr4MkhoXe0rZigAAAABJRU5ErkJggg==")     
    
  EndSelect
 

Until Evenement = #PB_Event_CloseWindow

End
Normally a red point appears in Firefox...and not in WebGadget, in IE that not works too :(

Thanks when even for your help 8)
ImageThe happiness is a road...
Not a destination
- chris -
New User
New User
Posts: 9
Joined: Sun Jun 06, 2010 10:43 am

Re: Send data image to WebGadget [Resolved]

Post by - chris - »

Hello

two red dots:

Code: Select all


#DQ = Chr(34)

Enumeration
#Form0
#Web0
#Bouton0
EndEnumeration

OpenWindow(#Form0, 216, 0, 397, 340, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
WebGadget(#Web0, 12, 18, 372, 291, "about:blank")
ButtonGadget(#Bouton0, 104, 315, 182, 20, "Charger le DATA")

Repeat

Evenement = WaitWindowEvent()

Select EventGadget()
   
   Case #Bouton0
         
    code$ + "<img src=" + #DQ + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" + #DQ + " alt=" + #DQ + "Red dot" + #DQ + ">" + #CRLF$ 
    
    SetGadgetItemText(#Web0, #PB_Web_HtmlCode, code$)
   
  EndSelect


Until Evenement = #PB_Event_CloseWindow

End

Last edited by - chris - on Sun Jan 15, 2012 8:39 pm, edited 2 times in total.
PB v5.62 x86/x64
Windows 10 Pro
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Send data image to WebGadget [Resolved]

Post by Kwai chang caine »

Hello CHRIS :D
Strange here that not works :shock:

Image
ImageThe happiness is a road...
Not a destination
- chris -
New User
New User
Posts: 9
Joined: Sun Jun 06, 2010 10:43 am

Re: Send data image to WebGadget [Resolved]

Post by - chris - »

hello

and without #PB_Web_Mozilla ?
PB v5.62 x86/x64
Windows 10 Pro
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Send data image to WebGadget [Resolved]

Post by wilbert »

On OS X the dots show up fine. :)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Send data image to WebGadget [Resolved]

Post by Kwai chang caine »

- chris - wrote:hello
and without #PB_Web_Mozilla ?
The same thing, i'm on XP PRO SP3
I have try v4.51 and 4.60 always the same thing
ImageThe happiness is a road...
Not a destination
- chris -
New User
New User
Posts: 9
Joined: Sun Jun 06, 2010 10:43 am

Re: Send data image to WebGadget [Resolved]

Post by - chris - »

hello

With full html:

one red dot

Code: Select all


#DQ = Chr(34)

Enumeration
  #Form0
  #Web0
  #Bouton0
EndEnumeration

OpenWindow(#Form0, 216, 0, 397, 340, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
WebGadget(#Web0, 12, 18, 372, 291, "about:blank")
ButtonGadget(#Bouton0, 104, 315, 182, 20, "Charger le DATA")

Repeat

  Evenement = WaitWindowEvent()

  Select EventGadget()

    Case #Bouton0
      
      code$ = ""
      code$ + "<html>" + #CRLF$
      code$ + "<head>" + #CRLF$
      code$ + "</head>" + #CRLF$
      code$ + "<body>" + #CRLF$  
      code$ + "<img src=" + #DQ + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" + #DQ + " alt=" + #DQ + "Red dot" + #DQ + ">" + #CRLF$ 
      code$ + "</body>" + #CRLF$      
      code$ + "</html>" + #CRLF$      
      
      SetGadgetItemText(#Web0, #PB_Web_HtmlCode, code$)

  EndSelect


Until Evenement = #PB_Event_CloseWindow

End

PB v5.62 x86/x64
Windows 10 Pro
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Send data image to WebGadget [Resolved]

Post by wilbert »

Maybe it has to do with the version of the browser. IE8 supports the Data URI scheme but older IE versions don't.
I don't know if WebGadget relies on the version of IE that is installed.
On my Windows 7 both PB x86 and PB x64 show the dots correctly with or without the #PB_Web_Mozilla flag.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Send data image to WebGadget [Resolved]

Post by netmaestro »

Try this one, it works here with mozilla or not:

Code: Select all

Enumeration
  #Form0
  #Web0
  #Bouton0
EndEnumeration

DataSection
  world: IncludeBinary #PB_Compiler_Home+"examples\sources\data\geebee2.bmp"
  worldend:
EndDataSection

*mem = AllocateMemory((?worldend-?world) * 1.35)

Base64Encoder(?world, ?worldend-?world, *mem, MemorySize(*mem))

a$ = "<html>"  + #CRLF$
a$ + "<head>"  + #CRLF$
a$ + "</head>" + #CRLF$
a$ + "<body>"  + #CRLF$  
a$ + "<a href="+Chr(34)+Chr(34)+"><img src="+Chr(34)+"Data:image/bmp;base64,"
a$ + PeekS(*mem)
a$ + Chr(34)+" alt="+Chr(34)+Chr(34)+" width="+Chr(34)+"128"+Chr(34)+" height="+Chr(34)+"128"+Chr(34)+" /></a>"+#CRLF$
a$ + "</body>" + #CRLF$      
a$ + "</html>" + #CRLF$  


OpenWindow(#Form0, 216, 0, 397, 340, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
WebGadget(#Web0, 12, 18, 372, 291, "about:blank")
ButtonGadget(#Bouton0, 104, 315, 182, 20, "Charger le DATA")

Repeat
  
  Evenement = WaitWindowEvent()
  
  Select EventGadget()
      
    Case #Bouton0
      
      SetGadgetItemText(#Web0, #PB_Web_HtmlCode, a$)
      
      
  EndSelect
  
  
Until Evenement = #PB_Event_CloseWindow

End

Last edited by netmaestro on Sun Jan 15, 2012 9:01 pm, edited 1 time in total.
BERESHEIT
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Send data image to WebGadget [Resolved]

Post by Kwai chang caine »

Maybe it has to do with the version of the browser. IE8 supports the Data URI scheme but older IE versions don't.
Yes you have right..i'm an old man...so i use an old browser IE7 :lol:
I don't know if WebGadget relies on the version of IE that is installed.
Yes the WebGadget use the browser IE installed in the machine :wink:
I believe you have found the problem :D
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Send data image to WebGadget [Resolved]

Post by Kwai chang caine »

Hello NETMAESTRO :D
I have try with a BMP and JPG your code and have another style of square :oops:
Image
ImageThe happiness is a road...
Not a destination
Post Reply