X2D - eXtended 2D
-
- Enthusiast
- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
X2D - eXtended 2D
Here's a library for drawing additional shapes within StartDrawing...StopDrawing.
http://www.physical-touch.de/X2D.zip
Have fun.
P.S.: THX to Freak without whom this library would never have seen daylight.
http://www.physical-touch.de/X2D.zip
Have fun.
P.S.: THX to Freak without whom this library would never have seen daylight.
-
- Enthusiast
- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
That's not only useful for Games. Hell, I could use it in a lot of my applications. But at the moment I have no idea how to implement that. How can I incorporate that in my lib. I don't even know if PB loads the Alpha Channel of, for example, a PNG!?Num3 wrote:A few sugestions:
[For games]
X2D_LoadtransparentBitmap(bitmapid,transparent color)
X2D_DrawtransparentBitmap(bitmapid,x,y)
Pleasssssssssssssssseeeeeeeee
I just found out about the other GDI Stuff I used in this version of the lib. Don't expect my 'learning curve' to be that steep

-
- Enthusiast
- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
change the bitmap to an icon file and you have transparency, in a way...
(dirty but works in some cases)
(dirty but works in some cases)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
- Enthusiast
- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
maybe this can help (thx Danilo to post that )Num3 wrote:A few sugestions:
[For games]
X2D_LoadtransparentBitmap(bitmapid,transparent color)
X2D_DrawtransparentBitmap(bitmapid,x,y)
Pleasssssssssssssssseeeeeeeee
Code: Select all
;
; by Danilo, 22.04.2003 - german forum
;
Procedure LoadTransparentImage(Number,FileName$,TransColor,NewColor)
;>
;> Number = ImageNumber
;> FileName$ = File Name
;> TransColor = RGB: Transparent Color, -1 = First Color in Picture
;> NewColor = RGB: New Color for TransColor, -1 = System Window Background
;>
Structure _LTI_BITMAPINFO
bmiHeader.BITMAPINFOHEADER
bmiColors.RGBQUAD[1]
EndStructure
Structure _LTI_LONG
l.l
EndStructure
hBmp = LoadImage(Number,FileName$)
If hBmp
hDC = StartDrawing(ImageOutput())
If hDC
ImageWidth = ImageWidth() : ImageHeight = ImageHeight()
mem = GlobalAlloc_(#GMEM_FIXED|#GMEM_ZEROINIT,ImageWidth*ImageHeight*4)
If mem
bmi._LTI_BITMAPINFO
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiheader\biWidth = ImageWidth
bmi\bmiheader\biHeight = ImageHeight
bmi\bmiheader\biPlanes = 1
bmi\bmiheader\biBitCount = 32
bmi\bmiheader\biCompression = #BI_RGB
If GetDIBits_(hDC,hBmp,0,ImageHeight(),mem,bmi,#DIB_RGB_COLORS) <> 0
If TransColor = -1
*pixels._LTI_LONG = mem+((ImageHeight-1)*ImageWidth*4)
TransColor = *pixels\l
Else
TransColor = RGB(Blue(TransColor),Green(TransColor),Red(TransColor))
EndIf
If NewColor = -1
NewColor = GetSysColor_(#COLOR_BTNFACE) ; #COLOR_WINDOW
EndIf
NewColor = RGB(Blue(NewColor),Green(NewColor),Red(NewColor))
*pixels._LTI_LONG = mem
For a = 1 To ImageWidth*ImageHeight
If *pixels\l = TransColor
*pixels\l = NewColor
EndIf
*pixels + 4
Next a
If SetDIBits_(hDC,hBmp,0,ImageHeight(),mem,bmi,#DIB_RGB_COLORS) <> 0
Result = hBmp
EndIf
EndIf
GlobalFree_(mem)
EndIf
EndIf
StopDrawing()
EndIf
ProcedureReturn Result
EndProcedure
image1 = LoadTransparentImage(1,"d:\bilder\berthel.bmp",-1,-1)
If image1
OpenWindow(0,0,0,ImageWidth(),ImageHeight(),#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Image")
CreateGadgetList(WindowID())
ImageGadget(0,0,0,ImageWidth(),ImageHeight(),image1)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Else
MessageRequester("ERROR","Cant load image!",#MB_ICONERROR)
EndIf
SPAMINATOR NR.1
-
- Enthusiast
- Posts: 537
- Joined: Wed Oct 29, 2003 10:35 am
-
- Enthusiast
- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
This one will come in the next version as X2D_DrawTransparentImage. It's already running here but I don't know if it's really fast enough for games. On the other hand, for games there is a working alternative: Sprites - isn't it?Num3 wrote: X2D_DrawtransparentBitmap(bitmapid,x,y)
But this one ... you won't need itNum3 wrote: X2D_LoadtransparentBitmap(bitmapid,transparent color)

I also work on a way to display Images with an Alpha-Channel and SemiTransparent Images. But I can't promiss that it will work.
@dontmailme: Thx for pointing out the F1 issue. I thought this was already done

The example-image was done by simply drawing the text 2 times with slightly different angles and colors. The second with DrawingMode(1) for transparent Background.
Make sure to have called DrawingFont first, otherwise the text won't be displayed crooked (and I have no idea why - Fred???).
-
- Enthusiast
- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
-
- Enthusiast
- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact: