Still looking at simple graphics problems even before I get to the networking.
To test this problem, download the 1600x1000 .jpg graphic at the next link,
http://wallpicshd.com/download.php?file ... 0x1000.jpg
and snag this 800 x 400 .png graphic.
http://www.udpac.org/wp-content/uploads ... 00x400.png
If you place the following source in the same folder that has both pictures,
and compile it, then it will run as expected in Windows®.
The program creates a 800x600 window.
and converts the 800 x 400 .png into a 800x400 sprite
The display is built when the REFRESH variable is set,
when it grabs a date based 200x200 texture selection from the big 1600x1000 wallpaper file,
and tile pastes it into the 800x600 window as its background,
The 800x400 sprite is then pasted into the top 2/3 of the window.
You can press the escape key to end the program.
Code: Select all
UsePNGImageDecoder()
UseJPEGImageDecoder()
; Load graphics data from files. 40 textures and one header.
CatchImage(100,?BITMAP1)
For YIND= 0 To 4 : For XIND= 0 To 7
GrabImage(100,YIND*8+XIND+1,XIND*200,YIND*200,200,200)
Next XIND : Next YIND
FreeImage(100)
CatchImage(100,?BITMAP2) : GrabImage(100,41,0,0,800,400) : FreeImage(100)
; Initialize the graphical environment.
InitSprite()
OpenWindow(0,0,0,800,600,"PROGRAM",#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget)
OpenWindowedScreen(WindowID(0),0,0,800,600,#True,0,0) : CreateSprite(0,800,600)
StartDrawing(ScreenOutput()) : DrawImage(ImageID(41),0,0) : StopDrawing()
;GrabSprite(1,0,0,800,400)
; Broken GrabSprite() command replaced with the following LoadSprite() line
LoadSprite(1,"Comcast-Logo-800x400.png",#PB_Sprite_AlphaBlending)
If InitKeyboard() = 0 : MessageRequester("PROGRAM","Could Not initialize keyboard.") : End : EndIf
FlipBuffers()
REFRESH= 1 : BYEBYE= 0
; Draw the screen and wait for escape or exit.
Repeat
RELEASE= ElapsedMilliseconds()+ 20
Repeat
X= WindowEvent() : If X = #PB_Event_CloseWindow : End : EndIf
Until X = 0
If REFRESH
StartDrawing(SpriteOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
; Draw date based 200x200 texture selection from wallpaper as background
For YIND= 0 To 2 : For XIND= 0 To 4
DrawImage(ImageID((DayOfYear(Date()) % 40)+ 1),XIND*200,YIND*200)
Next XIND : Next YIND
StopDrawing() : DisplaySprite(0,0,0)
DisplayTransparentSprite(1,0,0)
; DisplaySprite(1,0,0)
FlipBuffers()
REFRESH= 0
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape) : BYEBYE+ 1 : EndIf
If ElapsedMilliseconds() < RELEASE
Repeat : Delay(2) : Until ElapsedMilliseconds() > RELEASE
EndIf
Until BYEBYE
DataSection
BITMAP1: : IncludeBinary "2013_05_Awesome-City-Wallpaper-HD-1600x1000.jpg"
; http://wallpicshd.com/download.php?filename=2013/05/Awesome-City-Wallpaper-HD-1600x1000.jpg
BITMAP2: : IncludeBinary "Comcast-Logo-800x400.png"
; http://www.udpac.org/wp-content/uploads/2013/05/Comcast-Logo-800x400.png
EndDataSection
The problem is that the
DisplaySprite(1,0,0) command produces a black box, and the
DisplayTransparentSprite(1,0,0) shows nothing (black is transparent) using the 5.43 LTS Linux x64 compiler.
It looks as if the
GrabSprite() command is not working.
I've stripped the above snippet out of some code that worked well in last year's Linux compiler.
I'd considered using the alphablend drawing modes to obtain the transparency needed in the 800x400 graphics,
but those modes only work with the CanvasOutput() or ImageOutput(),
while this snippet uses the ScreenOutput() and SpriteOutput().
Fellow Linux programmers, if anyone has a few extra minutes and experience with basic BASIC graphics programming,
then I'm requesting an example to be posted of the least change to my extremely simple code above.
I want the minimum change necessary to make it actually work as it is supposed to, using the current 5.43 Linux compiler.
If you don't have access to a Windows® computer to see how it's supposed to run,
the colorful peacock from the Comcast graphic is superimposed over the tiled background that you do see in Linux.
{edit} Now 100% sure that the
GrabSprite() command does not work in Linux, as it creates a sprite of depth 0.
Replacing the
GrabSprite() with
LoadSprite() gets the program to properly display in Linux.