libcairo.dll.a for x64 ?
libcairo.dll.a for x64 ?
Can someone provide a static 64-bit library for Cairo?
But now i wonder if it is even possible to build a x64 library for Cairo...
If not, can I somehow use x32 libraries with fbc x64?
But now i wonder if it is even possible to build a x64 library for Cairo...
If not, can I somehow use x32 libraries with fbc x64?
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: libcairo.dll.a for x64 ?
@dodicat in setscreen() you used cairo_image_surface_create_for_data() but the last param "stride" is in bytes the fbgfx surface/image stride is a multiply of 16 bytes(4 pixels in RGBA) !
You can use imageInfo() if you create a surface from fbgfx image or ScreenInfo() if you used a gfx driver page as a source for a Cairo Image Surfaces.
The row alignment of 16 bytes is to support fast 16 byte aligned SSE CPU instructions. (so far I remember)
Joshy
You can use imageInfo() if you create a surface from fbgfx image or ScreenInfo() if you used a gfx driver page as a source for a Cairo Image Surfaces.
The row alignment of 16 bytes is to support fast 16 byte aligned SSE CPU instructions. (so far I remember)
Joshy
Code: Select all
Function setscreen(xres As Integer,yres As Integer) As cairo_t Ptr
dim as integer pitch
Screenres xres,yres,32 ',,&h08 Or &h40
screeninfo xres,yres,,,pitch
Width 8\xres,16\yres
screenlock()
Var surface = cairo_image_surface_create_for_data(Screenptr(), CAIRO_FORMAT_ARGB32,xres,yres,pitch)
screenunlock()
var res = cairo_create(surface)
Return res
End Function
Re: libcairo.dll.a for x64 ?
Thanks D.J.Peters.
16 bit alignment for images.
Screens-- xres*4 = pitch
16 bit alignment for images.
Screens-- xres*4 = pitch
Code: Select all
#define range(f,l) Int(Rnd*((l+1)-(f))+(f))
dim as long yres,pitch
dim as long ixres,iyres,ipitch
dim as any ptr im
windowtitle "Press a key"
do
dim as long xres= range(300,800)
screenres xres,400,32
screeninfo xres,yres,,,pitch
im=imagecreate (xres,yres)
imageinfo im, ixres,iyres,,ipitch
cls
locate 3,5
print "Screens"
locate 5,5
print "xres*4","pitch"
print
locate ,5
print xres*4,pitch
locate 12,5
print "Images"
locate 14,5
print "xres*4","pitch"
print
locate ,5
print ixres*4,ipitch
sleep
imagedestroy im
loop until inkey=chr(27)
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: libcairo.dll.a for x64 ?
Code: Select all
print "width","bytes","pitch"
for x as integer = 160 to 172
var bytes = x*4 ' RGBA
var pitch = ((bytes + 15)\4)*4 and &HFFF0
print x,bytes,pitch
next
sleep
Re: libcairo.dll.a for x64 ?
The pitch is numerically equal to xres*4 for various xres's, where xres=the screen width.
So what is the difference writing in xres*4 or pitch for the last parameter?
cairo_image_surface_create_for_data is getting sent that number (either xres*4 or pitch, which are equal).
Am I missing something here?
Why it pitch better than xres*4 ?
The only improvement I can do is call xres a long, and not integer.
I wrote the code ages ago when integer was required.
The last parameter of cairo_image_surface_create_for_data-- (stride as long).
So what is the difference writing in xres*4 or pitch for the last parameter?
cairo_image_surface_create_for_data is getting sent that number (either xres*4 or pitch, which are equal).
Am I missing something here?
Why it pitch better than xres*4 ?
The only improvement I can do is call xres a long, and not integer.
I wrote the code ages ago when integer was required.
The last parameter of cairo_image_surface_create_for_data-- (stride as long).
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: libcairo.dll.a for x64 ?
@dodicat if you get only a multiply of 4 the source code of gfx driver are changed.
it was allways a multiply of 16 bytes not 4 in the past.
Take a look at the the C code pitch is width * bpp at first:
pitch = width * bpp ' 1,2,4
after this it becomes an multiply of 16
pitch = (pitch + 0xF) & ~0xF;
Joshy
Take a look at line 46
it was allways a multiply of 16 bytes not 4 in the past.
Take a look at the the C code pitch is width * bpp at first:
pitch = width * bpp ' 1,2,4
after this it becomes an multiply of 16
pitch = (pitch + 0xF) & ~0xF;
Joshy
Take a look at line 46
Code: Select all
/* image create/destroy functions */
#include "fb_gfx.h"
static void *gfx_imagecreate(int width, int height, unsigned int color, int depth, int flags, int usenewheader)
{
FB_GFXCTX *context;
PUT_HEADER *image;
int size, pitch, header_size = 4;
int bpp;
FB_GRAPHICS_LOCK( );
if ((!__fb_gfx) || (width <= 0) || (height <= 0)) {
FB_GRAPHICS_UNLOCK( );
fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
return NULL;
}
context = fb_hGetContext();
if (depth > 0) {
bpp = BYTES_PER_PIXEL(depth);
if ((bpp != 1) && (bpp != 2) && (bpp != 4)) {
FB_GRAPHICS_UNLOCK( );
fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
return NULL;
}
} else {
bpp = __fb_gfx->bpp;
}
if (flags & DEFAULT_COLOR_1) {
switch (bpp) {
case 1: color = 0; break;
case 2: color = MASK_COLOR_16; break;
case 4: color = MASK_COLOR_32 | MASK_A_32; break;
}
} else {
if (bpp == 2)
color = ((color & 0xF8) >> 3) | ((color & 0xFC00) >> 5) | ((color & 0xF80000) >> 8);
}
pitch = width * bpp; // bpp = 1,2,4
if (usenewheader) {
header_size = sizeof(PUT_HEADER);
pitch = (pitch + 0xF) & ~0xF;
}
size = pitch * height;
/* 0xF for the para alignment, p_size is sizeof(void *) rounded up to % 16 for the storage for the original pointer */
int p_size = (sizeof(void *) + 0xF) & 0xF;
void *tmp = malloc(size + header_size + p_size + 0xF);
if (tmp == NULL) {
FB_GRAPHICS_UNLOCK( );
fb_ErrorSetNum( FB_RTERROR_OUTOFMEM );
return NULL;
}
image = (PUT_HEADER *)(((intptr_t)tmp + p_size + 0xF) & ~0xF);
((void **)image)[-1] = tmp;
if (!usenewheader) {
/* use old-style header for compatibility */
image->old.bpp = bpp;
image->old.width = width;
image->old.height = height;
} else {
image->type = PUT_HEADER_NEW;
image->bpp = bpp;
image->width = width;
image->height = height;
image->pitch = pitch;
fb_hMemSet(image->_reserved, 0, sizeof(image->_reserved));
}
fb_hPrepareTarget(context, (void *)image);
fb_hSetPixelTransfer(context, MASK_A_32);
context->pixel_set((unsigned char *)image + header_size, color, (pitch * height) / bpp);
FB_GRAPHICS_UNLOCK( );
fb_ErrorSetNum( FB_RTERROR_OK );
return image;
}
FBCALL void *fb_GfxImageCreate(int width, int height, unsigned int color, int depth, int flags)
{
return gfx_imagecreate( width, height, color, depth, flags, TRUE );
}
FBCALL void *fb_GfxImageCreateQB(int width, int height, unsigned int color, int depth, int flags)
{
return gfx_imagecreate( width, height, color, depth, flags, FALSE );
}
FBCALL void fb_GfxImageDestroy(void *image)
{
if( image == NULL ) return;
free(((void **)image)[-1]);
}
Re: libcairo.dll.a for x64 ?
Hi D.J.Peters.
That is for images, which are 16 bit aligned for colour depth 32
But for screen:
But to N3trunn3r
Please change
Width 8\xres,16\yres in the sub setscreen to
Width xres\8,yres\16
Also, you don't need (at the top)
Declare Function MoveWindow Alias "MoveWindow"(As Any Ptr,As Integer,As Integer,As Integer,As Integer,As Integer) As Integer
I was using that for something else.
That is for images, which are 16 bit aligned for colour depth 32
But for screen:
Code: Select all
Sub setscreen(xres As Long,yres As Long)
Dim As Long pitch
Screenres xres,yres,32
Width xres\8,yres\16
Screeninfo xres,yres,,,pitch
Print "(screen resolution)","xres*4","pitch","yres"
Print "(";xres;",";yres;")",,xres*4,pitch,yres
End Sub
#define range(f,l) Int(Rnd*((l+1)-(f))+(f))
Do
Var x=range(500,1000)
Var y=range(300,700)
setscreen(x,y)
Sleep
Loop Until Inkey=Chr(27)
Please change
Width 8\xres,16\yres in the sub setscreen to
Width xres\8,yres\16
Also, you don't need (at the top)
Declare Function MoveWindow Alias "MoveWindow"(As Any Ptr,As Integer,As Integer,As Integer,As Integer,As Integer) As Integer
I was using that for something else.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: libcairo.dll.a for x64 ?
@dodicat yes you are right scanline_size are ignored in set_mode (called by screenres,screen)
Joshy
Joshy
Code: Select all
static int set_mode(int mode, int w, int h, int depth, int scanline_size, int num_pages, int refresh_rate,
int palette, int font, int flags, float aspect, int text_w, int text_h);
Code: Select all
__fb_gfx->pitch = __fb_gfx->w * __fb_gfx->bpp;
Last edited by D.J.Peters on Jul 08, 2022 8:59, edited 1 time in total.
-
- Posts: 1007
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
Re: libcairo.dll.a for x64 ?
Hi friends.
@dodicat
Very nice demo. But I believe that you forgot to call cairo_text_extents:
After that, I think we can remove the local variable l in texture3 sub.
Tested under Linux (with "Cantarell" instead of "Georgia").
@dodicat
Very nice demo. But I believe that you forgot to call cairo_text_extents:
Code: Select all
Sub Cprint(surf As cairo_t Ptr,x As Long,y As Long,text As String,size As Single,colour As Ulong)
cairo_set_font_size (surf,(size))
cairo_text_extents (surf, text, @_text) ' <--
Tested under Linux (with "Cantarell" instead of "Georgia").
Re: libcairo.dll.a for x64 ?
Thanks Roland.
I tried that (making l=0).
It sets the text in the proper place in each ball OK, but it knocks off "Press a key"
The text position (the way I have it) sets from the left bottom of the first character (line 27)
So it actually is OK on each ball with l=0, but looks stupid, so i made that little offset to make it look slightly less stupid.
Do both methods (with cairo_text_extents (surf, text, @_text) and without) work in Linux?
Is "Press a key" still on the screen using cairo_text_extents (surf, text, @_text)?
I tried that (making l=0).
It sets the text in the proper place in each ball OK, but it knocks off "Press a key"
The text position (the way I have it) sets from the left bottom of the first character (line 27)
So it actually is OK on each ball with l=0, but looks stupid, so i made that little offset to make it look slightly less stupid.
Do both methods (with cairo_text_extents (surf, text, @_text) and without) work in Linux?
Is "Press a key" still on the screen using cairo_text_extents (surf, text, @_text)?
-
- Posts: 1007
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
Re: libcairo.dll.a for x64 ?
Yes, both methods work but indeed "Press a key" is cut when cairo_text_extents is called.
Re: libcairo.dll.a for x64 ?
Thanks, works just fine!dodicat wrote: ↑Jul 06, 2022 15:27 Here is the dll and an import library file
https://www.mediafire.com/file/7zg0w419 ... l.zip/file
Where does the cairo.dll comes from?
I am much happier to get dlls from a single source, rather than have to deal with different files and versions.
For x32 I always install the GTK Runtime package, but there does not seem to be a precompiled x64 version of GTK Runtime for Windows.
I also just found precompiled x64 Cairo DLLs on github, could be a good alternative: https://github.com/preshing/cairo-windows
Re: libcairo.dll.a for x64 ?
I think this was it:
https://github.com/preshing/cairo-windows/releases
member srvaldez first put up the link a while back.
I made the import lib myself using gendef (to get the .def file), and dlltool.
https://github.com/preshing/cairo-windows/releases
member srvaldez first put up the link a while back.
I made the import lib myself using gendef (to get the .def file), and dlltool.
Re: libcairo.dll.a for x64 ?
I use cairo with GTK and I got it from Msys for 64-bit use on an up-to-date Windows 10 machine.
Look at the documentation for Msys to see how to download it. It is quite easy and once you get it loaded, check out the documentation for downloading the latest version of GTK or any other package or as many packages as you need. Typically a single pacman line each. I only have downloaded GTK. I put a #lIBPATH statement in my FB code for the gtk lib and it all works slick as a wet frog's back.
Wally
Look at the documentation for Msys to see how to download it. It is quite easy and once you get it loaded, check out the documentation for downloading the latest version of GTK or any other package or as many packages as you need. Typically a single pacman line each. I only have downloaded GTK. I put a #lIBPATH statement in my FB code for the gtk lib and it all works slick as a wet frog's back.
Wally