Image. Is possible to add one?

New to FreeBASIC? Post your questions here.
Luis Babboni
Posts: 303
Joined: Mar 15, 2015 12:41

Image. Is possible to add one?

Postby Luis Babboni » Dec 12, 2017 18:33

Hi people!

Is possible to put an image loaded from somewhere as a background in the screen?

Thanks.
MrSwiss
Posts: 3634
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Image. Is possible to add one?

Postby MrSwiss » Dec 12, 2017 19:19

Sure, no problem ... (only: if you overwrite the IMG, then clear it, you'll have to:
Put the IMG first again, before new overwrite)
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Image. Is possible to add one?

Postby lizard » Dec 12, 2017 19:24

Without other libraries it is only possible to load and save .bmp:

Code: Select all

Screen 19, 32
Dim As Any Ptr bild
Dim As String datei
Dim As Integer breite, hoehe

datei = "DeinBild.bmp"
breite = 467
hoehe = 236

bild = ImageCreate(breite, hoehe, 0)
BLoad datei, bild
Put (100, 100), bild, PSet

Sleep

ImageDestroy(bild)
Luis Babboni
Posts: 303
Joined: Mar 15, 2015 12:41

Re: Image. Is possible to add one?

Postby Luis Babboni » Dec 12, 2017 23:34

Thanks! I´ll try it tomorrow! :-)
Luis Babboni
Posts: 303
Joined: Mar 15, 2015 12:41

Re: Image. Is possible to add one?

Postby Luis Babboni » Dec 13, 2017 12:26

Nice, works perfect! :-)

I have a problem now.
If I maximized the window, I have now way to minimize it again.
How to do it or directly to not allow to maximize it?

Thanks!
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Image. Is possible to add one?

Postby lizard » Dec 13, 2017 13:50

Luis Babboni wrote:If I maximized the window, I have now way to minimize it again.
How to do it or directly to not allow to maximize it?


I wonder how you can maximize. Here it is only possible to minimize. Because Screen 19 means fixed size 800 x 600. Better use Screenres with desired resolution. See docs for all the possibilities. Simply replace Screen 19,32 with Screenres 1024,768, 32 or similar. Note the picture should change with the choosen colordepth. If you want full screen you could use:


Code: Select all

#Include "fbgfx.bi"

Dim as Integer  swidth, sheight
Dim As Any Ptr bild
Dim As String datei
Dim As Integer breite, hoehe


SCREENCONTROL FB.GET_DESKTOP_SIZE, swidth, sheight

IF SCREENRES(swidth, sheight,32,,FB.GFX_NO_FRAME or FB.GFX_ALWAYS_ON_TOP) THEN
  PRINT "Fehler: Grafikfenster konnte nicht initialisiert werden!"
  SLEEP
  END
END If


datei = "ma002.bmp"
breite = 467
hoehe = 236

bild = ImageCreate(breite, hoehe, 0)
BLoad datei, bild
Put (100, 100), bild, PSet

Sleep


If you want a frame you can delete "FB.GFX_NO_FRAME or".
UEZ
Posts: 635
Joined: May 05, 2017 19:59
Location: Germany

Re: Image. Is possible to add one?

Postby UEZ » Dec 13, 2017 18:39

If you don't care about Linux compatibility you can use GDIPlus to load / save in various image formats.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Image. Is possible to add one?

Postby lizard » Dec 13, 2017 20:16

There are a lot of libraries who can load more graphics formats. Depending what you are planning to work on. Naturally if you are italian you will choose a library with good italian docs.
MrSwiss
Posts: 3634
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Image. Is possible to add one?

Postby MrSwiss » Dec 13, 2017 23:28

The simplest way to use multiple file formats (loading, incl. .PNG saving) and,
still staying multi platform, is:
FBImage, from "Libraries" section of forum ... (by D.J.Peters, aka: Joshy)
Luis Babboni
Posts: 303
Joined: Mar 15, 2015 12:41

Re: Image. Is possible to add one?

Postby Luis Babboni » Dec 14, 2017 1:35

I have no problem with ,bmp, is fine for me.
What I try to do and could not is to avoid the possibilitie that someone click by mistake in "enlarge the screen" (the square at the left of the cross to close window). Or if it is not possible to avoid it, be able to return to the orginal size.
paul doe
Posts: 1319
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Image. Is possible to add one?

Postby paul doe » Dec 14, 2017 10:50

Luis Babboni wrote:I have no problem with ,bmp, is fine for me.
What I try to do and could not is to avoid the possibilitie that someone click by mistake in "enlarge the screen" (the square at the left of the cross to close window). Or if it is not possible to avoid it, be able to return to the orginal size.

You can do it setting the 'gfx_no_switch' flag, defined in 'fbgfx.bi', in the call to screenRes. Like this:

Code: Select all

#include once "fbgfx.bi"

screenRes( 800, 600, 32, , fb.gfx_no_switch )

sleep()

Look in the wiki page for the full explanation on the possibilities of screenRes: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgScreenres
Luis Babboni
Posts: 303
Joined: Mar 15, 2015 12:41

Re: Image. Is possible to add one?

Postby Luis Babboni » Dec 14, 2017 14:27

Nice! Thanks Paul!
paul doe
Posts: 1319
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Image. Is possible to add one?

Postby paul doe » Dec 14, 2017 15:30

Luis Babboni wrote:Nice! Thanks Paul!

My pleasure.

Return to “Beginners”

Who is online

Users browsing this forum: Baidu [Spider] and 4 guests