read write routine connection

This commit is contained in:
2025-06-04 20:47:13 -04:00
parent 1610fdecd0
commit 2f1b05b0f7
20 changed files with 87 additions and 4 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ builddir = "./build_linux64"
doinstall = True #copies the build_output to the install dir when finished
cc = "g++" #compiler
cflags = "-fPIC"
libraries = "-l{} -lamscimglib4.linux64".format(libname)
libraries = "-l{} -lamscimglib4.linux64 -lpthread".format(libname)
libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,commondir,depdir)
linkerflags = "-static-libgcc -Wl,-rpath=."
srcexts = [".c",".cpp"]
+2 -2
View File
@@ -17,9 +17,9 @@ builddir = "./build_mingw64"
doinstall = True #copies the build_output to the install dir when finished
cc = "x86_64-w64-mingw32-g++" #compiler
cflags = "-fPIC -O3"
libraries = "-l{} -lamscimglib4.winx64".format(libname)
libraries = "-l{} -lamscimglib4.winx64 -lpthread".format(libname)
libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,commondir,depdir)
linkerflags = "-static-libgcc -static-libstdc++ -Wl,-rpath=."
linkerflags = "--static -static-libgcc -static-libstdc++ -Wl,-rpath=."
srcexts = [".c",".cpp"]
binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library
+1 -1
View File
@@ -19,7 +19,7 @@ cc = "x86_64-w64-mingw32-g++" #compiler
cflags = "-fPIC -O3"
libraries = "-l{} -lamscimglib4.winx64".format(libname)
libdirs = "-L{} -L{}/lib -L{}/lib".format(builddir,commondir,depdir)
linkerflags = "-static-libgcc -static-libstdc++ -Wl,-rpath=."
linkerflags = "--static -static-libgcc -static-libstdc++ -Wl,-rpath=."
srcexts = [".c",".cpp"]
binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
#include <amscppimglib4/amscppimglib4.hpp>
#include <amscppimglib4/amscppimglib4_intlutil.hpp>
#include <amscimglib4/amscimglib4.h>
namespace ams
{
@@ -458,4 +459,86 @@ namespace ams
return data[Nc + 4*(I + Nx*J)];
}
int read_image(const char *fname, amsimage* image)
{
int ret = amsimage_success;
int res;
amscimglib4_image *im2 = NULL;
if(image==NULL)
{
ret = amsimage_failure;
printf("read_image: Error: image pointer is null.\n");
return ret;
}
res = amscimglib4_image_new(&im2,1,1);
if(res!=amscimglib4_success)
{
ret = amsimage_failure;
printf("read_image: Error: c image struct failed to allocate.\n");
return ret;
}
amscimglib4_readimage(fname,im2);
//you can NOT move buffers. The im2 buffers are created with malloc, not new. No pseudo-move-semantics for you!
//copy buffers
res = image->resize(im2->sizex,im2->sizey);
if(res!=amsimage_success)
{
ret = amsimage_failure;
amscimglib4_image_delete(&im2);
printf("read_image: Error: c++ image failed to allocate.\n");
return ret;
}
//both structures have the same memory layout, so the internal copy function works
imglib4::amsimage_region_copy(
image->data,image->Nx,image->Ny,
im2->data,im2->sizex,im2->sizey,
0,0
);
amscimglib4_image_delete(&im2);
return ret;
}
int write_image(const char *fname, amsimage* image)
{
int ret = amsimage_success;
int res;
amscimglib4_image *im2 = NULL;
if(image==NULL)
{
ret = amsimage_failure;
printf("write_image: Error: image pointer is null.\n");
return ret;
}
res = amscimglib4_image_new(&im2,image->Nx,image->Ny);
if(res!=amscimglib4_success)
{
ret = amsimage_failure;
printf("write_image: Error: c image struct failed to allocate.\n");
return ret;
}
//both structures have the same memory layout, so the internal copy function works
imglib4::amsimage_region_copy(
im2->data,im2->sizex,im2->sizey,
image->data,image->Nx,image->Ny,
0,0
);
amscimglib4_writeimage(fname,im2);
amscimglib4_image_delete(&im2);
return ret;
}
};