Hello Gwyddion-users!
I've been trying to use the libraries provided (in C++) to write a
program that loads one of the supported file types, and then exports
to another format. I'm currently using Microsoft Visual Studio 2010 on
a 64-bit Vista machine. I've run in to some difficulty lately I've
been unable to resolve as yet - it seems that gwy_file_load fails,
throwing the error " Cannot load `sample.mi': No module can load this
file type." This failure persists for any file type I try, supported
or not.
The relevant portion of my code:
/* Name of the file to display */
const gchar *filename = argv[1];
if(argc != 2){
std::cout << "Usage: mi2bitmap <filename>" << std::endl;
return 1;
}
/* Error Initialization */
GError *err = NULL;
/* The data file contents */
GwyContainer *data;
/* Initialize Gtk+ */
gtk_init(&argc, &argv);
/* Initialize Gwyddion stuff */
gwy_app_init_common(&err, "layer", "file", NULL);
/* Name of the file to export as */
const gchar *extension = "jpeg";
gchar *mpath = gwy_find_self_dir("");
gchar *importfilenamefull = g_build_filename(mpath, "\\" , filename, NULL);
gchar *exportfilenamefull = g_build_filename(mpath, "\\" , filename,
".", extension, NULL);
gchar *gfilename =
g_filename_from_utf8(gwy_canonicalize_path(importfilenamefull), -1,
NULL, NULL, &err);
/* Detect File Type -- Crashes! */
//std::cout << gwy_file_detect(gfilename, TRUE,
GWY_FILE_OPERATION_LOAD) << std::endl;
/* Load the file */
data = gwy_file_load(gfilename, GWY_RUN_NONINTERACTIVE, &err);
if (!data) {
g_printerr("File load error: Cannot load `%s': %s\n", argv[1],
err->message);
g_clear_error(&err);
return 1;
}
You'll note that I've used "canonicalize_path" and
"filename_from_utf8" just to make sure the problem isn't with the
filename... Also note that gwy_file_detect crashes the program if it
is uncommented, nomatter what filename I put in there - the debugger
shows this occurs on the following line in the stack:
main_loop:
mov eax,dword ptr [ecx] ; read 4 bytes
Please bear with me as this is a learning experience and I'm a
beginner with C++. Any help with this would be much appreciated, thank
you.
Ryan
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Gwyddion-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gwyddion-users