Line
-
- Enthusiast
- Posts: 361
- Joined: Thu Jul 02, 2009 5:42 am
Line
Hi All,
I am using the line command to draw lines on a image. This works well except when the image
has a transparent background, the line command does not work on transparent backgrounds.
Is there anyway to make it show on a transparent background?
I am using the line command to draw lines on a image. This works well except when the image
has a transparent background, the line command does not work on transparent backgrounds.
Is there anyway to make it show on a transparent background?
Re: Line
Hi
Code: Select all
OpenWindow(0,0,0,800,600,"Contrast 4 Image",#PB_Window_SystemMenu |#PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
ImageGadget(0,10,10,780,580,0)
CreateImage(0,780,580,32,#PB_Image_Transparent )
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels )
Line(10,10,700,500,$FF0000FF) ;Use RGBA colors with alpha = 255
StopDrawing()
SetGadgetState(0,ImageID(0))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
Egypt my love
Re: Line
Better Quality and more flexible
Code: Select all
OpenWindow(0, 0, 0, 800, 600, "", #PB_Window_SystemMenu |#PB_Window_ScreenCentered)
ImageGadget(0, 10, 10, 780, 580, 0)
CreateImage(0, 780, 580, 32, #PB_Image_Transparent)
StartVectorDrawing(ImageVectorOutput(0))
MovePathCursor(10, 10)
AddPathLine(700, 500)
VectorSourceColor(#Red|$FF000000)
StrokePath(1)
StopVectorDrawing()
SetGadgetState(0,ImageID(0))
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
地球上の平和
Re: Line
A simple working example:spacebuddy wrote:...the line command does not work on transparent backgrounds...
Code: Select all
UsePNGImageDecoder()
Enumeration
#MainWindow
#Canvas
#Image
EndEnumeration
transparentImage.s = OpenFileRequester("Select Transparent Image:", "", "PNG |*.png", 0)
If transparentImage And LoadImage(#Image, transparentImage)
imgWidth = ImageWidth(#Image)
imgHeight = ImageHeight(#Image)
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, 0, 0, imgWidth, imgHeight, "Draw On Transparent Image", wFlags)
CanvasGadget(#Canvas, 0, 0, imgWidth, imgHeight)
StartDrawing(ImageOutput(#Image))
DrawingMode(#PB_2DDrawing_AllChannels)
FrontColor(RGBA(220, 100, 100, 255))
LineXY(10, 10, imgWidth - 10, 10)
LineXY(10, 10, 10, imgHeight - 10)
LineXY(10, imgHeight - 10, imgWidth - 10, imgHeight - 10)
LineXY(imgWidth - 10, 10, imgWidth - 10, imgHeight - 10)
StopDrawing()
StartDrawing(CanvasOutput(#Canvas))
Box(0, 0, imgWidth, imgHeight, RGB(255, 255, 220))
DrawAlphaImage(ImageID(#Image), 0, 0)
StopDrawing()
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
EndIf
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

-
- Enthusiast
- Posts: 361
- Joined: Thu Jul 02, 2009 5:42 am
Re: Line
Thank you all for the help, but I still can't get this to work. I am thinking there could be
some thing wrong with my image.
I put the image in my dropbox if someone has time to check it out.
https://www.dropbox.com/s/1zcr5nzionb03 ... n.png?dl=0
It works on other images I have tried, but not this one.
Thanks
some thing wrong with my image.
I put the image in my dropbox if someone has time to check it out.
https://www.dropbox.com/s/1zcr5nzionb03 ... n.png?dl=0
It works on other images I have tried, but not this one.
Thanks
Re: Line
This is the output of your image using my example. Seems to work.spacebuddy wrote:...It works on other images I have tried, but not this one.

Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: Line
I think you have forget : UsePNGImageDecoder()
If you don't think about it , this is the most common mistake, as there is no usable feedback.
If you don't think about it , this is the most common mistake, as there is no usable feedback.
Code: Select all
UsePNGImageDecoder()
image_ID=LoadImage(#PB_Any, "C:\Users\Tanaka\Desktop\VJJmCVaD.png")
OpenWindow(0, 0, 0, 800, 600, "", #PB_Window_SystemMenu |#PB_Window_ScreenCentered)
ImageGadget(0, 10, 10, 780, 580, 0)
StartVectorDrawing(ImageVectorOutput(image_ID))
MovePathCursor(10, 10)
AddPathLine(700, 500)
VectorSourceColor(#Red|$FF000000)
StrokePath(1)
StopVectorDrawing()
SetGadgetState(0,ImageID(image_ID))
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
地球上の平和
-
- Enthusiast
- Posts: 361
- Joined: Thu Jul 02, 2009 5:42 am
Re: Line
Okay, I just tested it under Windows and it does work. But when I try the same code on my Mac
it does not work. I think this is a bug under Mac OS/X
Thanks all
it does not work. I think this is a bug under Mac OS/X
Thanks all
Re: Line
Under MacOS the event processing is a bit different.
Try before the final output
While WindowEvent() : Wend, so that all events are processed.
Also the output to "Hidden" does not work on all OS, but always on Windows.
Try before the final output
While WindowEvent() : Wend, so that all events are processed.
Also the output to "Hidden" does not work on all OS, but always on Windows.
地球上の平和
Re: Line
I have taken TI-994A's example and loaded the goblin.png from spacebuddy and tested it on MacOS 10.14.6 'Mojave' with PB 5.73 x64. It shows a similar output as the output image posted by TI-994A. I only had to change the x1 value in LineXY from 10 to 40 and also adapt the respective x2 value.spacebuddy wrote:Okay, I just tested it under Windows and it does work. But when I try the same code on my Mac
it does not work. I think this is a bug under Mac OS/X
Re: Line
If this didn't work, almost none of my codes for PB on Mac would work.
Since everything is checked on Mac, PB bug is excluded.
There remains only the possibility that perhaps a VM is used which triggers the bug.
Since everything is checked on Mac, PB bug is excluded.
There remains only the possibility that perhaps a VM is used which triggers the bug.
地球上の平和
-
- Enthusiast
- Posts: 361
- Joined: Thu Jul 02, 2009 5:42 am
Re: Line
I am using Big Sur on a Mac mini m1, the program is running under rosetta2, I am wondering if that is the problem.
Under Windows 10 it works perfectly.
Thanks
Under Windows 10 it works perfectly.
Thanks
Re: Line
Use all you can get from 2DDrawing lib
Use carefully DrawingMode() you can get lot of effects
Simple and straight forward
Use carefully DrawingMode() you can get lot of effects
Simple and straight forward
Code: Select all
UsePNGImageDecoder()
LoadImage(0,"I:\goblin.png")
OpenWindow(0,0,0,ImageWidth(0)+20,ImageHeight(0)+20,"Test", #PB_Window_SystemMenu |#PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
ImageGadget(0,10,10,780,580,ImageID(0))
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels |#PB_2DDrawing_Outlined )
Box(10,10,ImageWidth(0)-20,ImageHeight(0)-20,$FF0000FF) ;Use RGBA colors with alpha = 255
LineXY(20,20,ImageWidth(0) - 20,370,$FFFF0000)
DrawingMode(#PB_2DDrawing_AllChannels)
Box(140,20,4,ImageHeight(0)-40,$FF00FF00)
StopDrawing()
SetGadgetState(0,ImageID(0))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
Egypt my love
Re: Line
In that case, this could simply be a compatibility issue with the new OS, processor, or translator.spacebuddy wrote:I am using Big Sur on a Mac mini m1, the program is running under rosetta2...
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: Line
That seems indeed to be the problem. I did the same test described above for Mojave on my Intel iMac 5K 2019 with MacOS 11.1 'Big Sur' and PB 5.73 x64 and it works like a charm.TI-994A wrote:In that case, this could simply be a compatibility issue with the new OS, processor, or translator.spacebuddy wrote:I am using Big Sur on a Mac mini m1, the program is running under rosetta2...
Last edited by Shardik on Sat Jan 30, 2021 10:02 am, edited 1 time in total.