Save image in BMP 1bit format


I want to save image in Bitmap with 1bit depth.
I use EasyBMP library. It’s working well but not very efficient :frowning:

#ifndef PBitmap_h
#define PBitmap_h
#include "EasyBMP.h"
#include "ofMain.h"

static void saveToBitmap1BitByPixel(ofImage &img, string absolutePath){
    BMP bmp;
    //save in BMP 1 bit depth
    bmp.SetSize(img.getWidth(), img.getHeight());
    RGBApixel px;
    for(int y=0; y<img.getHeight(); y++){
        for(int x=0; x<img.getWidth(); x++){

            px.Red = img.getColor(x, y).r;
            px.Green = img.getColor(x, y).g;
            px.Blue = img.getColor(x, y).b;
            bmp.SetPixel(x, y, px);
    char pp[1024];
    strcpy(pp, absolutePath.c_str());

#endif /* PBitmap_h */

May be someone else have a more elegant solution ?