Save Fbo for printing


I want to save an Fbo to an ofImage, thats no problem, but i need that the output omg has a dpi of 300ppp.

How can i save an oFimage with an specific dpi?

Natxo Pedreira Gonzalez

Just found some freeImage code to save an image and toggle some parametersā€¦ seems to work, photoshop when opens tell me 300dpi. Sorry i forget where i found this piece of codeā€¦

FIBITMAP * ofApp::getBmpFromPixels(ofPixels &pix){
    FIBITMAP * bmp = NULL;
    int w						= pix.getWidth();
    int h						= pix.getHeight();
    unsigned char * pixels		= pix.getPixels();
    int bpp						= pix.getBitsPerPixel();
    int bytesPerPixel			= pix.getBitsPerPixel() / 8;

    // part for little endian
    unsigned char temp;
    int pos;
    for (int i = 0; i < w*h; i++){
        pos = i * 3;
        temp = pixels[pos  ];
        pixels[pos  ] = pixels[pos+2];
        pixels[pos+2] = temp;
    }//end of part
    bmp	= FreeImage_ConvertFromRawBits(pixels, w,h, w*3,24,0,0,0, true);
    return bmp;  

and to call

string fname = ofToDataPath("saveexamaple.tif");

FIBITMAP * bmp	= getBmpFromPixels(img.getPixelsRef());

FreeImage_SetDotsPerMeterX(bmp, 11811);
FreeImage_SetDotsPerMeterY(bmp, 11811);

FreeImage_Save(fif, bmp, fname.c_str(), TIFF_NONE);
1 Like