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

http://www.purebasic.com
https://www.purebasic.fr/english/
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.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
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.electrochrisso wrote:...why have you got ResizeImage(0,32,32) as the image id for the ButtonImageGadget.
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.TI-994A wrote: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.electrochrisso wrote:...why have you got ResizeImage(0,32,32) as the image id for the ButtonImageGadget.
Wow! I answered your question without understanding it; sorry about that.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.
why this reproach! it is not off topic@electrochrisso Not really related to this posting????
TI-994A wrote:Hi IdeasVacuum. Thanks for the great work!
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: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
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
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().TI-994A wrote:Wow! I answered your question without understanding it; sorry about that.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.
You're absolutely correct; it seems that ResizeImage() does return a new image handle - not documented though. Thank you for pointing that out.
No problem .... : http://purebasic.fr/german/viewtopic.ph ... 45#p294445kernadec wrote:@Bisonte, OK![]()
would you tell me where I can find the tool, compressed data of Stargate , thanks
Good day
Hello VB6_to_PBx. I am so glad that it was helpful to you; and thank you for saying so.VB6_to_PBx wrote:TI-994A ,
thank you very much for your help !
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.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().