The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 one question about export_all_graphs_to_BMP()

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
tony_lincoln Posted - 09/10/2006 : 11:03:00 PM
Hi,

After the curve fitting, I need to save all graphs created by Origin, the BMP name should correspond to my txt file in which there is data for one curve. So I changed the demo codes provided by Origin as the following:

void export_all_graphs_to_BMP(int fileNB, StringArray txtFileFullName)
{
PageBase pgb;
pgb = Project.Pages(); // Get the project's active page
if( pgb.IsValid() )
printf("Active page is of type %d\n", pgb.GetType());
else
printf("Active page is invalid\n");

StringArray BMPFileFullName;
string BMPFileBaseName = "";
string BMPFilePath = getPath(txtFileFullName[0]);

for(int i=0; i < fileNB; i++)
{
txtFileFullName[i] = txtFileFullName[i].Mid(0, lstrlen(txtFileFullName[i])-4);
BMPFileBaseName = getBaseName(txtFileFullName[i]);
BMPFileBaseName.Replace("cut_normalizedCell_ ", "cf_");
string fileName = BMPFilePath +"\\" + BMPFileBaseName + ".BMP";
printf("*****3: %s\n", fileName);
// Mike, until here, the codes still work.

string strFormat = "BMP"; // Width in pixels
int nWidth = 1024; // Get page properties and set height appropriately to// maintain aspect ratio
GraphPage gpg = pgb;
int nHeight = (int) (nWidth * gpg.Dimension.Height.dVal / gpg.Dimension.Width.dVal); // Bits per pixel
int nBitsPerPixel = 8; // Set export file path to be in the User Files folder - change as desired

BOOL bRet = export_page_to_image(fileName, strFormat, pgb, nWidth, nHeight, nBitsPerPixel);
// Report on error
if( !bRet ) printf("Failed to export graph page: %s\n", pgb.GetName());
}

}/////////////////////////////////////////////////////////////////////////////////

Yesterday it can run perfectly and the graph can be saved as BMP with the name corresponding to the txtFileFullName in which there is a curve. But today, when I run the codes again, it says:

....
*****3: C:\data\FittingResults\BMP\cf_132.BMP
Calling members of unattached wrapper class
Calling members of unattached wrapper class
Calling members of unattached wrapper class
Calling members of unattached wrapper class
Command Error!

This means that the last second line of the codes can not work: export_page_to_image(). But why did it work yesterday?!

Thanks in advance.
Tony
3   L A T E S T    R E P L I E S    (Newest First)
tony_lincoln Posted - 09/11/2006 : 1:42:45 PM
Thanks. Actually the key method is export_page_to_image(). I put it into the method simple_import_and_fit() that Mike provided several days ago and it works. Thanks a lot!
Tony
Mike Buess Posted - 09/11/2006 : 08:35:59 AM
Another problem with your version of the example is that you will get fileNB copies of the same BMP rather than fileNB different BMPs. The original code exports all graphs as BMP whereas your code exports the same graph fileNB times.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/11/2006 08:37:46 AM
Deanna Posted - 09/11/2006 : 01:26:56 AM
The problem seems to be that pgb is not valid. This happens when the active page is not a graph page. I guess yesterday you ran the function when a graph page is activated but today, the active page is not a graph. Please check.

I suggest that the first few lines should be changed to:

PageBase pgb;
pgb = Project.Pages(); // Get the project's active page
if( pgb.IsValid() )
printf("Active page is of type %d\n", pgb.GetType());
else
{
printf("Active page is invalid\n");
return; //Return immediately
}

Then if pgb is not valid, the function will return immediately, without executing the rest part of the function.

Deanna
OriginLab GZ Office

Edited by - Deanna on 09/11/2006 01:28:16 AM

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000