[solved] GET and PUT ( graphics ) commands slow down my program[solved]

New to FreeBASIC? Post your questions here.
Daniel Ouellette
Posts: 47
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: GET and PUT ( graphics ) commands slow down my program

Postby Daniel Ouellette » Aug 09, 2020 14:02

You all explained very well what I was trying to do without needing to change everything.
Daniel Ouellette
Posts: 47
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: GET and PUT ( graphics ) commands slow down my program

Postby Daniel Ouellette » Aug 09, 2020 14:56

To tell you a bit more, for several years now, I've been using Freebasic to test the electronic devices I design using an isolated external USB interface. These devices are equipped with a microcontroller that I program in assembler language. Freebasic programs are used to check the functioning of the devices in development and production, up to making an automatic tester for some of them. Freebasic programs are not dedicated to customers, only in the laboratory, but I try as much as possible to take care of their appearance on screen in order to look good in front of potential customers.
Daniel Ouellette
Posts: 47
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: GET and PUT ( graphics ) commands slow down my program

Postby Daniel Ouellette » Aug 09, 2020 15:09

Freebasic programs are not dedicated to customers, so they are not sold to them. So I am the main user of Freebasic programs, but the production team could also use them to make their work easier. So I hope that I don't violate the terms of use. However, during demonstrations, on-screen results from the Freebasic programs are shown to customers.
grindstone
Posts: 755
Joined: May 05, 2015 5:35
Location: Germany

Re: GET and PUT ( graphics ) commands slow down my program

Postby grindstone » Aug 09, 2020 18:10

@Daniel Ouellette: What OS are you using?
Daniel Ouellette
Posts: 47
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: GET and PUT ( graphics ) commands slow down my program

Postby Daniel Ouellette » Aug 09, 2020 18:21

Windows
grindstone
Posts: 755
Joined: May 05, 2015 5:35
Location: Germany

Re: GET and PUT ( graphics ) commands slow down my program

Postby grindstone » Aug 09, 2020 18:42

As far as I understood, you have developed a device that produces images with a size of 1024 x 768 pixels at a color depth of 16 bits. These images are submitted via USB, and you want to display them on your PC monitor in a centered window. You already managed to read the image data from the device and display it on the screen, writing it to the upper left corner of a full size window.

Am I right so far? If so, this snippet could do the job. Don't write the image on the screen but into the img5 - buffer:

Code: Select all

#Include "fbgfx.bi"

Dim As Integer w, h, depth, pic_x, pic_y

ScreenInfo w, h, depth

ScreenRes w, h, 16, 2, FB.GFX_NO_FRAME
ScreenSet 1,0

Dim As Any Ptr img5 = ImageCreate(1024, 768, RGB(128,128,128), 16)

pic_x = (w - 1024) / 2
pic_y = (h - 768) / 2

Do
   '##############################################
   Circle img5, (400, 300), 200, RGB(Int(Rnd * 255),Int(Rnd * 255),Int(Rnd * 255))
   '
   ' replace the circle with
   ' the read-the-image-from-the-USB-port-and-
   ' put-it-to-the-img5-buffer - stuff
   '
   '##############################################
   Put (pic_x, pic_y), img5, PSet
   ScreenCopy
Loop Until Len(InKey)

ImageDestroy img5
Daniel Ouellette
Posts: 47
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: GET and PUT ( graphics ) commands slow down my program

Postby Daniel Ouellette » Aug 09, 2020 19:44

Well, not really. Via the USB interface, the device sends several data to the PC, which are then interpreted by the Freebasic program largely in graphical form, in addition to other data that are only displayed. This produces images with a size of 1024 x 768 pixels at a colour depth of 16 bits, as you say, with several graphics and data. If the PC screen is very large, there is no problem, the image is displayed as a window. Of course, the Y resolution cannot be lower than 768, but if it is 768 (which seems to be common), the window cannot be displayed correctly anymore because of the window frame and the taskbar. Even if I manually delete the taskbar (which can't be done by the Freebasic program), removing the window frame, when the Y resolution is 768, gives an ugly image, unless I fill the rest with a solid background color, hence the reason to center this 1024 x 768 image. Running in full screen mode makes the image even uglier. It may seem like a whim at first glance, but I try to make the image look good in front of the clients, even if they don't use it. This works well with the GET command, but the program is much slower and I was wondering if there is another way to do this without changing everything. So I write it in the top left corner of the full size window of the PC, as you say, which is the first 1024 x 768 and for to move it to the center.
Daniel Ouellette
Posts: 47
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: GET and PUT ( graphics ) commands slow down my program

Postby Daniel Ouellette » Aug 09, 2020 19:45

Sorry, I didn't see your last message.
Daniel Ouellette
Posts: 47
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: GET and PUT ( graphics ) commands slow down my program

Postby Daniel Ouellette » Aug 09, 2020 19:53

As I mentioned, it is not an image that is sent via USB, but only data from which the Freebasic program creates an image and in this case it is the GET command that seems to be a problem because of its execution time.
grindstone
Posts: 755
Joined: May 05, 2015 5:35
Location: Germany

Re: GET and PUT ( graphics ) commands slow down my program

Postby grindstone » Aug 09, 2020 19:59

No reason to apologise, I edited it several times. *smile*

Anyway, you can prepare the pictue you want to show by first writing it to an image instead of the screen, then Put this image to the center of the screen and make it visible with ScreenCopy.
fxm
Posts: 9984
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: GET and PUT ( graphics ) commands slow down my program

Postby fxm » Aug 09, 2020 20:07

Daniel Ouellette wrote:As I mentioned, it is not an image that is sent via USB, but only data from which the Freebasic program creates an image ...

Can you directly draw the image in an image buffer (1024x768) and not on the screen (no longer using GET), then just PUT the image on the screen center (by using one only screen page, without ScreenSet, neither CLS, neither FLIP).
Daniel Ouellette
Posts: 47
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: GET and PUT ( graphics ) commands slow down my program

Postby Daniel Ouellette » Aug 09, 2020 20:11

With "ScreenSet 1.0", I thought I was writing first on a image instead of the screen. Can you explain how?
grindstone
Posts: 755
Joined: May 05, 2015 5:35
Location: Germany

Re: GET and PUT ( graphics ) commands slow down my program

Postby grindstone » Aug 09, 2020 20:14

If the image is composed of multiple parts it's maybe better to do it invisible in the background.
Daniel Ouellette
Posts: 47
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: GET and PUT ( graphics ) commands slow down my program

Postby Daniel Ouellette » Aug 09, 2020 20:16

fxm wrote:Can you directly draw the image in an image buffer (1024x768) and not on the screen (no longer using GET), then just PUT the image on the screen center (by using one only screen page, without ScreenSet, neither CLS, neither FLIP).
How to do this ?
Daniel Ouellette
Posts: 47
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: GET and PUT ( graphics ) commands slow down my program

Postby Daniel Ouellette » Aug 09, 2020 20:19

grindstone wrote:If the image is composed of multiple parts it's maybe better to do it invisible in the background.
So with ScreenSet and GET?

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 5 guests