|
Post by alexfish on Nov 30, 2022 11:57:12 GMT 1
Are Well
RPI4 Got the same problem with the m.2 card only thing of note was last update was on the eeprom
if boot usb sdcard then all is ok.
now looking at the boot configs since if plug the coupling in then m.2 card is seen.
thought it was fishy , if put fresh os on then it will boot ?
BR Alex
|
|
|
Post by alexfish on Nov 30, 2022 12:54:19 GMT 1
now booting from m.2
can't give details for the obvious, best google it
BR Alex
|
|
|
Post by alexfish on Nov 30, 2022 13:45:38 GMT 1
Definite last post here for gtk3
Playing With Alpha
Black background Pasty/pastel color fixes, here using white
' gtk3 image/pixbuf test5 demo '========gtk3 PRAGMA LDFLAGS `pkg-config gtk+-3.0 --libs` PRAGMA OPTIONS `pkg-config gtk+-3.0 --cflags` PRAGMA INCLUDE <gtk-3.0/gtk/gtk.h> '========pixbuff PRAGMA LDFLAGS `pkg-config gdk-pixbuf-2.0 --libs` PRAGMA OPTIONS `pkg-config gdk-pixbuf-2.0 --cflags` PRAGMA INCLUDE <gdk-pixbuf/gdk-pixbuf.h> '========gobject PRAGMA LDFLAGS `pkg-config gobject-2.0 --libs` PRAGMA OPTIONS `pkg-config gobject-2.0 --cflags` PRAGMA INCLUDE <glib-object.h>
OPTION PARSE FALSE
DECLARE window , image TYPE GtkWidget * DECLARE pixy TYPE GdkPixbuf* DECLARE layer TYPE GtkWidget * '============================================================================ SUB PUT_PIXEL_RGBA(GdkPixbuf* pixbuf,int xpos,int ypos,unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
LOCAL pixels,p TYPE unsigned char* LOCAL width,height,rowstride,n_channels
' check x y fits width & heigh before getting to here 'width = gdk_pixbuf_get_width (pixbuf) 'height = gdk_pixbuf_get_height (pixbuf)
rowstride = gdk_pixbuf_get_rowstride (pixbuf) n_channels = gdk_pixbuf_get_n_channels (pixbuf) pixels = gdk_pixbuf_get_pixels (pixbuf) ' // The pixel we wish to modify p = pixels + ypos * rowstride + xpos * n_channels
p[0] = red p[1] = green p[2] = blue p[3] = alpha
END SUB '============================================================ LOCAL workarea = {0} TYPE GdkRectangle '============================================================ gtk_init (&argc, &argv) gdk_monitor_get_workarea(gdk_display_get_primary_monitor(gdk_display_get_default()),&workarea)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL)
gtk_window_set_title (GTK_WINDOW (window), "BaCon Rules") layer = gtk_fixed_new() g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL) gtk_container_add(GTK_CONTAINER(window), layer) pixy = gdk_pixbuf_new(0,TRUE,8,600,600) gdk_pixbuf_fill(pixy,0x000000FF) image = gtk_image_new_from_pixbuf (pixy) gtk_fixed_put(GTK_FIXED(layer),image,0,0) gtk_widget_set_size_request(GTK_WIDGET (layer),600,400) gtk_widget_show (GTK_WIDGET(image)) gtk_widget_show_all (window)
LOCAL angle TYPE double LOCAL hug_xsize = 300, hug_ysize = 200 TYPE double LOCAL x,y,t,i TYPE double LOCAL hug_x = 200,hug_y=200 TYPE double LOCAL newpix TYPE GdkPixbuf* newpix = gdk_pixbuf_new_subpixbuf (pixy,hug_x,hug_y,hug_xsize,hug_xsize) FOR i = 1 TO 360 STEP .05
angle = 2 * PI * i / 360 'x = (hug_xsize/2)*COS(angle) 'y = (hug_ysize/2)*SIN(angle) x = (hug_xsize/2)*SIN(angle) y = (hug_ysize/2)*COS(angle) FOR t = (hug_xsize/2)-x TO (hug_xsize/2)+x PUT_PIXEL_RGBA(newpix,t, (hug_ysize/2)+y,DEC("FF"),DEC("FF"),DEC("FF"),DEC("FF")) PUT_PIXEL_RGBA(newpix,t, (hug_ysize/2)+y,DEC("FF"),DEC("FF"),DEC("00"),DEC("BF")) NEXT
NEXT
g_object_unref(newpix) g_object_unref(pixy) gtk_main ()
BR Alex
|
|
|
Post by alexfish on Nov 30, 2022 15:13:37 GMT 1
Hi All
Now reading through bits again , The bits, how many bits and how far back.
Here is a Clue
coded by Vovchik had to adapt this y1 keyword added some yyy's
'*************************************************************** ' double_line.bac - draw double line as rectangle ' Vovchik Circa Hug Entertainments May 19, 2015 at 10:22pm '***************************************************************
INCLUDE "hug.bac" INIT HUGOPTIONS("NOSCALING") DECLARE w, h TYPE int w = 640 : ' display width h = 480 : ' display height
' ------------------ SUB DOUBLE_LINE(STRING col$, int x1, int yyy1, int x2, int y2, int d) ' ------------------ ' Draws a double line constructed using a rectangle whose endpoints ' are (x11, yyy11), (x12, yyy12), (x21, y21) und (x22, y22) LOCAL dx, dy, x11, x12, x21, x22, y11, y12, y21, y22, xm, ym TYPE int LOCAL alfa TYPE double 'Sonderfall: Senkrechte Linie IF x1 = x2 THEN dx = INT(d / 2.0) dy = 0 ELIF y1 = y2 THEN dx = 0 dy = (d / 2.0) ELSE ' gradient angle of line alfa = ATN((yyy1 - y2) / (x2 - x1)) ' x und y differece between endpoints of ' the rectangle and the endpoints of the normal line dx = INT((d / 2.0) * SIN(alfa)) dy = INT((d / 2.0) * COS(alfa)) END IF ' calculate the corner points x11 = x1 - dx x12 = x1 + dx x21 = x2 - dx x22 = x2 + dx y11 = yyy1 - dy y12 = yyy1 + dy y21 = y2 - dy y22 = y2 + dy ' draw rectangle LINE(col$, x11, y11, x21, y21) LINE(col$, x21, y21, x22, y22) LINE(col$, x22, y22, x12, y12) LINE(col$, x12, y12, x11, y11) 'coordinates of the line midpoint xm = INT(x1 + (x2 - x1) / 2.0) ym = INT(y2 + (yyy1 - y2) / 2.0)
END SUB
' ------------------ SUB MY_QUIT() ' ------------------ IF MOUSE(2) = 1 OR MOUSE(2) = 3 THEN QUIT END SUB
' ------------------ SUB DRAW_LINES() ' ------------------ DOUBLE_LINE("skyblue", 20, 200, 20, 460, 2) : ' left wall DOUBLE_LINE("skyblue", 20, 460, 619, 460, 2) : ' floor DOUBLE_LINE("skyblue", 619, 460, 619, 200, 2) : ' right wall DOUBLE_LINE("red", 619, 200, 320, 100, 2) : ' right roof DOUBLE_LINE("red", 320, 100, 20, 200, 2) : ' left roof END SUB
' ------------------ SUB MK_GUI() ' ------------------ win = WINDOW("Double lines (click to quit)", w, h) canvas = CANVAS(w, h) ATTACH(win, canvas, 0, 0) CALLBACK(canvas, MY_QUIT) SQUARE("black", 0, 0, w, h, 1) DRAW_LINES() END SUB
MK_GUI() DISPLAY
BR Alex
|
|
|
Post by alexfish on Nov 30, 2022 22:51:58 GMT 1
ENTER THE DRAGON
INCLUDE hug.bac HUGOPTIONS("NOSCALING")
GTK$ = HUGLIB$("gtk") GDK$ = "libgdk_pixbuf-2.0.so.0" IMPORT "gtk_image_set_from_pixbuf(long,long)" FROM GTK$ TYPE void IMPORT "gdk_pixbuf_new (int,int,int ,int ,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_fill ( long , unsigned int ) " FROM GDK$ TYPE void
DECLARE imagebuf TYPE long DECLARE newbuf TYPE long
win = WINDOW("Test Image Hack",600,400) can = CANVAS(600,350)
ATTACH(win,can,0,50) imagebuf = hug_widget_image(STR$(can)) newbuf = gdk_pixbuf_new(0,TRUE,8,600,350) gdk_pixbuf_fill(newbuf,0xFF0000FF) gtk_image_set_from_pixbuf(imagebuf,newbuf) DISPLAY
BR Alex
|
|
|
Post by alexfish on Nov 30, 2022 23:17:35 GMT 1
Add some bits to play with INCLUDE hug.bac HUGOPTIONS("NOSCALING")
GTK$ = HUGLIB$("gtk") GDK$ = "libgdk_pixbuf-2.0.so.0" IMPORT "gtk_image_clear(long)" FROM GTK$ TYPE void IMPORT "gtk_image_set_from_pixbuf(long,long)" FROM GTK$ TYPE void IMPORT "gdk_pixbuf_new (int,int,int ,int ,int)" FROM GDK$ TYPE long IMPORT "gdk_pixbuf_fill ( long , unsigned int ) " FROM GDK$ TYPE void IMPORT "gdk_pixbuf_new_subpixbuf ( long , int , int , int , int ) " FROM GDK$ TYPE long DECLARE imagebuf TYPE long DECLARE newbuf TYPE long SUB PUT_PIXEL_RGBA(long pixbuf,int xpos,int ypos,unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
LOCAL pixels,p TYPE unsigned char* LOCAL width,height,rowstride,n_channels
' check x y fits width & heigh before getting to here 'width = gdk_pixbuf_get_width (pixbuf) 'height = gdk_pixbuf_get_height (pixbuf)
rowstride = gdk_pixbuf_get_rowstride (pixbuf) n_channels = gdk_pixbuf_get_n_channels (pixbuf) pixels = gdk_pixbuf_get_pixels (pixbuf) ' // The pixel we wish to modify p = pixels + ypos * rowstride + xpos * n_channels
p[0] = red p[1] = green p[2] = blue p[3] = alpha
END SUB win = WINDOW("Test Image Hack",600,600) can = CANVAS(600,550) ATTACH(win,can,0,50) imagebuf = hug_widget_image(STR$(can)) newbuf = gdk_pixbuf_new(0,TRUE,8,600,550) gdk_pixbuf_fill(newbuf,0x000000BF) LOCAL angle TYPE double LOCAL hug_xsize = 300, hug_ysize = 200 TYPE double LOCAL x,y,t,i TYPE double LOCAL hug_x = 50,hug_y=50 TYPE double
newpix = gdk_pixbuf_new_subpixbuf (newbuf,hug_x,hug_y,hug_xsize,hug_xsize) FOR i = 1 TO 360 STEP .05
angle = 2 * PI * i / 360 'x = (hug_xsize/2)*COS(angle) 'y = (hug_ysize/2)*SIN(angle) x = (hug_xsize/2)*SIN(angle) y = (hug_ysize/2)*COS(angle) FOR t = (hug_xsize/2)-x TO (hug_xsize/2)+x PUT_PIXEL_RGBA(newpix,t, (hug_ysize/2)+y,DEC("FF"),DEC("FF"),DEC("FF"),DEC("FF")) PUT_PIXEL_RGBA(newpix,t, (hug_ysize/2)+y,DEC("FF"),DEC("FF"),DEC("00"),DEC("BF")) NEXT
NEXT gtk_image_set_from_pixbuf(imagebuf,newbuf) g_object_unref(newbuf) DISPLAY
If going to redraw on the internal buffer clear it gtk_image_clear() BR Alex Attachments:
|
|
|
Post by alexfish on Dec 1, 2022 13:17:03 GMT 1
Hi All REF 'SUB PUT_PIXEL_RGBA' have adapted the Vovchik colour name to hex to the lib here is a demo to play with simple code . if pass just hex use 6bit & the alpha separate IF PLOT(newbuf,"FF00FF","FF" ,t,s) HOME$ = GETENVIRON$("HOME")
newbuf = gdk_pixbuf_new(0,TRUE,8,20,20)
FOR t = 0 TO 20 FOR s = 0 TO 20 PLOT(newbuf,"turquoise","FF" ,t,s) NEXT NEXT
gdk_pixbuf_save(newbuf,HOME$ & "/test.png","png",0,NULL) BR Alex There will be re post :: colors are Wrong::Repost archive DoneThinking Assoc may be faster IE DECLARE colorname$ ASSOC STRING colorname$("#F5F5DC") = "beige" PRINT INDEX$(colorname$, "beige") Attachments:Color.bac.tar (10 KB)
|
|
|
Post by alexfish on Dec 1, 2022 16:46:04 GMT 1
Update Color to ASSOC is it faster , No , both the same but filling a pixbuf takes for ever However the purpose of the PLOT / is to make a coloured pixbuf for painting in terms of aliceblueFF = gdk_pixbuf_new(0,TRUE,8,1,1) PLOT(aliceblue_buf,"aliceblue","FF" ,0,0) PLOT is not an Apt name or use name to fill a pixbuf unsigned int aliceblueFF =("aliceblue",FF) pixbuf_fill(mybuf,aliceblueFF) In cairo terms cairo_set_source_rgba or cairo_set_source_rgb where the Alpha is set internal at FF BR Alex + got the array wrong count to 20 arrays start at 0 in unix FOR t = 0 TO 19 FOR s = 0 TO 19 PLOT(newbuf,"saddlebrown","FF" ,t,s) NEXT NEXT Attachments:Color2.bac.zip (2.45 KB)
|
|
|
Post by alexfish on Dec 2, 2022 2:01:40 GMT 1
Code base for the above now in lib
now looks like
HOME$ = GETENVIRON$("HOME") newbuf = PIXBUF_NEW ("olivedrab","FF" ,200,200) gdk_pixbuf_save(newbuf,HOME$ & "/test.png","png",0,NULL)
pi@raspberrypi:~/bacon $ time ./Color2
real 0m0.059s user 0m0.028s sys 0m0.030s
1000*1000
real 0m0.153s user 0m0.140s sys 0m0.012s
BR Alex
|
|
|
Post by bigbass on Dec 2, 2022 21:07:51 GMT 1
Hello Alex
I tried your yellow circle and Circle2 examples they work correctly on the RPI3 raw pixel drawing and color palettes in buffers with gtk2 ,gtk3 and now libgdk_pixbuf directly
the PUT_PIXEL_RGBA and the PLOT SUBS
looks like they should be able to drop into any coding style easily (meaning reusable) low level code
Joe
|
|
|
Post by alexfish on Dec 2, 2022 22:47:35 GMT 1
Hi Joe can do most things , depends on the aperture so to speak , how big is aperture have added HUG widgets as per say , oh no never again , oh yes again type type the widget , Viola the work in progress on this part of the lib so can imagine what will show in the canvas , just in progress on this bit penny drop when changing Vovchiks HEX$ to colour using ASSOC So here IE :WIDGET$ DECLARE WIDGET$ ASSOC STRING WIDGET$("window = WINDOW(title, xsize, ysize)") = "WINDOW" WIDGET$("but = BUTTON(caption, xsize, ysize)") = "BUTTON" bit To get the widget from entry SUB GETWIDGET() wid$ = GRAB$(ent) wid$ = INDEX$(WIDGET$,wid$) IF LEN(wid$) THEN TEXT(sed,wid$ & NL$) END IF
END SUB
Just So easy to add I could not resist the temptation preview of main bits so far code wise INCLUDE hug.bac INCLUDE pixbuf.bac INCLUDE cairo.bac INCLUDE imager.bac INCLUDE colornames.bac INCLUDE widgetlist.bac
BR Alex PICKY of the added bit widget list Attachments:
|
|
|
Post by alexfish on Dec 3, 2022 12:21:42 GMT 1
REUSABLE: well easy means will be to clear the pixbuf to alpha
for that have
IMPORT "gdk_pixbuf_fill( long , unsigned int ) " FROM GDK$ TYPE void &
SUB PIXBUFF_CLEAR(long pixbuf) gdk_pixbuf_fill (pixbuf , 0x00000000) END SUB
to resize a buffer use pixbuf scale simple
BR Alex
|
|
|
Post by alexfish on Dec 3, 2022 16:26:53 GMT 1
Hi All Now at stage one testing Keep this bit very short Look at the picky on the canvas is a 600*400 rectangle which represents the window on there is a real window its size is 400*200 the editor is what I call Hug Fast writer , type window and get WINDOW bits to edit there is a attach button , so can repeat a widget , use the attach but to paste the attach code EASY PEASY How ever now ready to finalize the image bits , for that , Vochik and I did some work in the backdoor I need to go throw the bits, again Update :: in gtk2 we can constrain the widget to a reasonable degree In first instance need to use a window without scaling since Hug window does not have (NOSCALING) option in the WINDOW function ,think also widgets , CANVAS has Rectified See ScreenShot 2 , so only have 2 Hacks for hug lib on direct an one added GraphicWindow, IE there is no Scalling so not rely hacked in 1 the window is a FUCTION an in 2 , we are only clearing the Default CANVAS Image Where by can paint it with a pixbuf rather than to the DrawableGtk3 = unmentionable word , test Joes posting of 'Enter the Dragon' at first the window fits but then Tangle with a Dragon you get Burnt Can get the screen size ,but those dims width and height are not accessible to be used math wise Have Fun + BR Alex Attachments:
|
|
|
Post by alexfish on Dec 3, 2022 17:49:17 GMT 1
Hence the G_WINDOW INCLUDE g_window.bac
FUNCTION G_WINDOW (STRING hug_title$, int hug_xsize, int hug_ysize)
LOCAL win, layer, dim, i
win = gtk_window_new(GTK_WINDOW_TOPLEVEL) gtk_window_set_title(win, hug_title$) gtk_window_set_position(win, GTK_WIN_POS_CENTER)
g_signal_connect_data(win, "delete-event", exit, 0, 0, 0) g_signal_connect_data(win, "key-press-event", hug_key_press, 0, 0, 0)
IF INSTR(hug_gui_properties.options$, "TABLE") THEN SPLIT hug_gui_properties.options$ BY " " TO opt$ SIZE dim FOR i = 0 TO dim - 1 IF INSTR(opt$[i], "TABLE") AND i+2 < dim THEN layer = gtk_table_new(VAL(opt$[i+2]), VAL(opt$[i+1]), 1) BREAK END IF NEXT ELSE gtk_window_set_resizable(win, 0) layer = gtk_fixed_new() END IF
gtk_container_add(win, layer)
gtk_widget_set_size_request(win,hug_xsize, hug_ysize) IF HUG_WIDGET_SHOW THEN gtk_widget_show_all(win)
hug_winstate(STR$(win)) = 0
hug_widget_xsize(STR$(win)) = hug_xsize hug_widget_ysize(STR$(win)) = hug_ysize hug_widget_signal(STR$(win)) = 1 hug_widget_s_widget(STR$(win)) = win hug_widget_type$(STR$(win)) = "window" hug_widget_attach(STR$(win)) = layer hug_widget_font(STR$(win)) = win hug_widget_focus(STR$(win)) = win WIDGET = win
RETURN win
END FUNCTION
|
|
|
Post by alexfish on Dec 3, 2022 21:32:33 GMT 1
Finaly Pick Shows it all BR Alex Attachments:
|
|