EZ-DRAW 1.2 graphic static lib win/linux
EZ-DRAW 1.2 graphic static lib win/linux
2 very litle static libs EZ-Draw and EZ-Image done in c and very easy to use from Freebasic
EZ-Draw use GDI on windows and X11 on linux (even Mac) , so it gives the possibility to create portable code in Freebasic with very light size.
Comparing to the native FreeBasic graphic features : A very good point, is the ability to open as many windows as you want as the same time.
EZ-Image will open the most commun format jpg; png; bmp; gif
I've compiled for win 32/64 and same for linux
2 .bi files to work with are also done, and some examples of use from Freebasic
posted here https://github.com/marpon/EZ-DrawFb
original c code EZ_DRAW 1.2 see https://pageperso.lif.univ-mrs.fr/~edou ... ex-en.html
EZ-Draw use GDI on windows and X11 on linux (even Mac) , so it gives the possibility to create portable code in Freebasic with very light size.
Comparing to the native FreeBasic graphic features : A very good point, is the ability to open as many windows as you want as the same time.
EZ-Image will open the most commun format jpg; png; bmp; gif
I've compiled for win 32/64 and same for linux
2 .bi files to work with are also done, and some examples of use from Freebasic
posted here https://github.com/marpon/EZ-DrawFb
original c code EZ_DRAW 1.2 see https://pageperso.lif.univ-mrs.fr/~edou ... ex-en.html
Re: EZ-DRAW 1.2 graphic static lib win/linux
Mmm, might be quite useful, indeed. Thanks for sharing.
-
- Posts: 165
- Joined: Apr 19, 2019 19:03
Re: EZ-DRAW 1.2 graphic static lib win/linux
Interesting and works all in first attempt here on linux.
Re: EZ-DRAW 1.2 graphic static lib win/linux
happy it works , did you test with linux 32 or linux 64?Knatterton wrote:Interesting and works all in first attempt here on linux.
Interrested to know because i've not tested on linux 32,
and I've compiled the 32bits c libs for linux from gcc64 with -m32 flag , but not sure if it is correct.
-
- Posts: 165
- Joined: Apr 19, 2019 19:03
Re: EZ-DRAW 1.2 graphic static lib win/linux
In linux 64 all worked. Now i have booted up in linux 32 to test, there is the error messagemarpon wrote:happy it works , did you test with linux 32 or linux 64?Knatterton wrote:Interesting and works all in first attempt here on linux.
Interrested to know because i've not tested on linux 32,
and I've compiled the 32bits c libs for linux from gcc64 with -m32 flag , but not sure if it is correct.
Code: Select all
./libez-draw_l32.a(ez-draw.o):(.data+0x0): Mehrfachdefinition von `ez_get_RGB'
Re: EZ-DRAW 1.2 graphic static lib win/linux
Tested on scientific Linux (Red Hat) 32 bits.
Same error as Knatterton
[dodicat@localhost EZ-DrawFb-master]$ fbc test_draw.bas
./libez-draw_l32.a(ez-draw.o):(.data+0x0): multiple definition of `ez_get_RGB'
test_draw.o:(.bss+0x0): first defined here
[dodicat@localhost EZ-DrawFb-master]$
Same error as Knatterton
[dodicat@localhost EZ-DrawFb-master]$ fbc test_draw.bas
./libez-draw_l32.a(ez-draw.o):(.data+0x0): multiple definition of `ez_get_RGB'
test_draw.o:(.bss+0x0): first defined here
[dodicat@localhost EZ-DrawFb-master]$
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: EZ-DRAW 1.2 graphic static lib win/linux
Yes the declaration are wrong there are more issues I fixed last night.
file: ez-draw.bi
file: ez-image.biThis test shows you how to get the debug output from the library (if __FB_DEBUG__ set with -g)
and how you can overwrite the white background color of all the windows.
Joshy
file: test01.bas
file: ez-draw.bi
Code: Select all
#ifndef __EZ_DRAW_BI__
#define __EZ_DRAW_BI__
#include once "crt/stdio.bi"
#ifdef __FB_WIN32__
const EZ_BASE_WIN32 = 1
#include once "crt/sys/win32/time.bi"
#include once "windows.bi"
#include once "win/wingdi.bi"
#include once "win/windowsx.bi"
' #libpath "libs"
#ifndef __FB_64BIT__
#inclib "ez-draw_w32"
#else
#inclib "ez-draw_w64"
#endif
const XK_BackSpace = &hff08
const XK_Tab = &hff09
const XK_Return = &hff0d
const XK_Pause = &hff13
const XK_Scroll_Lock = &hff14
const XK_Escape = &hff1b
const XK_Delete = &hffff
const XK_Home = &hff50
const XK_Left = &hff51
const XK_Up = &hff52
const XK_Right = &hff53
const XK_Down = &hff54
const XK_Prior = &hff55
const XK_Next = &hff56
const XK_End = &hff57
const XK_Insert = &hff63
const XK_Menu = &hff67
const XK_Num_Lock = &hff7f
const XK_KP_Enter = &hff8d
const XK_KP_Home = &hff95
const XK_KP_Left = &hff96
const XK_KP_Up = &hff97
const XK_KP_Right = &hff98
const XK_KP_Down = &hff99
const XK_KP_Prior = &hff9a
const XK_KP_Next = &hff9b
const XK_KP_End = &hff9c
const XK_KP_Begin = &hff9d
const XK_KP_Equal = &hffbd
const XK_KP_Multiply = &hffaa
const XK_KP_Add = &hffab
const XK_KP_Separator = &hffac
const XK_KP_Subtract = &hffad
const XK_KP_Divide = &hffaf
const XK_KP_0 = &hffb0
const XK_KP_1 = &hffb1
const XK_KP_2 = &hffb2
const XK_KP_3 = &hffb3
const XK_KP_4 = &hffb4
const XK_KP_5 = &hffb5
const XK_KP_6 = &hffb6
const XK_KP_7 = &hffb7
const XK_KP_8 = &hffb8
const XK_KP_9 = &hffb9
const XK_F1 = &hffbe
const XK_F2 = &hffbf
const XK_F3 = &hffc0
const XK_F4 = &hffc1
const XK_F5 = &hffc2
const XK_F6 = &hffc3
const XK_F7 = &hffc4
const XK_F8 = &hffc5
const XK_F9 = &hffc6
const XK_F10 = &hffc7
const XK_F11 = &hffc8
const XK_F12 = &hffc9
const XK_Shift_L = &hffe1
const XK_Shift_R = &hffe2
const XK_Control_L = &hffe3
const XK_Control_R = &hffe4
const XK_Caps_Lock = &hffe5
const XK_Meta_L = &hffe7
const XK_Meta_R = &hffe8
const XK_Alt_L = &hffe9
const XK_Alt_R = &hffea
const XK_space = &h0020
const XK_exclam = &h0021
const XK_quotedbl = &h0022
const XK_numbersign = &h0023
const XK_dollar = &h0024
const XK_percent = &h0025
const XK_ampersand = &h0026
const XK_apostrophe = &h0027
const XK_parenleft = &h0028
const XK_parenright = &h0029
const XK_asterisk = &h002a
const XK_plus = &h002b
const XK_comma = &h002c
const XK_minus = &h002d
const XK_period = &h002e
const XK_slash = &h002f
const XK_0 = &h0030
const XK_1 = &h0031
const XK_2 = &h0032
const XK_3 = &h0033
const XK_4 = &h0034
const XK_5 = &h0035
const XK_6 = &h0036
const XK_7 = &h0037
const XK_8 = &h0038
const XK_9 = &h0039
const XK_colon = &h003a
const XK_semicolon = &h003b
const XK_less = &h003c
const XK_equal = &h003d
const XK_greater = &h003e
const XK_question = &h003f
const XK_at = &h0040
const XK_A = &h0041
const XK_B = &h0042
const XK_C = &h0043
const XK_D = &h0044
const XK_E = &h0045
const XK_F = &h0046
const XK_G = &h0047
const XK_H = &h0048
const XK_I = &h0049
const XK_J = &h004a
const XK_K = &h004b
const XK_L = &h004c
const XK_M = &h004d
const XK_N = &h004e
const XK_O = &h004f
const XK_P = &h0050
const XK_Q = &h0051
const XK_R = &h0052
const XK_S = &h0053
const XK_T = &h0054
const XK_U = &h0055
const XK_V = &h0056
const XK_W = &h0057
const XK_X = &h0058
const XK_Y = &h0059
const XK_Z = &h005a
const XK_bracketleft = &h005b
const XK_backslash = &h005c
const XK_bracketright = &h005d
const XK_asciicircum = &h005e
const XK_underscore = &h005f
const XK_grave = &h0060
' !!! FreeBASIC isn't case sensitive so I added an underscore !!!
const XK_a_ = &h0061
const XK_b_ = &h0062
const XK_c_ = &h0063
const XK_d_ = &h0064
const XK_e_ = &h0065
const XK_f_ = &h0066
const XK_g_ = &h0067
const XK_h_ = &h0068
const XK_i_ = &h0069
const XK_j_ = &h006a
const XK_k_ = &h006b
const XK_l_ = &h006c
const XK_m_ = &h006d
const XK_n_ = &h006e
const XK_o_ = &h006f
const XK_p_ = &h0070
const XK_q_ = &h0071
const XK_r_ = &h0072
const XK_s_ = &h0073
const XK_t_ = &h0074
const XK_u_ = &h0075
const XK_v_ = &h0076
const XK_w_ = &h0077
const XK_x_ = &h0078
const XK_y_ = &h0079
const XK_z_ = &h007a
const XK_braceleft = &h007b
const XK_bar = &h007c
const XK_braceright = &h007d
const XK_asciitilde = &h007e
const XK_nobreakspace = &h00a0
const XK_exclamdown = &h00a1
const XK_cent = &h00a2
const XK_sterling = &h00a3
const XK_currency = &h00a4
const XK_yen = &h00a5
const XK_brokenbar = &h00a6
const XK_section = &h00a7
const XK_diaeresis = &h00a8
const XK_copyright = &h00a9
const XK_ordfeminine = &h00aa
const XK_guillemotleft = &h00ab
const XK_notsign = &h00ac
const XK_hyphen = &h00ad
const XK_registered = &h00ae
const XK_macron = &h00af
const XK_degree = &h00b0
const XK_plusminus = &h00b1
const XK_twosuperior = &h00b2
const XK_threesuperior = &h00b3
const XK_acute = &h00b4
const XK_mu = &h00b5
const XK_paragraph = &h00b6
const XK_periodcentered = &h00b7
const XK_cedilla = &h00b8
const XK_onesuperior = &h00b9
const XK_masculine = &h00ba
const XK_guillemotright = &h00bb
const XK_onequarter = &h00bc
const XK_onehalf = &h00bd
const XK_threequarters = &h00be
const XK_questiondown = &h00bf
const XK_Agrave = &h00c0
const XK_Aacute = &h00c1
const XK_Acircumflex = &h00c2
const XK_Atilde = &h00c3
const XK_Adiaeresis = &h00c4
const XK_Aring = &h00c5
const XK_AE = &h00c6
const XK_Ccedilla = &h00c7
const XK_Egrave = &h00c8
const XK_Eacute = &h00c9
const XK_Ecircumflex = &h00ca
const XK_Ediaeresis = &h00cb
const XK_Igrave = &h00cc
const XK_Iacute = &h00cd
const XK_Icircumflex = &h00ce
const XK_Idiaeresis = &h00cf
const XK_ETH = &h00d0
const XK_Ntilde = &h00d1
const XK_Ograve = &h00d2
const XK_Oacute = &h00d3
const XK_Ocircumflex = &h00d4
const XK_Otilde = &h00d5
const XK_Odiaeresis = &h00d6
const XK_multiply = &h00d7
const XK_Oslash = &h00d8
const XK_Ugrave = &h00d9
const XK_Uacute = &h00da
const XK_Ucircumflex = &h00db
const XK_Udiaeresis = &h00dc
const XK_Yacute = &h00dd
const XK_THORN = &h00de
const XK_ssharp = &h00df
' !!! FreeBASIC isn't case sensitive so I added an underscore !!!
const XK_agrave_ = &h00e0
const XK_aacute_ = &h00e1
const XK_acircumflex_ = &h00e2
const XK_atilde_ = &h00e3
const XK_adiaeresis_ = &h00e4
const XK_aring_ = &h00e5
const XK_ae_ = &h00e6
const XK_ccedilla_ = &h00e7
const XK_egrave_ = &h00e8
const XK_eacute_ = &h00e9
const XK_ecircumflex_ = &h00ea
const XK_ediaeresis_ = &h00eb
const XK_igrave_ = &h00ec
const XK_iacute_ = &h00ed
const XK_icircumflex_ = &h00ee
const XK_idiaeresis_ = &h00ef
const XK_eth_ = &h00f0
const XK_ntilde_ = &h00f1
const XK_ograve_ = &h00f2
const XK_oacute_ = &h00f3
const XK_ocircumflex_ = &h00f4
const XK_otilde_ = &h00f5
const XK_odiaeresis_ = &h00f6
const XK_division_ = &h00f7
const XK_oslash_ = &h00f8
const XK_ugrave_ = &h00f9
const XK_uacute_ = &h00fa
const XK_ucircumflex_ = &h00fb
const XK_udiaeresis_ = &h00fc
const XK_yacute_ = &h00fd
const XK_thorn_ = &h00fe
const XK_ydiaeresis_ = &h00ff
const XK_EuroSign_ = &h20ac
#elseif defined(__FB_LINUX__)
#include once "crt/sys/linux/time.bi"
#include once "X11/Xlib.bi"
#include once "X11/Xutil.bi"
#include once "X11/Xresource.bi"
#include once "X11/keysym.bi"
#include once "X11/extensions/Xdbe.bi"
#inclib "X11"
#inclib "Xext"
#inclib "m"
'#libpath "libs"
#ifndef __FB_64BIT__
#inclib "ez-draw_l32"
#else
#inclib "ez-draw_l64"
#endif
const EZ_BASE_XLIB = 1
#else
#error 666, Build target must be Windows or Linux !
#endif
const EZ_FONT_MAX = 16
const EZ_TIMER_MAX = 100
const EZ_WIN_MAX = 1024
'#define EZ_ROUND(x) iif((x) < 0, clng((x) - 0.5), clng((x) + 0.5))
#ifdef __FB_WIN32__
type Ez_window as HWND ' pointer 32/64bit
#else
type Ez_window as Window ' long 32-bit
#endif
type Ez_Align as long
enum
EZ_AA = 183200,
EZ_TL, EZ_TC, EZ_TR,
EZ_ML, EZ_MC, EZ_MR,
EZ_BL, EZ_BC, EZ_BR,
EZ_BB,
EZ_TLF, EZ_TCF, EZ_TRF,
EZ_MLF, EZ_MCF, EZ_MRF,
EZ_BLF, EZ_BCF, EZ_BRF,
EZ_CC
end enum
#ifdef __FB_WIN32__
type XdbeBackBuffer as HDC
type XEvent as MSG
type KeySym as long
type XContext as LPCTSTR
type XPoint as POINT
#define None NULL
#endif
#ifdef __FB_WIN32__
const KeyPress = 2
const KeyRelease = 3
const ButtonPress = 4
const ButtonRelease = 5
const MotionNotify = 6
const Expose = 12
const ConfigureNotify = 22
const ClientMessage = 33
const LASTEvent = 35
const EZ_TIMER1 = 208
enum
EZ_MSG_PAINT = WM_APP + 1
EZ_MSG_LAST
end enum
#endif
enum
#ifdef __FB_WIN32__
WindowClose = 35 + 1
#else
WindowClose = LASTEvent + 1
#endif
TimerNotify
EzLastEvent
end enum
type Ez_event
as long type
as Ez_window win
as long mx
as long my
as long mb
as long width
as long height
as KeySym key_sym
as zstring * 80 key_name
as zstring * 80 key_string
as long key_count
as XEvent xev
end type
#define EZ_CALLBACK cdecl
type Ez_func as sub EZ_CALLBACK (byref ev as Ez_event)
extern "C"
extern ez_black as ulong
extern ez_white as ulong
extern ez_grey as ulong
extern ez_red as ulong
extern ez_green as ulong
extern ez_blue as ulong
extern ez_yellow as ulong
extern ez_cyan as ulong
extern ez_magenta as ulong
declare function ez_error (byval fmt as const zstring ptr, ...) as ulong
' EZ library
declare function ez_init() as long
' disable=0 or enable=1 auto window closing (fefault)
declare sub ez_auto_quit(byval val as long)
' enter the GUI main loop
declare sub ez_main_loop()
' quit the GUI main loop
declare sub ez_quit()
' Ez_window constructor destructor
declare function ez_window_create(byval w as long, byval h as long, byval name as const zstring ptr, byval func as Ez_func) as Ez_window
declare sub ez_window_destroy(byval win as Ez_window)
' convert window handle to window ID
declare function ez_window_get_id(byval win as Ez_window) as long
' send an Expose event to the window, so as to empty the window and to force to redraw.
declare sub ez_send_expose(byval win as Ez_window)
' show=1 or hide=1 the window
declare sub ez_window_show(byval win as Ez_window, byval val as long)
' enable=1 or disable=0 flicker free double buffer drawing
declare sub ez_window_dbuf(byval win as Ez_window, byval val as long)
' clear the window
declare sub ez_window_clear(byval win as Ez_window)
' set or get the window resolution in pixels
declare sub ez_window_set_size(byval win as Ez_window, byval w as long, byval h as long)
declare sub ez_window_get_size(byval win as Ez_window, byval w as long ptr, byval h as long ptr)
' set or get userdata
declare sub ez_set_data(byval win as Ez_window, byval data as const any ptr)
declare function ez_get_data(byval win as Ez_window) as any ptr
' one shoot timer
declare sub ez_start_timer(byval win as Ez_window, byval delayMS as long)
' fixed sized font's
declare function ez_font_load(byval num as long, byval name as const zstring ptr) as long
declare sub ez_set_nfont(byval num as long)
' tools
declare function ez_random(byval n as long) as long
declare function ez_get_time() as double
' Ez_Color
extern ez_get_RGB as function(byval r as ubyte, byval g as ubyte, byval b as ubyte) as ulong
declare function ez_get_grey(byval g as ubyte) as ulong
' HSV to RGB triple
declare sub ez_HSV_to_RGB(byval h as double, byval s as double, byval v as double, byval r as ubyte ptr, byval g as ubyte ptr, byval b as ubyte ptr)
' HSV to Ez_color
declare function ez_get_HSV(byval h as double, byval s as double, byval v as double) as ulong
' set current drawing color
declare sub ez_set_color(byval colour as ulong)
' set current drawing thickness
declare sub ez_set_thick(byval thick as long)
' EZ drawing
declare sub ez_draw_point (byval win as Ez_window, byval x as long, byval y as long)
declare sub ez_draw_line (byval win as Ez_window, byval x1 as long, byval y1 as long, byval x2 as long, byval y2 as long)
declare sub ez_draw_rectangle(byval win as Ez_window, byval x1 as long, byval y1 as long, byval x2 as long, byval y2 as long)
declare sub ez_fill_rectangle(byval win as Ez_window, byval x1 as long, byval y1 as long, byval x2 as long, byval y2 as long)
declare sub ez_draw_triangle (byval win as Ez_window, byval x1 as long, byval y1 as long, byval x2 as long, byval y2 as long, byval x3 as long, byval y3 as long)
declare sub ez_fill_triangle (byval win as Ez_window, byval x1 as long, byval y1 as long, byval x2 as long, byval y2 as long, byval x3 as long, byval y3 as long)
declare sub ez_draw_circle (byval win as Ez_window, byval x1 as long, byval y1 as long, byval x2 as long, byval y2 as long)
declare sub ez_fill_circle (byval win as Ez_window, byval x1 as long, byval y1 as long, byval x2 as long, byval y2 as long)
declare sub ez_draw_text (byval win as Ez_window, byval align as Ez_Align, byval x as long, byval y as long, byval format as const zstring ptr, ...)
end extern
#endif ' __EZ_DRAW_BI__
Code: Select all
#ifndef __EZ_IMAGE_BI__
#define __EZ_IMAGE_BI__
#include once "ez-draw.bi"
#ifdef __FB_WIN32__
#ifndef __FB_64BIT__
#inclib "ez-image_w32"
#else
#inclib "ez-image_w64"
#endif
#elseif defined(__FB_LINUX__)
#ifndef __FB_64BIT__
#inclib "ez-image_l32"
#else
#inclib "ez-image_l64"
#endif
#else
#error 666, Build target must be Windows or Linux !
#endif
type Ez_image
as long width
as long height
as ubyte ptr pixels_rgba
as long has_alpha
as long opacity
end type
type Ez_pixmap
as long width
as long height
#ifdef __FB_WIN32__
as HBITMAP hmap
as long has_alpha
#else
as Pixmap map
as Pixmap mask
#endif
end type
extern "C"
' Ez_Image
declare function ez_image_load (byval filename as const zstring ptr) as Ez_image ptr
declare function ez_image_new () as Ez_image ptr
declare sub ez_image_destroy (byval img as Ez_image ptr)
declare function ez_image_create (byval width as long, byval height as long) as Ez_image ptr
declare function ez_image_dup (byval img as Ez_image ptr) as Ez_image ptr
declare sub ez_image_set_alpha (byval img as Ez_image ptr, byval has_alpha as long)
declare function ez_image_has_alpha (byval img as Ez_image ptr) as long
declare sub ez_image_set_opacity (byval img as Ez_image ptr, byval opacity as long)
declare function ez_image_get_opacity (byval img as Ez_image ptr) as long
declare sub ez_image_print (byval img as Ez_image ptr, byval src_x as long, byval src_y as long, byval w as long, byval h as long)
declare sub ez_image_fill_rgba (byval img as Ez_image ptr, byval r as ubyte, byval g as ubyte, byval b as ubyte, byval a as ubyte)
declare sub ez_image_blend (byval dst as Ez_image ptr, byval src as Ez_image ptr, byval dst_x as long, byval dst_y as long)
declare sub ez_image_blend_sub (byval dst as Ez_image ptr, byval src as Ez_image ptr, byval dst_x as long, byval dst_y as long, _
byval src_x as long, byval src_y as long, byval w as long, byval h as long)
declare function ez_image_extract (byval img as Ez_image ptr, byval x as long, byval y as long, byval w as long, byval h as long) as Ez_image ptr
declare function ez_image_sym_ver (byval img as Ez_image ptr) as Ez_image ptr
declare function ez_image_sym_hor (byval img as Ez_image ptr) as Ez_image ptr
declare function ez_image_scale (byval img as Ez_image ptr, byval factor as double) as Ez_image ptr
declare function ez_image_rotate (byval img as Ez_image ptr, byval theta as double, byval quality as long) as Ez_image ptr
declare sub ez_image_rotate_point(byval img as Ez_image ptr, byval theta as double, byval src_x as long, byval src_y as long, byval dst_x as long ptr, byval dst_y as long ptr)
declare sub ez_image_paint (byval win as Ez_window, byval img as Ez_image ptr, byval x as long, byval y as long)
declare sub ez_image_paint_sub (byval win as Ez_window, byval img as Ez_image ptr, byval x as long, byval y as long, byval src_x as long, byval src_y as long, byval w as long, byval h as long)
' Ez_pixmap
declare function ez_pixmap_new() as Ez_pixmap ptr
declare sub ez_pixmap_destroy(byval pix as Ez_pixmap ptr)
declare function ez_pixmap_create_from_image(byval img as Ez_image ptr) as Ez_pixmap ptr
declare sub ez_pixmap_paint(byval win as Ez_window, byval pix as Ez_pixmap ptr, byval x as long, byval y as long)
declare sub ez_pixmap_tile(byval win as Ez_window, byval pix as Ez_pixmap ptr, byval x as long, byval y as long, byval w as long, byval h as long)
' STBI image loader
enum
EZ_STBI_DEFAULT = 0
EZ_STBI_GREY = 1
EZ_STBI_GREY_ALPHA = 2
EZ_STBI_RGB = 3
EZ_STBI_RGB_ALPHA = 4
end enum
type Ez_stbi_io_callbacks
read as function(byval user as any ptr, byval data as zstring ptr, byval size as long) as long
skip as sub (byval user as any ptr, byval n as ulong)
eof as function(byval user as any ptr) as long
end type
declare function ez_stbi_info_from_memory(byval pBuffer as const ubyte ptr, _
byval nBuffersize as long, _
byval width as long ptr, _
byval height as long ptr, _
byval comp as long ptr) as long
declare function ez_stbi_load_from_memory(byval pBuffer as const ubyte ptr, _
byval nBuffersize as long, _
byval width as long ptr, _
byval height as long ptr, _
byval comp as long ptr, _
byval req_comp as long) as ubyte ptr
declare function ez_stbi_info(byval filename as const zstring ptr, _
byval Buffersize as long, _
byval width as long ptr, _
byval height as long ptr, _
byval comp as long ptr) as long
declare function ez_stbi_load(byval filename as const zstring ptr, _
byval width as long ptr, _
byval height as long ptr, _
byval comp as long ptr, _
byval req_comp as long) as ubyte ptr
declare function ez_stbi_info_from_file(byval f as FILE ptr, _
byval width as long ptr, _
byval height as long ptr, _
byval comp as long ptr) as long
declare function ez_stbi_load_from_file(byval f as FILE ptr, _
byval width as long ptr, _
byval height as long ptr, _
byval comp as long ptr, _
byval req_comp as long) as ubyte ptr
declare function ez_stbi_info_from_callbacks(byval clbk as const Ez_stbi_io_callbacks ptr, _
byval user as any ptr, _
byval width as long ptr, _
byval height as long ptr, _
byval comp as long ptr) as long
declare function ez_stbi_load_from_callbacks(byval clbk as const Ez_stbi_io_callbacks ptr, _
byval user as any ptr, _
byval width as long ptr, _
byval height as long ptr, _
byval comp as long ptr, _
byval req_comp as long) as ubyte ptr
declare sub ez_stbi_image_free(byval retval_from_Ez_stbi_load as any ptr)
declare function ez_stbi_zlib_decode_malloc_guesssize(byval buffer as const zstring ptr, byval len as long, byval initial_size as long, byval outlen as long ptr) as zstring ptr
declare function ez_stbi_zlib_decode_malloc (byval buffer as const zstring ptr, byval len as long, byval outlen as long ptr) as zstring ptr
declare function ez_stbi_zlib_decode_buffer (byval obuffer as zstring ptr, byval olen as long, byval ibuffer as const zstring ptr, byval ilen as long) as long
declare function ez_stbi_zlib_decode_noheader_malloc (byval buffer as const zstring ptr, byval len as long, byval outlen as long ptr) as zstring ptr
declare function ez_stbi_zlib_decode_noheader_buffer (byval obuffer as zstring ptr, byval olen as long, byval ibuffer as const zstring ptr, byval ilen as long) as long
end extern
#endif ' __EZ_IMAGE_BI__
and how you can overwrite the white background color of all the windows.
Joshy
file: test01.bas
Code: Select all
#include once "ez-draw.bi"
#include once "ez-image.bi"
sub _init_ constructor
#if __FB_DEBUG__
setenviron("EZ_DRAW_DEBUG=1")
#ifdef __EZ_IMAGE_BI__
setenviron("EZ_IMAGE_DEBUG=1")
#endif
if ez_init()<0 then beep : sleep : end 1
#else
if ez_init()<0 then
open err for output as #99
print #99,"fatal error: ez_init() !"
close #99
beep : sleep : end 1
end if
#endif
end sub
#if __FB_DEBUG__
sub _quit_ destructor
open err for output as #99
print #99,"done ..."
close #99
beep : sleep 1000
end sub
#endif
sub WindowCB EZ_CALLBACK (byref ev as Ez_event)
print "WindowCB: " & ev.type
select case as const ev.type
case Expose : ' We must redraw everything
ez_set_color (ez_get_RGB(255,255,255))
ez_draw_text (ev.win, EZ_MC, 200, 150,!"To quit, press the key 'q', or click\non the Close button of the window")
case KeyPress : ' A key was pressed
' "q" breacks the message loop
if (ev.key_sym = XK_q_) then ez_quit()
end select
end sub
'
' main
'
' TIP! before the Expose event are triggered
' (the event where you have completly redraw all the window content)
' Ez-Draw clears the window background with the exported color ez_white.
' so if you don't like a white window background you can overwrite the ez_white color !
var BackgroundColor=@ez_white
*BackgroundColor=ez_get_RGB(25,25,25)
var win = ez_window_create(320*2,240,"test01.bas",@WindowCB)
ez_main_loop()
Re: EZ-DRAW 1.2 graphic static lib win/linux
I do not see what was wrong?by D.J.Peters » Jul 06, 2019 23:43
Yes the declaration are wrong there are more issues I fixed last night.
you only organized your bi files differently and added the lower case
(wich in fact will not be really needed eg : XK_Q +32 do the trick for lower case)
I don't see what you have done to resolve the error for lunux 32 (dodicat & Knatterton tests)
I've tested my couples .bi file / static libs for win 32 & 64 and linux 64 everything was correct.
As i said the linux 32 libs were compiled with gcc64 using the -m32 flag
i do not have installed the linux gcc32 toolchain nor a 32 linux system.
so i'm not totaly confident on my linux 32 static libs
I think to be completly right is to boot on linux 32 , use the gcc32 to compile the libs
and after test them on that 32 linux system
for the ones wanting to do that download the following zip
https://github.com/marpon/EZ-DrawFb/blo ... ib_src.zip
it contains the .c and .h files and a makefile to create the static libs
on the makefile you will have
replace ez-draw2 by ez-draw for the libez-draw_l32.a# use under ez-draw or ez-image (according the lib to create)
NAME = ez-draw2
replace ez-draw2 by ez-image for the libez-image_l32.a
Re: EZ-DRAW 1.2 graphic static lib win/linux
Hi marpon.
Your makefile threw errors on windows
(recipe for target 'mk_dir' failed)
So I compiled the old fashioned way with mingw.
I found that with win 32 bit fbc -gen gas fails where -gen gcc is OK.
So I fired up my Linux box (I am here on Linux), and fbc -gen gcc (your test fikes) work like a charm.(your original libs)
The -gen gas fails.
Your footballs bounce well here on Red Hat.
I'll try and recompile your source here on Linux later.
Your makefile threw errors on windows
(recipe for target 'mk_dir' failed)
So I compiled the old fashioned way with mingw.
I found that with win 32 bit fbc -gen gas fails where -gen gcc is OK.
So I fired up my Linux box (I am here on Linux), and fbc -gen gcc (your test fikes) work like a charm.(your original libs)
The -gen gas fails.
Your footballs bounce well here on Red Hat.
I'll try and recompile your source here on Linux later.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: EZ-DRAW 1.2 graphic static lib win/linux
Believe it or not ez_get_RGB was wrong = twice declared. One time as export and again as shared var !it must be one simple declare only:Joshy
Code: Select all
extern ez_get_RGB as function(byval r as Ez_uint8 , byval g as Ez_uint8 , byval b as Ez_uint8) as Ez_uint32
dim shared ez_get_RGB as function(byval r as Ez_uint8 , byval g as Ez_uint8 , byval b as Ez_uint8) as Ez_uint32
Code: Select all
extern ez_get_RGB as function(byval r as ubyte, byval g as ubyte, byval b as ubyte) as ulong
Re: EZ-DRAW 1.2 graphic static lib win/linux
thanks, you are true, forget to clean,D.J.Peters wrote:Believe it or not ez_get_RGB was wrong = twice declared. One time as export and again as shared var !it must be one simple declare only:Code: Select all
extern ez_get_RGB as function(byval r as Ez_uint8 , byval g as Ez_uint8 , byval b as Ez_uint8) as Ez_uint32 dim shared ez_get_RGB as function(byval r as Ez_uint8 , byval g as Ez_uint8 , byval b as Ez_uint8) as Ez_uint32
JoshyCode: Select all
extern ez_get_RGB as function(byval r as ubyte, byval g as ubyte, byval b as ubyte) as ulong
done now in github and simplified ez-draw.bi cleaned all const for keys and using #include once "X11/keysym.bi" even for win
see again https://github.com/marpon/EZ-DrawFb
@dodicat
yes that makefile was only done for linux (in fact unix like Os)
a more complete one is now on github wich can work for both win/linux
see https://github.com/marpon/EZ-DrawFb/tre ... urces_libs
and true also the 32 win gas is not working, the faulty problem is what D.J.Peters has found : duplicated extern and dim shared on ez-draw.bi
corrected version now in github
I think it is the same problem for linux 32 using gas, normally with the new version of ez-draw.bi everything should work
My fault, I always compile on 32 or 64 using gcc and in that case (i don't know why),
it is working even with that duplicate extern and dim shared.
Sorry and thank's all of you for testing and reporting, hope now it can work in all cases
With that very little libs we have a tool for minimal 'portable' graphic features but with multiple windows (wich is a limitation on native fb)
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: EZ-DRAW 1.2 graphic static lib win/linux
@marpon
pro:
multiply windows
resizable windows
different pen thickness
fast sprites (pixmaps)
the well known image loader are included
cons:
slow (*)
you can't draw on images
no color = pixel(x,y)
you can't grab an image from window (this would be a workaround to create/drawing images on the fly)
you can't save the window as image (this would be another workaround to create/drawing images on the fly)
no rounded rectangles
no arcs or filled pies (only circle or elipse)
...
(*) On weekend I read every line from the source codes and I know how the good old X-Lib and GDI works.
The most important problem are every EZ-Draw command will make the current window or double buffer as the drawing target,
and update the pen for thickness.
This is the unnecessary bottleneck in scope of speed.
Imagine you draw 1000 or more pixels/lines/circles in a loop (may be a simulated particle fountain)
every call of ez_set_color() will call ez_update_pen() also
every call of ez_draw_point(x,y) will call ez_cur_win() also.
remember you draw 1000 or more pixels every frame !
But every problem in code is a challenge too :-)
To solve this you can add:
void ez_begin_drawing(ez_window* target, uint color, uint thick) ;
Inside of ez_begin_drawing() call ez_set_thick(), ez_ez_set_color() and ez_cur_win() only once.
make a copy of all drawing commands renamed it and remove the unnecessary calls from it
ez_draw_point -> ez_draw_point_fast
ez_draw_line -> ez_draw_line_fast
...
Should be 4-7 timers faster as before.
How ever it's a nice tiny static lib can be a good starting point for a more improved version ;-)
May be some one can compile it for the FreeBASIC supported __FB_ARM__ family also (the beagle bone and raspberry pie's)
happy gfx coding
Joshy
pro:
multiply windows
resizable windows
different pen thickness
fast sprites (pixmaps)
the well known image loader are included
cons:
slow (*)
you can't draw on images
no color = pixel(x,y)
you can't grab an image from window (this would be a workaround to create/drawing images on the fly)
you can't save the window as image (this would be another workaround to create/drawing images on the fly)
no rounded rectangles
no arcs or filled pies (only circle or elipse)
...
(*) On weekend I read every line from the source codes and I know how the good old X-Lib and GDI works.
The most important problem are every EZ-Draw command will make the current window or double buffer as the drawing target,
and update the pen for thickness.
This is the unnecessary bottleneck in scope of speed.
Imagine you draw 1000 or more pixels/lines/circles in a loop (may be a simulated particle fountain)
every call of ez_set_color() will call ez_update_pen() also
every call of ez_draw_point(x,y) will call ez_cur_win() also.
remember you draw 1000 or more pixels every frame !
But every problem in code is a challenge too :-)
To solve this you can add:
void ez_begin_drawing(ez_window* target, uint color, uint thick) ;
Inside of ez_begin_drawing() call ez_set_thick(), ez_ez_set_color() and ez_cur_win() only once.
make a copy of all drawing commands renamed it and remove the unnecessary calls from it
ez_draw_point -> ez_draw_point_fast
ez_draw_line -> ez_draw_line_fast
...
Code: Select all
sub WindowCB EZ_CALLBACK (byref ev as Ez_event)
select case as const ev.type
case Expose : ' We must redraw everything
ez_begin_drawing(myWindow,myColor1,1)
for i as integer 0 to 199
ez_draw_point_fast(particle(i).x,particle(i).y)
next
ez_begin_drawing(myWindow,myColor2,3)
for i as integer 200 to 399
ez_draw_point_fast(particle(i).x,particle(i).y)
next
ez_begin_drawing(myWindow,myColor3,4)
for i as integer 400 to 999
ez_draw_point_fast(particle(i).x,particle(i).y)
next
case else
' handle other events here ...
end select
end sub
How ever it's a nice tiny static lib can be a good starting point for a more improved version ;-)
May be some one can compile it for the FreeBASIC supported __FB_ARM__ family also (the beagle bone and raspberry pie's)
happy gfx coding
Joshy
Re: EZ-DRAW 1.2 graphic static lib win/linux
Some evolutions, optimizations
added
setpixel;
capture screen;
save to bmp(24bits);
save to jpeg;
win to image;
...
and some tweaks on drawing functions to speed up a little
https://github.com/marpon/EZ-DrawFb/tre ... ez-draw_v2
the c sources are also available with a makefile for windows or linux
sure is not complete as the big libs but easy to use and for beginning with graphics quite enougth for the cost of some ko only
and without need to add extra shared libs dependancies
feel free to use, complete or modify (please inform me )
added
setpixel;
capture screen;
save to bmp(24bits);
save to jpeg;
win to image;
...
and some tweaks on drawing functions to speed up a little
https://github.com/marpon/EZ-DrawFb/tre ... ez-draw_v2
the c sources are also available with a makefile for windows or linux
sure is not complete as the big libs but easy to use and for beginning with graphics quite enougth for the cost of some ko only
and without need to add extra shared libs dependancies
feel free to use, complete or modify (please inform me )