diff --git a/glfw/__init__.py b/glfw/__init__.py index 3c6927e..cfca83a 100644 --- a/glfw/__init__.py +++ b/glfw/__init__.py @@ -46,16 +46,21 @@ lib_basename = 'glfw-3.0.4.bin.WIN32/lib-mingw/glfw3' elif sys.platform == 'darwin': lib_ext = '.dylib' - lib_basename = 'libglfw' -else: + lib_basename = 'glfw-3.0.4.bin.MAC64/libglfw' +else: # linux? lib_ext = '.so' lib_basename = 'libglfw' here = os.path.dirname(__file__) libfile = os.path.join(here, lib_basename+lib_ext) +# if the precompiled libs are not valid reset lib filename and build +if not os.path.exists(libfile): + lib_basename = 'libglfw' + libfile = os.path.join(here, lib_basename+lib_ext) + if os.path.exists(libfile): _glfw_file = libfile -else: +else: print 'BUILDING GLFW...' os.system('mkdir -p %s/build; cd %s/build; cmake -DBUILD_SHARED_LIBS=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF ../glfw_src; make; cp src/libglfw%s %s '%(here,here, lib_ext, here)) print 'CLEANING BUILD...' diff --git a/glfw/glfw-3.0.4.bin.MAC64/libglfw.dylib b/glfw/glfw-3.0.4.bin.MAC64/libglfw.dylib new file mode 100644 index 0000000..17850f1 Binary files /dev/null and b/glfw/glfw-3.0.4.bin.MAC64/libglfw.dylib differ diff --git a/piio/compile.mac64.sh b/piio/compile.mac64.sh new file mode 100644 index 0000000..2ac465f --- /dev/null +++ b/piio/compile.mac64.sh @@ -0,0 +1,11 @@ +#WITHOUT EXR STATICALLY LINKED +#gcc-4.8 -std=c99 -c iio.c -I/usr/local/Cellar/libpng/1.5.14/include/ +#gcc-4.8 -std=c99 -c freemem.c +#gcc -dynamiclib -arch x86_64 -o MAC64/libiio.so iio.o freemem.o /usr/local/Cellar/libpng/1.5.18/lib/libpng.a /usr/local/Cellar/jpeg/8d/lib/libjpeg.a /usr/local/Cellar/libtiff/4.0.3/lib/libtiff.a /usr/local/Cellar/zlib/1.2.8/lib/libz.a + +#WITH EXR STATICALLY LINKED +gcc-4.8 -std=c99 -c iio.c -I/usr/local/Cellar/libpng/1.5.14/include/ -I/usr/local/include/OpenEXR -DI_CAN_HAS_LIBEXR -O3 -std=c99 -funroll-loops -Wno-unused -DNDEBUG +gcc-4.8 -std=c99 -c freemem.c -O3 +gcc -dynamiclib -arch x86_64 -o MAC64/libiio.so iio.o freemem.o /usr/local/lib/libImath.a /usr/local/lib/libIlmImf.a /usr/local/lib/libIex.a /usr/local/lib/libHalf.a /usr/local/lib/libIlmThread.a /usr/local/Cellar/zlib/1.2.8/lib/libz.a /usr/local/lib/libtiff.a /usr/local/lib/libjpeg.a /usr/local/Cellar/libpng/1.5.18/lib/libpng.a /usr/local/Cellar/zlib/1.2.8/lib/libz.a /usr/local/lib/libtiff.a /usr/local/lib/libjpeg.a /usr/local/Cellar/libpng/1.5.18/lib/libpng.a /usr/lib/libstdc++-static.a + + diff --git a/piio/iio.c b/piio/iio.c index 724689b..8da9dc4 100644 --- a/piio/iio.c +++ b/piio/iio.c @@ -638,7 +638,13 @@ static void inplace_flip_vertical(struct iio_image *x) static void inplace_transpose(struct iio_image *x) { - fail("inplace transpose not implemented"); + int w = x->sizes[0]; + int h = x->sizes[1]; + if (w != h) + fail("rectangular inplace transpose not implemented"); + for (int i = 0; i < w; i++) + for (int j = 0; j < i; j++) + inplace_swap_pixels(x, i, j, j, i); } static void inplace_reorient(struct iio_image *x, int orientation) diff --git a/piio/piio.py b/piio/piio.py index 82f6e4a..9f8347e 100644 --- a/piio/piio.py +++ b/piio/piio.py @@ -37,12 +37,22 @@ lib_basename = 'WIN64/iio' else: lib_basename = 'WIN32/iio' -else: # linux and osx +elif sys.platform.startswith('darwin'): # precompiled osx intel 64 bits + lib_basename = 'MAC64/libiio' + lib_ext = '.so' +else: # linux lib_basename = 'libiio' lib_ext = '.so' libiiofile= os.path.join(here, lib_basename+lib_ext) +### fallback if precompiled libraries are not usable +try: + os.stat(libiiofile) +except OSError: + lib_basename = 'libiio' + lib_ext = '.so' + libiiofile= os.path.join(here, lib_basename+lib_ext) ### HACK TO BUILD libiio ON THE FLY try: @@ -162,7 +172,7 @@ def read_tiled_buffers(filename): # generate the interlan memory to copy the tile data = ctypes.ARRAY(ctypes.c_float, N)() libiio.copy_tile(ptr, w, h, nch, data, x, y, ww, hh, out_nch) # only allow up to 4 channels - tiles.append( (data, x, y, ww,hh, out_nch) ) + tiles.append( [data, x, y, ww,hh, out_nch, -1] ) # -1 (the last field is a placeholder for the textureID) # free the memory diff --git a/v.py b/v.py index 5c8b888..8516f6a 100755 --- a/v.py +++ b/v.py @@ -736,7 +736,7 @@ def keyboard_callback(window, key, scancode, action, mods): glfw.glfwSetWindowShouldClose(window,1) global x0,y0,w0,h0 print(x0,y0,w0,h0) - exit(0) + sys.exit(0) @@ -774,8 +774,8 @@ def display( window ): # ideally winx,winy should be equal to D.w,D.h BUT if the # image is larger than the screen glutReshapeWindow(D.w,D.h) # will fail and winx,winy will be truncated to the size of the screen -# winx, winy= glfw.glfwGetFramebufferSize(window) - winx, winy= glfw.glfwGetWindowSize(window) + winx, winy= glfw.glfwGetFramebufferSize(window) +# winx, winy= glfw.glfwGetWindowSize(window) V.winx,V.winy=winx,winy glViewport(0, 0, winx, winy); @@ -998,7 +998,7 @@ def main(): from os import stat stat(sys.argv[1]) except OSError: - exit(1) + sys.exit(1) # otherwise use stdin as input (because it should be a pipe) else: sys.argv.append('-') @@ -1017,8 +1017,8 @@ def main(): # as we must find out the image size before creating the window D.imageBitmapTiles,D.w,D.h,D.nch,D.v_min,D.v_max = load_image(I1) D.filename = I1 - if I1 != '-': - from os import stat + from os import stat, path + if I1 != '-' and path.exists(I1): D.mtime = (stat(I1).st_mtime) V.data_min, V.data_max= D.v_min,D.v_max V.reset_scale_bias() @@ -1038,7 +1038,7 @@ def main(): from os import getcwd,chdir savepath = getcwd() if not glfw.glfwInit(): - exit() + sys.exit(1) chdir(savepath) @@ -1053,7 +1053,7 @@ def main(): if not window: glfw.glfwTerminate() - exit() + sys.exit(1) # Make the window's context current glfw.glfwMakeContextCurrent(window)