It is currently Thu Oct 24, 2019 6:14 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: GrabDrawingImage make vertical mirroring output PB560/561b1
PostPosted: Tue Sep 05, 2017 7:34 am 
Offline
Addict
Addict

Joined: Sat Mar 02, 2013 9:17 am
Posts: 931
GrabDrawingImage make vertical mirroring output
PB560/561b1

Linux OK, crash on Mac

Code:
InitSprite()

  Procedure CopyContent_Sprite_Canvas_BF(source_ID, destination_ID)
    If Not StartDrawing(SpriteOutput(source_ID)) : ProcedureReturn -9 : EndIf
    Protected temp_image_ID=GrabDrawingImage(#PB_Any, 0 ,0, SpriteWidth(source_ID), SpriteHeight(source_ID))
    If Not temp_image_ID : StopDrawing() : ProcedureReturn -6 : EndIf
    StopDrawing()
    If Not StartDrawing(CanvasOutput(destination_ID)) : ProcedureReturn -5 : EndIf
    DrawImage(ImageID(temp_image_ID), 0, 0)
    StopDrawing()
    FreeImage(temp_image_ID)
  EndProcedure

OpenWindow(0, 0, 0, 800, 400,"", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 400, 400)
canvas=CanvasGadget(#PB_Any, 500, 100, 200, 200)

sprite=CreateSprite(#PB_Any, 200, 200)

StartDrawing(SpriteOutput(sprite))
DrawText(0, 0, "Hello World")
StopDrawing()

CopyContent_Sprite_Canvas_BF(sprite, canvas)

Repeat
  If WaitWindowEvent(1)=#PB_Event_CloseWindow : Break : EndIf
ForEver

_________________
http://www.nachtoptik.de


Last edited by walbus on Tue Sep 05, 2017 9:40 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: GrabDrawingImage make vertical mirroring output PB560/56
PostPosted: Tue Sep 05, 2017 8:12 am 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4368
Location: Germany
@walbus (not topic related)

I think your CopyContent_Sprite_Canvas_BF() is missing a StopDrawing:
Code:
If Not temp_image_ID
  StopDrawing()
  ProcedureReturn -6
EndIf


Because StartDrawing(SpriteOutput(source_ID)) is still active in this case.

Bernd


Top
 Profile  
Reply with quote  
 Post subject: Re: GrabDrawingImage make vertical mirroring output PB560/56
PostPosted: Tue Sep 05, 2017 8:49 am 
Offline
Addict
Addict

Joined: Sat Mar 02, 2013 9:17 am
Posts: 931
Yep, many thanks Bernd, i add it to the main code and change it above now

Regards Werner

_________________
http://www.nachtoptik.de


Top
 Profile  
Reply with quote  
 Post subject: Re: GrabDrawingImage make vertical mirroring output PB560/56
PostPosted: Mon May 20, 2019 11:38 am 
Offline
New User
New User
User avatar

Joined: Sat Apr 10, 2004 10:17 pm
Posts: 6
Location: Rhine Main Area - Germany
*** Push ***
Tested with PB 5.71 beta and Windows 10 64bit, bug isn't fixed yet. With this bug, GrabDrawingImage is totally useless. Really annoying :cry:

_________________
My very first BASIC Program is Open Source now:
10 PRINT "HELLO WORLD !"
20 END
RUN


Top
 Profile  
Reply with quote  
 Post subject: Re: GrabDrawingImage make vertical mirroring output PB560/56
PostPosted: Tue May 21, 2019 10:34 am 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1651
Location: Germany
GrabDrawingImage() from an image (ImageOutput()) is working fine. Only GrabDrawingImage() from a sprite (SpriteOutput()) does show the vertical mirroring on Windows and works correctly on Linux:

Image

Code:
EnableExplicit

Define Image1.I
Define Image2.I
Define Image3.I
Define Sprite.I

InitSprite()

; ----- Create test image with text

Image1 = CreateImage(#PB_Any, 160, 50, 24, 0)

If StartDrawing(ImageOutput(Image1))
  DrawText(0, 0, "Hello World!", $FFFFFF, 0)
  StopDrawing()
EndIf

OpenWindow(0, 0, 0, (ImageWidth(Image1) + 18) * 3 - 9, ImageHeight(Image1) + 40,
  "GrabDrawingImage() bug demo",
  #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 10, 10, ImageWidth(Image1) + 4, ImageHeight(Image1) + 4,
  #PB_Canvas_Border)
CanvasGadget(1, ImageWidth(Image1) + 22, 10, ImageWidth(Image1) + 4,
  ImageHeight(Image1) + 4, #PB_Canvas_Border)
CanvasGadget(2, ImageWidth(Image1) * 2 + 33, 10, ImageWidth(Image1) + 4,
  ImageHeight(Image1) + 4, #PB_Canvas_Border)
TextGadget(3, 65, ImageHeight(Image1) + 15, 85, 25, "Test image")
TextGadget(4, 188, ImageHeight(Image1) + 15, 170, 25,
  "GrabDrawingImage() from image")
TextGadget(5, 360, ImageHeight(Image1) + 15, 170, 25,
  "GrabDrawingImage() from sprite")

; ----- Display Image1 (test image) in CanvasGadget 0

If StartDrawing(CanvasOutput(0))
  DrawImage(ImageID(Image1), 0, 0)
  StopDrawing()
EndIf

; ----- Grab Image1 (test image) into Image2

If StartDrawing(ImageOutput(Image1))
  Image2 = GrabDrawingImage(#PB_Any, 0, 0, ImageWidth(Image1),
    ImageHeight(Image1))
  StopDrawing()
EndIf

; ----- Display Image2 (grabbed test image) in CanvasGadget 1

If StartDrawing(CanvasOutput(1))
  DrawImage(ImageID(Image2), 0, 0)
  StopDrawing()
EndIf

; ----- Create sprite

OpenWindowedScreen(WindowID(0), 0, 0, 1, 1)
Sprite = CreateSprite(#PB_Any, 160, 50)

; ----- Draw Image1 (test image) into sprite

If StartDrawing(SpriteOutput(Sprite))
  DrawImage(ImageID(Image1), 0, 0)
  StopDrawing()
EndIf

; ----- Grab image from sprite and draw it into Image3

If StartDrawing(SpriteOutput(Sprite))
  Image3 = GrabDrawingImage(#PB_Any, 0 ,0, SpriteWidth(Sprite),
    SpriteHeight(Sprite))
  StopDrawing()
EndIf

; ----- Display Image3 (grabbed sprite) in CanvasGadget 2

If StartDrawing(CanvasOutput(2))
  DrawImage(ImageID(Image3), 0, 0)
  StopDrawing()
EndIf

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject: Re: GrabDrawingImage make vertical mirroring output PB560/56
PostPosted: Tue May 21, 2019 1:49 pm 
Offline
New User
New User
User avatar

Joined: Sat Apr 10, 2004 10:17 pm
Posts: 6
Location: Rhine Main Area - Germany
Shardik wrote:
... Only GrabDrawingImage() from a sprite (SpriteOutput()) does show the vertical mirroring on Windows ...

Yep! This is exactly what I need to do :wink:

_________________
My very first BASIC Program is Open Source now:
10 PRINT "HELLO WORLD !"
20 END
RUN


Top
 Profile  
Reply with quote  
 Post subject: Re: GrabDrawingImage make vertical mirroring output PB560/56
PostPosted: Tue May 21, 2019 3:57 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 544
On both OpenGL & DirectX ?


Top
 Profile  
Reply with quote  
 Post subject: Re: GrabDrawingImage make vertical mirroring output PB560/56
PostPosted: Tue May 21, 2019 7:27 pm 
Offline
New User
New User
User avatar

Joined: Sat Apr 10, 2004 10:17 pm
Posts: 6
Location: Rhine Main Area - Germany
Mijikai wrote:
On both OpenGL & DirectX ?

Don't have any experience with OpenGL. Does anybody else checked this with OpenGL?

_________________
My very first BASIC Program is Open Source now:
10 PRINT "HELLO WORLD !"
20 END
RUN


Top
 Profile  
Reply with quote  
 Post subject: Re: GrabDrawingImage make vertical mirroring output PB560/56
PostPosted: Tue May 21, 2019 8:00 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4368
Location: Germany
OpenGL works correct.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye