Stitch-up

General FreeBASIC programming questions.
dodicat
Posts: 6542
Joined: Jan 10, 2006 20:30
Location: Scotland

Stitch-up

Postby dodicat » Jun 30, 2012 2:46

Just signed up to mediafire, thought I would try it out:

http://www.mediafire.com/?6add6bi398bz26j
Richard
Posts: 3023
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Stitch-up

Postby Richard » Jun 30, 2012 3:59

@ dodicat
Can you not find a site with less advertisments?

In create knot, the first For loop, your line;
Alpha = Alpha + 2*PI / SCALING_FACTOR2
to close the knot, should be something like;
Alpha = Alpha + 2*PI / (SCALING_FACTOR2 – 4 )

Now we all await Mr. Redditt's revenge.
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Re: Stitch-up

Postby pestery » Jun 30, 2012 8:02

Ah, the old glStencilxxx commands. Just had one small problem with the example. GL_BGRA was not defined, but including GL/glext.bi fixed the problem. Cool example by the way :-)

Regarding mediafire, I've been using it for a while and it seems to be pretty good. It's free, seems to be reliable, no time limit on uploaded files and you can upload as much as you want (as far as I know anyway). As Richard said, there is a bit of advertising but I find it doesn't get it the way like is does on some other sites.
Roland Chastain
Posts: 859
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Stitch-up

Postby Roland Chastain » Jun 30, 2012 9:20

Very nice program !

dodicat, if you want a folder on my little web site, just say it to me !
roland{.}chastain{at}yahoo{.}fr

Else, you could post your examples here. I don't know if there is an english equivalent.
dodicat
Posts: 6542
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Stitch-up

Postby dodicat » Jul 03, 2012 0:20

Thanks for the feedback.

I left a little space, it looks better?

fb23 doesn't need glext.bi , but fb24 does I see.

Roland Chastain, I might take you up on that.
I like your Philosophy bit.
I've just been watching (on the tele), Bentham, Kant and Aristotle's ideas on Justice.

Seemingly we are all living in a Bentham type situation now. But hey, anybody who gets themselves stuffed and preserved and put on public exhibition can't be ALL bad?
Roland Chastain
Posts: 859
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Stitch-up

Postby Roland Chastain » Jul 03, 2012 7:50

dodicat wrote:I might take you up on that.


I have learned an english expression this morning. Good !

It could look like this :

stitchup.bas

When you want to me to add or to remove something, just send it to me in an e-mail.

dodicat wrote:I like your Philosophy bit.


Thanks !

Roland
srvaldez
Posts: 2455
Joined: Sep 25, 2005 21:54

Re: Stitch-up

Postby srvaldez » Jul 04, 2012 13:26

hi dodicat
how did you convert the image to data statements?
btw it runs OK, 64 fps
dodicat
Posts: 6542
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Stitch-up

Postby dodicat » Jul 04, 2012 21:30

Hi srvaldez.
Hope you are feeling a bit better.
I've got a couple of methods, here's one for colour data for every bitmap pixel.
This is the one I used for Stitch-up.
Compile to exe, then drag and drop a bitmap into it.
(You have screen 20 here, so it will do a reasonably large bitmap, say 800 by 600 for example.
You'll get a file two_sprite.bas, which is a runner and contains data.
Mind you, for even 800 X 600 the data is massive.
It might take five seconds to compile two_sprite.bas.
The file size in Kb is bigger than the actual bitmap in Kb, but I suppose this is to be expected, since 10 characters are needed to define each pixel colour.
Here's the file, just follow the instructions when you use it.

Code: Select all



'Data maker
'compile this to .exe
'drag a .bmp file on to the this executable
'it will create two_sprite.bas (somewhere)
'run two_sprite.bas to view the bitmap data and test the conversion.
Screen 20,32
open "two_sprite.bas" for output as #2

Type bitmap_size
    As Integer across,down
End Type

Dim  mybitmap As String =Command(1)


Redim shared As uInteger pixel_colours(0,0) 'shared to increase potential size

Function size(bmp As String) As bitmap_size 'fetch bitmap width/height
    Dim As Integer w,h
    Open bmp For Binary As #1
    Get #1, 19, w
    Get #1, 23, h
    Close #1
    Return Type<bitmap_size>(w,h)
End Function

Sub load(bmp As String,pixels() As Integer) 'load bitmap into array of point colours
    Bload bmp
    dim count as integer
    dim as string comma=","
    dim as string dash="_"
    Dim temp As bitmap_size=size(bmp)
    Redim pixels(temp.across,temp.down)
    dim max as integer=(1+temp.across)*(1+temp.down)
    For x As Integer=0 To temp.across
        For y As Integer=0 To temp.down
            count=count+1
            pixels(x,y)=Point(x,y)
            if count=max then
                comma=""
                dash=""
            end if
            print #2,"&H"& hex(point(x,y))&comma;
            if count mod 8=0 then print #2,dash
        Next y
    Next x
   
End Sub

'Use mouse or keys to move bitmap in this run
Sub drawbitmap(mx As Integer,my As Integer,mybitmap As bitmap_size,scale as single=1)
    #macro magnify(pivotx,pivoty,px,py,scale)
    var rotx=scale*(px-pivotx)+pivotx
    var roty=scale*(py-pivoty)+pivoty
    #endmacro
    For x As Integer=mx To mx+mybitmap.across
        For y As Integer=my To my+mybitmap.down
            'Pset (x,y),pixel_colours(x-mx,y-my)
            magnify(mx,my,x,y,scale)
            line(rotx-scale/2,roty-scale/2)-(rotx+scale/2,roty+scale/2),pixel_colours(x-mx,y-my),BF
        Next y
    Next x
   
End Sub
'____________________________
Sub framecounter
    Static As double frame,fps
    frame=frame+1
    Static As double t1,t2
    If frame>=fps Then
        t1 = Timer
        fps = frame/(t1-t2)
        Windowtitle "Frames per second = " & fps
        t2=Timer
        frame=0
    End If
End Sub
'______________________________________
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Dim As bitmap_size bitmap_info=size(mybitmap) 'get height/width of bitmap
print #2,"redim shared as uinteger a(";str(bitmap_info.across);",";str(bitmap_info.down);")"
print #2 ,"DATA _"
draw string(bitmap_info.across,bitmap_info.down), "PLEASE WAIT"
load mybitmap,pixel_colours() 'set bitmap into an array

'variables for the mouse and arrow keys
Dim As Integer mx,my,mw,mb,copymx,copymy
dim as string i
'Testing loop for this section.
Do
    Getmouse(mx,my,mw,mb)
    if mb=2 then exit do
    if mw<0 then mw=10
    if mw=0 then mw=1
    If mb=1 Then
        copymx=mx:copymy=my
    End If
    i=inkey
    if i= chr(255) + "K"  then copymx=copymx-5
    if i= chr(255) + "M"  then copymx=copymx+5
    if i= chr(255) + "P"  then copymy=copymy+5
    if i= chr(255) + "H"  then copymy=copymy-5
   
    Screenlock
    Cls
   
    drawbitmap(copymx,copymy,bitmap_info,mw/10) 'SCALE
    draw string(20,20),"TURN MOUSE WHEEL  --- MAGNIFICATION = "&str(mw/10)
    draw string(20,50),"END AT THE REQUIRED MAGNIFICATION"
    draw string(20,80),"LEFT CLICK TO SHIFT IMAGE"
    draw string(20,110),"ESC OR RIGHT CLICK TO END"
   
    framecounter
   
    Screenunlock
    Sleep 1,1
   
Loop Until i=Chr(27)
'Running code
print #2," "

print #2,"screen 20,32"
print #2,"dim as double magnification"
print #2,"magnification= ";mw/10
print #2,"Type bitmap_size"
print #2,"As Integer across,down"
print #2,"End Type"

print #2,"sub read_data(mybitmap as bitmap_size)"
'print #2,"dim as uinteger temp"
print #2,"for x as integer=0 to mybitmap.across"
print #2,"for y as integer=0 to mybitmap.down"
print #2,"read a(x,y)"
print #2,"next y"
print #2,"next x"
print #2,"end sub"

print #2,"dim shared as any pointer image"
print #2,"image=imagecreate(magnification*ubound(a,1),magnification*ubound(a,2))"

print #2,"Sub drawbitmap_to_image(mybitmap As bitmap_size,scale as single=1,mx As Integer=0,my As Integer=0)"
print #2,"#macro magnify(pivotx,pivoty,px,py,scale)"
print #2,"var rotx=scale*(px-pivotx)+pivotx"
print #2,"var roty=scale*(py-pivoty)+pivoty"
print #2,"#endmacro"
print #2,"For x As Integer=mx To mx+mybitmap.across"
print #2,"For y As Integer=my To my+mybitmap.down"
print #2,"magnify(mx,my,x,y,scale)"
print #2,"line image,(rotx-scale/2,roty-scale/2)-(rotx+scale/2,roty+scale/2),a(x-mx,y-my),BF"
print #2,"Next y"
print #2,"Next x"
print #2,"End Sub"

print #2,"Dim As bitmap_size bitmap_info"
print #2,"bitmap_info.across=ubound(a)"
print #2,"bitmap_info.down=ubound(a,2)"
print #2,"read_data(bitmap_info)"
print #2,"drawbitmap_to_image(bitmap_info,magnification)"
print #2,"'BITMAP image is now in image"
print #2,"'This just displays the image"
print #2,"dim as string i"
print #2,"Do"
print #2,"i=inkey"
print #2,"Screenlock"
print #2,"Cls"
print #2,"locate 2,2"
print #2,"print ""magnification ="";";mw/10
print #2,"put(";copymx;",";copymy;"),image,pset"
print #2,"Screenunlock"
print #2,"Sleep 1,1"
print #2,"Loop Until i=Chr(27)"
print #2,"imagedestroy image"
close #2
locate 10,10
print "SAVED -- two_sprite.bas is your file"
print "Press a key to end"
sleep

 
srvaldez
Posts: 2455
Joined: Sep 25, 2005 21:54

Re: Stitch-up

Postby srvaldez » Jul 04, 2012 23:45

thank you dodicat :)
yes I am getting better although a bit slow.
albert
Posts: 5701
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Stitch-up

Postby albert » Jul 07, 2012 7:09

@dodicat and Richard

I can't go on mediafire from my apartments ethernet. I'll have to go to the library to download it.
I was putting my programs on mediafire. They allow 2 gigabytes of throughput off each free account a month.

The apartment complex won't allow the site to come up , because lots of the potential downloads have viruses and pirated,copyrighted materials, and they don't want infected or sued.

Where are you guys getting FB 0.24, the NEWS section of the main board still say FB 0.23 ?
albert
Posts: 5701
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Stitch-up

Postby albert » Jul 07, 2012 7:25

Back when i first got linux, in the late 90's

I found a method of enlarging small thumbnail jpg's to full screen size without pixelating the picture.

1) load the small pict into GIMP , gausian blur it to 1
2) double the size of the pict.
3) load pict into XView and sharpen to 75 (XView was commercial and redhat 5.0 had permission to use it in their distro, the GIMP sharpen doesn't work too good and neither does ImageMagik sharpen.)
4) load pict into GIMP or ImageMagik and oilify to .5
5) I cant remenber if 4 is the last step or if theres another. but just keep going 1 to 4 or 5 until the image is the size you want.

you might have to resharpen after the oilify, im not sure.
And it might be Gausian blur to .5 and oilify to 1, its one of the two.

but you can take one of those little thumbnail 75x75 jpg's and blow it up to 1024x768 fully clear and no pixelation.
dodicat
Posts: 6542
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Stitch-up

Postby dodicat » Jul 07, 2012 8:07

@Albert
Roland Chastain has the file on his site, four posts back.
Just click the link and as by magic you get the code.
Why don't you apply for the job as the appartment software guy, and get rid of silly rules?

Fb24, down at the page bottom.
The 33Mb download includes gcc.

http://www.freebasic-portal.de/download ... uilds.html
Roland Chastain
Posts: 859
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Stitch-up

Postby Roland Chastain » Jun 25, 2015 8:08

Hello!

I just tried to compile stitchup.bas with FBC 1.02.1. I mean the file from my website, not the file from MediaFire. The file from my website has one more line:

Code: Select all

#include once "GL/glext.bi"


I get errors:

FreeBASIC Compiler - Version 1.02.1 (04-25-2015), built for win32 (32bit)
c:\freebasic\inc\GL\windows\glext.bi(52) error 58: Illegal specification, at parameter 1 (mode) in 'type PFNGLDRAWRANGEELEMENTSPROC as sub(byval mode as GLenum, byval start as GLuint, byval end as GLuint, byval count as GLsizei, byval type as GLenum, byval indices as const any ptr)'
c:\freebasic\inc\GL\windows\glext.bi(53) error 58: Illegal specification, at parameter 1 (target) in 'type PFNGLTEXIMAGE3DPROC as sub(byval target as GLenum, byval level as GLint, byval internalformat as GLint, byval width as GLsizei, byval height as GLsizei, byval depth as GLsizei, byval border as GLint, byval format as GLenum, byval type as GLenum, byval pixels as const any ptr)'
...


I imagine that the problem has already been discussed somewhere, but I found nothing.
grindstone
Posts: 726
Joined: May 05, 2015 5:35
Location: Germany

Re: Stitch-up

Postby grindstone » Jun 25, 2015 9:29

Hi Roland!

Maybe you're looking for this: http://www.freebasic.net/forum/viewtopic.php?f=14&t=19316

I've played around with it a little. stitchup.bas compiles if you add

Code: Select all

#include once "GL/gl.bi"
as first line of the code.

Regards
grindstone
dkl
Site Admin
Posts: 3211
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Stitch-up

Postby dkl » Jun 25, 2015 9:34

Hello,

looks like the new inc/GL/windows/glext.bi is missing an #include "GL/gl.bi" at its top, that probably got lost somewhere when I made the new OpenGL bindings. #including GL/gl.bi before GL/glext.bi should work as a temporary work-around. But I'll update glext.bi for the next FB release to do it automatically.

Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests