Page 2 of 2

Re: ImageButtonGadget images

Posted: Sat Jul 28, 2012 11:09 am
by electrochrisso
You saved me a bit of time to work that bit out TI, so it was worth the mention. :)

Re: ImageButtonGadget images

Posted: Sat Jul 28, 2012 1:30 pm
by kernadec
hi
it could be like that too

Goodday

Code: Select all

#Btnpage_white_office = 1
CatchImage(0,?image)

OpenWindow(#PB_Any, 0, 0, 400, 300, "WindowTitle", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered) 
ButtonImageGadget(#Btnpage_white_office, 30, 30, 32, 32,ResizeImage(0,32,32)) 
	
Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow 

DataSection
  image:
  IncludeBinary #PB_Compiler_Home+"\Examples\Sources\Data\Geebee2.bmp"
EndDataSection

Re: ImageButtonGadget images

Posted: Sat Jul 28, 2012 2:10 pm
by electrochrisso
kernadec wrote:hi
it could be like that too

Goodday

Code: Select all

#Btnpage_white_office = 1
CatchImage(0,?image)

OpenWindow(#PB_Any, 0, 0, 400, 300, "WindowTitle", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered) 
ButtonImageGadget(#Btnpage_white_office, 30, 30, 32, 32,ResizeImage(0,32,32)) 
	
Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow 

DataSection
  image:
  IncludeBinary #PB_Compiler_Home+"\Examples\Sources\Data\Geebee2.bmp"
EndDataSection
Not really related to this posting, anyhow why have you got ResizeImage(0,32,32) as the image id for the ButtonImageGadget. :?:

Re: ImageButtonGadget images

Posted: Sat Jul 28, 2012 2:20 pm
by TI-994A
electrochrisso wrote:...why have you got ResizeImage(0,32,32) as the image id for the ButtonImageGadget. :?:
Hello again electrochrisso. It's because the image dimensions are larger than the button. If it is not resized to match the dimensions of the button, only a portion of the image will be drawn.

Re: ImageButtonGadget images

Posted: Sat Jul 28, 2012 2:43 pm
by electrochrisso
TI-994A wrote:
electrochrisso wrote:...why have you got ResizeImage(0,32,32) as the image id for the ButtonImageGadget. :?:
Hello again electrochrisso. It's because the image dimensions are larger than the button. If it is not resized to match the dimensions of the button, only a portion of the image will be drawn.
Yes it changes the handle to the newly resized image, I probably have used it before but forgot, I will remember that one in future. :)

Re: ImageButtonGadget images

Posted: Sat Jul 28, 2012 5:54 pm
by TI-994A
electrochrisso wrote:Yes it changes the handle to the newly resized image, I probably have used it before but forgot, I will remember that one in future. :)
Wow! I answered your question without understanding it; sorry about that.

You're absolutely correct; it seems that ResizeImage() does return a new image handle - not documented though. Thank you for pointing that out.

Re: ImageButtonGadget images

Posted: Sat Jul 28, 2012 5:59 pm
by kernadec
@electrochrisso Not really related to this posting????
why this reproach! it is not off topic
excuse me but you misjudge the code as it is in the same kind.
image data is inserted in the compilation with the same principle,


Goodday

Re: ImageButtonGadget images

Posted: Sat Jul 28, 2012 8:30 pm
by Bisonte
But with IncludeBinary some virusscanners gone wild ...
I prefer Stargates Method with Quads ... (and his IDE Tool to make these Datasections) ;) All types of Images are possible, and other things...

Re: ImageButtonGadget images

Posted: Sat Jul 28, 2012 8:32 pm
by IdeasVacuum
kernadec, please see the first post - this is about an alternative to included data methods.

Re: ImageButtonGadget images

Posted: Sat Jul 28, 2012 9:04 pm
by kernadec
@IdeasVacuum, I understand the alternative,
I do not dispute your work, it was not my intention, for me just one example.
thank for the sharing.

@Bisonte, OK :D
would you tell me where I can find the tool, compressed data of Stargate , thanks

Good day

Re: ImageButtonGadget images

Posted: Sun Jul 29, 2012 2:18 am
by VB6_to_PBx
TI-994A wrote:Hi IdeasVacuum. Thanks for the great work!
VB6_to_PBx wrote:[14:38:05][COMPILER] Line 268: Constant not found: #Btnpage_white_office.
[14:41:04][COMPILER] Line 268: Constant not found: #Btnpage_white_office.
...
a short "complete actual working " source code example showing how to display the image on a button image gadget would help tremendously
Hi VB6_to_PBx. You'll have to either enumerate the ButtonImageGadget() or manually assign it a gadget number. Also, make sure that the ButtonImageGadget() size matches the created image size. Give this a try:

Code: Select all

Enumeration
  #MainWindow
  #Btnpage_white_office
EndEnumeration

Procedure DrawBtnpage_white_office()

  ;the ButtonImageGadget() size should match this image size
  Protected iImage.i = CreateImage(#PB_Any, 100, 30, 24)

    If StartDrawing(ImageOutput(iImage))
          DrawingMode(#PB_2DDrawing_Default)
          Plot(0000,0000,RGB(255,255,255)) ...
          ...
          ...
          ...
          StopDrawing()

          ;#Btnpage_white_office is the assigned constant for the ButtonImageGadget()
          SetGadgetAttribute(#Btnpage_white_office, #PB_Button_Image, ImageID(iImage))

    EndIf
EndProcedure

wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, #PB_Any, #PB_Any, 300, 300, "Image Button Example", wFlags)

;create a ButtonImageGadget() with #Btnpage_white_office as the gadget number,
;assign a zero value to the ImageID and ensure that the size matches the output image
ButtonImageGadget(#Btnpage_white_office, 30, 30, 100, 30, 0)

DrawBtnpage_white_office()

While WaitWindowEvent() ! #PB_Event_CloseWindow : CloseWindow : Wend

TI-994A ,
thank you very much for your help !

Re: ImageButtonGadget images

Posted: Sun Jul 29, 2012 2:39 am
by electrochrisso
TI-994A wrote:
electrochrisso wrote:Yes it changes the handle to the newly resized image, I probably have used it before but forgot, I will remember that one in future. :)
Wow! I answered your question without understanding it; sorry about that.

You're absolutely correct; it seems that ResizeImage() does return a new image handle - not documented though. Thank you for pointing that out.
Actually it is in the docs, it's further down in the remarks section, as stated:- This function changes the handle of the used image. Therefore it must be newly assigned e.g. to an ImageGadget() with SetGadgetState().

I did a quick test:-

a.l=CreateImage(0,100,100)
Debug a
Debug ImageID(0)

-1140517088
-1140517088

b.l=ResizeImage(0,10,10)
Debug b
Debug ImageID(0)

537204954
537204954

Re: ImageButtonGadget images

Posted: Sun Jul 29, 2012 8:40 am
by Bisonte
kernadec wrote:@Bisonte, OK :D
would you tell me where I can find the tool, compressed data of Stargate , thanks

Good day
No problem .... : http://purebasic.fr/german/viewtopic.ph ... 45#p294445

Re: ImageButtonGadget images

Posted: Sun Jul 29, 2012 8:46 am
by TI-994A
VB6_to_PBx wrote:TI-994A ,
thank you very much for your help !
Hello VB6_to_PBx. I am so glad that it was helpful to you; and thank you for saying so.
electrochrisso wrote:Actually it is in the docs, it's further down in the remarks section, as stated:- This function changes the handle of the used image. Therefore it must be newly assigned e.g. to an ImageGadget() with SetGadgetState().
Hello electrochrisso. You're right again. The documentation is a little confusing when it mentioned that ResizeImage() returns nonzero if the operation succeeded and zero if it failed, without indicating that the nonzero is the new handle. Regardless, it's always great to learn something new. Thank you.