October 29, 2025, 07:13:38 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Using a bitmap as a window background

Started by Rock Ridge Farm (Larry), December 05, 2008, 06:54:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rock Ridge Farm (Larry)

I have a small bitmap that I would like to fill the background of a window.
How do I do that?

Allan

Hi Larry

There is a sample prog called imgview.eba in the EBasic Projects folder that might contain what you are wanting to use. ?

allan

pistol350

December 06, 2008, 01:09:12 AM #2 Last Edit: December 06, 2008, 01:33:17 AM by pistol350
Assuming i fully understood what you said,
you are trying to use a bitmap as a tile to fill the background of your window.
I know of a sample code that you can use to do that.
It's called bitmaptiler or something.
I'll do a search using the famous retriever program written by Allan ;)

EDIT : FOUND IT !!!
Finding specific sample codes among hundreds others becomes so easy when using RETRIEVER !!!  :D


' bitmap tiler
def w1 : window
def filename, path : string
def filter, test : string
def handle, flag : uint
def i, found : int

filter = "Bitmap|*.bmp||"
path = getstartpath

openwindow w1,0,0,800,600,@MINBOX|@MAXBOX|@SIZE,NULL,"Bitmap Tiler",&main
beginmenu w1
    menutitle "Option"
        menuitem "Select a bitmap", 0, 1
        separator
        menuitem "Quit", 0, 2
endmenu


waituntil w1 = 0
if flag = 1 then deleteimage handle, @IMGBITMAP
end

'*************************************************
sub main()
select @MESSAGE
    case @IDCLOSEWINDOW
        closewindow w1
    case @IDMENUPICK
        select @MENUNUM
            case 1:  ' user selected "Select a bitmap" in menu
                filename = filerequest ("Select a bitmap.", w1, 1 , filter, "bmp",0 ,path)
            found=0     
            ' I want to stay in the same directory if I load another image
            for i = len(filename) to 1 step -1
                  test = mid$(filename,i,1)
                  if (test="\\")&(found=0) : ' Find the last  occurrence of the downslash
                     found = i   
                  endif
            next i
            if found > 0 then path=left$(filename,found) : ' cut the filename from the path
            if flag =1 : ' a bitmap is loaded so clear the memory
               deleteimage handle, @IMGBITMAP
               flag = 0
            endif
            lay_tiles()
            case 2: ' user selected "Quit" in menu
                closewindow w1
        endselect
endselect
return
endsub

'*************************************************
sub lay_tiles()
def w, h, x, y : uint

handle = loadimage (filename,@IMGBITMAP)
flag = 1 : ' An image is loaded
getbitmapsize handle,w,h : ' Need to find these values for tiling
for x = 0 to 1023 step w : ' leave extra room if the image is maximised
   for y = 0 to 765 step h
      showimage w1, handle, @IMGBITMAP, x, y , w, h
   next y
next x
setcaption w1, filename + "  Width = " + str$(w) + "  Height = " + str$(h) : ' info for the user
return
endsub

'*************************************************
Regards,

Peter B.

Rock Ridge Farm (Larry)


Allan

Thanks Pistol350 for using Retriever.

We have developed three new Retriever programs now and they are much more helpful. (EB, CB and IB)

The new Retriever allows you to View the Searched For text and gives the Line numbers in the code which enables you to get to the source quickly.

PS - That is how I found ImgView.eba file   :P

Allan

pistol350

I may not have this brand new version or i'd pay attention to that option.
Regards,

Peter B.

Allan

Like to see a demo of the new Retriever, Pistol350?

Here is a link that is on our Retriever web page (just set up recently).

http://home.iprimus.com.au/bizzypak/retriever/CBRet.zip

It is said you need a good slogan so we hope this one we chose is appropriate with todays modern lingo:-


Be a Kung Fu Master with your Coding - use Retriever


Allan

pistol350

Regards,

Peter B.