How to save the picture you create

Do you use the Store Result operator. If you do how do you use it. Or do yo ujust do a screen capture.

Any help is appreciated.

Thanks

Unfortunately, I don't think

Unfortunately, I don't think there currently is a way to export an image. You will have to grab a screenshot. We should try to add that soon, I guess.

TGA Exporter

I wrote this yesterday as I was wondering the same thing. You can just extend the example code slightly and add this in at the end (or iterate over all the operations and save those with the GetName() value of "Store Result").

typedef struct {
char idlength;
char colourmaptype;
char datatypecode;
short int colourmaporigin;
short int colourmaplength;
char colourmapdepth;
short int x_origin;
short int y_origin;
short width;
short height;
char bitsperpixel;
char imagedescriptor;
} TGAHeader;

void writeTGA(NOperator* op, std::string path = "") {

NBitmap* pbmp = (NBitmap*)op->m_pObj;

TGAHeader header;
header.idlength=0;
header.colourmaptype=0;
header.datatypecode=2;
header.colourmaporigin=0;
header.colourmaplength=0;
header.colourmapdepth=0;
header.x_origin=0;
header.y_origin=0;
header.width = (short)pbmp->GetWidth();
header.height = (short)pbmp->GetHeight();
header.bitsperpixel= 32;
header.imagedescriptor=0;

std::string tganame (path);
if(tganame.size()>0) tganame += "\\";
tganame += op->GetUserName();
tganame += ".tga";

FILE* tgaf = fopen(tganame.c_str(),"wb");
fwrite(&header.idlength, 1, 1, tgaf);
fwrite(&header.colourmaptype, 1, 1, tgaf);
fwrite(&header.datatypecode, 1, 1, tgaf);
fwrite(&header.colourmaporigin, 2, 1, tgaf);
fwrite(&header.colourmaplength, 2, 1, tgaf);
fwrite(&header.colourmapdepth, 1, 1, tgaf);
fwrite(&header.x_origin, 2, 1, tgaf);
fwrite(&header.y_origin, 2, 1, tgaf);
fwrite(&header.width, 2, 1, tgaf);
fwrite(&header.height, 2, 1, tgaf);
fwrite(&header.bitsperpixel, 1, 1, tgaf);
fwrite(&header.imagedescriptor, 1, 1, tgaf);

RGBA* pixels = pbmp->GetPixels();

char* offset=0;
for(int y=header.height-1;y>0;y--) {
offset = (char*) pixels + y*header.width*4;
for(int x=0;x<header.width;x++) {
offset += 4;
fwrite(offset+2, 1, 1, tgaf);
fwrite(offset+1, 1, 1, tgaf);
fwrite(offset, 1, 1, tgaf);
fwrite(offset+3, 1, 1, tgaf);
}
}

fclose(tgaf);
}

Thanks!

Thank you! I will add this shortly.

cool

There were a couple silly bugs in the pixel writing loop. The corrected version is below:


for(int y=header.height-1;y>=0;y--) {
offset = (char*) pixels + y*header.width*4;
for(int x=0;x<header.width;x++) {
fwrite(offset+2, 1, 1, tgaf);
fwrite(offset+1, 1, 1, tgaf);
fwrite(offset, 1, 1, tgaf);
fwrite(offset+3, 1, 1, tgaf);
offset += 4;
}
}

Done

I've now added a "Export TGA" option to the context menu of the preview viewport. I think that's fine for now, but something to export all "Store Result" operators in a page (or group, or file) will have to be added eventually as well.

I haven't added your name to the contributor list on the source file since I don't know it. I'll add it if you want me to though.

contributor list

Can you add a credit to Andrew Caudwell (acaudwell at gee m ail)

Cheers

Done

and done :)

Regarding exporting

Useful though any form of exporting is, those without photoshop or other image tools, none of which currently reside on this computer due to hard-drive damage, lose the ability to use their exported textures. Requested: a .bmp or .png export option so that it is at least possible to admire the exported textures in a decent web-browser.

Designers without programming experience obviously cannot do this themselves, or there would be a proposed program in this very post.

--:A/H:
studio maru