Transparent image with ButtonImageGadget()?
Transparent image with ButtonImageGadget()?
Hellooooo!
I need a little help, I have been developing a paint program and I need to use ButtonImageGadget() command with it.. the problem is, I don't know how to use a transparent image with that command, and the bigger problem is, PB doesn't read GIf files!!! You can help me either to solve how to use transparent images in ButtonImageGadget() OR you can solve how to use GIF files WITH transparency without external DLL's
Thank you thank you thank you!
very very appreciated of any kind of help!
			
			
									
									
						I need a little help, I have been developing a paint program and I need to use ButtonImageGadget() command with it.. the problem is, I don't know how to use a transparent image with that command, and the bigger problem is, PB doesn't read GIf files!!! You can help me either to solve how to use transparent images in ButtonImageGadget() OR you can solve how to use GIF files WITH transparency without external DLL's
Thank you thank you thank you!
very very appreciated of any kind of help!
you can use icons with transparency
			
			
									
									PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

						Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

SnicoEdit: http://www.snidesoft.com/article.php?st ... 3045559857 (FreeWare)josku_x wrote:well, unless I get a icon program to use my 200x120 size images!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

						Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

ts-soft, I have found a better program, it is also freeware, 
look: http://gif.ceskyweb.cz/eng/gifex.htm
now, I have converted my images to icons, help me how to use them in ButtonImageGadget()??
			
			
									
									
						look: http://gif.ceskyweb.cz/eng/gifex.htm
now, I have converted my images to icons, help me how to use them in ButtonImageGadget()??
josku_x wrote: now, I have converted my images to icons, help me how to use them in ButtonImageGadget()??
Code: Select all
If OpenWindow(0,#CW_USEDEFAULT, #CW_USEDEFAULT, 200, 120, #PB_Window_SystemMenu, "IconTest")
  Image = LoadImage(0, "your.ico")
  If CreateGadgetList(WindowID(0))
    ButtonImageGadget(0, 0, 0, 200, 120, Image)
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
EndIfI'm speaking german, not so bad as english
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

						Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

[deutsch]
oh nein, ich hab ein kleines problem, guck mal auf dieses bild hier:

wie du siehst, ist mein icon nicht ganz in der ButtinImageGadget(), und ich bin mir 100% sicher das ich die grüne farbe als durchsichtig gemacht habe... walfisch dreck!
[deutsch]
[english]
oh no, I have a little problem, look to this picture:

as you can see, my icon is not fully drawn in the ButtonImageGadget(), and I am 100% sure that the green color was set to transparent, whale dirt (:D)!
[/english][/url]
			
			
									
									
						oh nein, ich hab ein kleines problem, guck mal auf dieses bild hier:

wie du siehst, ist mein icon nicht ganz in der ButtinImageGadget(), und ich bin mir 100% sicher das ich die grüne farbe als durchsichtig gemacht habe... walfisch dreck!
[deutsch]
[english]
oh no, I have a little problem, look to this picture:

as you can see, my icon is not fully drawn in the ButtonImageGadget(), and I am 100% sure that the green color was set to transparent, whale dirt (:D)!
[/english][/url]
I have tested the iconeditor, its not so good as snicoedit. can't make icon in 200x120 pixels.
			
			
									
									PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

						Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

you can test this: EC_ImagePluginOLE
viewtopic.php?t=6005&postdays=0&postord ... e&start=45
			
			
									
									viewtopic.php?t=6005&postdays=0&postord ... e&start=45
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

						Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Okay, it's a bit late to be a real help to the questioner..., but maybe someone else can make use of it.
This procedure adds "gif-like" transparency to any image (the source being BMP or any other by the image-library supported type) when creating the ButtonImageGadget:
Don't know, how fast it will be with big images, but for icon-like things I found it working alright.
			
			
									
									
						This procedure adds "gif-like" transparency to any image (the source being BMP or any other by the image-library supported type) when creating the ButtonImageGadget:
Code: Select all
Procedure createButtonImageGadget(ButtonLeft, ButtonTop, ButtonWidth, ButtonHeight, IconImageNo, TransparentColorValue = 0, Flags = #Null)
	; returns gadget-number if successful
	; TransparentColorValue = 0 => no transparency, ButtonImageGadget() can/should be used directly
	Define IconImageWidth, IconImageHeight
	Define *PixelBuffer, *BufferCursor
	Define i, j, ColorValue
	Define ButtonNo
	
	If IsImage(IconImageNo)
		If TransparentColorValue
			IconImageWidth = ImageWidth(IconImageNo)
			IconImageHeight = ImageHeight(IconImageNo)
			; creating buffer for icon-image
			*PixelBuffer = AllocateMemory(IconImageWidth * IconImageHeight * SizeOf(Long))	
			If *PixelBuffer
				; reading pixels into buffer while "analysing" them for transparency
				If StartDrawing(ImageOutput(IconImageNo))
					*BufferCursor = *PixelBuffer
					For i = 0 To IconImageWidth - 1
						For j = 0 To IconImageHeight - 1
							ColorValue = Point(i, j)
							If ColorValue = TransparentColorValue
								ColorValue = 0			; = RGBA(0, 0, 0, 0)  => 100% transparency
							Else
								ColorValue | $FF000000		; sets alpha-channel to 255 => no transparency
							EndIf
							PokeL(*BufferCursor, ColorValue)
							*BufferCursor + SizeOf(Long)
						Next
					Next
					StopDrawing()
					FreeImage(IconImageNo)
					; creating empty base-image for image-button
					IconImageNo = CreateImage(#PB_Any, IconImageWidth, IconImageHeight, 32)			
					If IconImageNo
						; writing buffered pixels to button-image
						If StartDrawing(ImageOutput(IconImageNo))
							DrawingMode(#PB_2DDrawing_AllChannels)
							*BufferCursor = *PixelBuffer
							For i = 0 To IconImageWidth - 1
								For j = 0 To IconImageHeight - 1
									Plot(i, j, PeekL(*BufferCursor))
									*BufferCursor + SizeOf(Long)
								Next
							Next
							StopDrawing()					
							; image-writing ready, button can be created
							ButtonNo = ButtonImageGadget(#PB_Any, ButtonLeft, ButtonTop, ButtonWidth, ButtonHeight, ImageID(IconImageNo), Flags)
						EndIf
					EndIf
					
					FreeMemory(*PixelBuffer)
				EndIf
			EndIf
		Else
			; no transparency used
			ButtonNo = ButtonImageGadget(#PB_Any, ButtonLeft, ButtonTop, ButtonWidth, ButtonHeight, ImageID(IconImageNo), Flags)
		EndIf
	EndIf
	
	ProcedureReturn ButtonNo
EndProcedureRe: Transparent image with ButtonImageGadget()?
@andrasch
Just as a side note: The alpha channel of Png images is supported now (since PB 4.40?!). So you can use the Png transparency for drawing etc. and of course the ButtonImageGadget().
			
			
									
									Just as a side note: The alpha channel of Png images is supported now (since PB 4.40?!). So you can use the Png transparency for drawing etc. and of course the ButtonImageGadget().
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
						

