text:
Q: Como espelhar uma imagem? Gostaria de sabe como faço para espelhar uma imagem.
Consegui um algoritmo, mas ele só inverte imagens com resolução 60x60 e bpp=1.
Tenho o seguinte modelo de imagem para testar:
unsigned char icon[] ={
    //HEADER
    0x42, 0x4D,             // 0-1   BM
    0xF6, 0x07, 0x00, 0x00, // 2-5   uint32 filesize (not reliable)
    0x00, 0x00, 0x00, 0x00, // 6-9   uint32 0
    0x76, 0x00, 0x00, 0x00, // 10-13 uint32 bitmapOffset

    0x28, 0x00, 0x00, 0x00, // 14-17 uint32 info size
    0x3C, 0x00, 0x00, 0x00, // 18-21 int32  width
    0x3C, 0x00, 0x00, 0x00, // 22-25 int32  height
    0x01, 0x00,             // 26-27 uint16 nplanes
    0x04, 0x00,             // 28-29 uint16 bits per pixel bpp bitCount
    0x00, 0x00, 0x00, 0x00, // 30-33 uint32 compression flag
    0x00, 0x00, 0x00, 0x00, // 34-37 uint32 image size in bytes
    0xC4, 0x0E, 0x00, 0x00, // 38-41 int32  biXPelsPerMeter
    0xC4, 0x0E, 0x00, 0x00, // 32-45 int32  biYPelsPerMeter
    0x00, 0x00, 0x00, 0x00, // 46-49 uint32 colors used
    0x00, 0x00, 0x00, 0x00, // 50-53 uint32 important color count
    //*********************************************
    //Dados da imagem:
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80,
0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF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 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
                };

Alguém teria alguma ideia de onde eu deveria fazer um melhor ajuste neste algoritmo?
Suponhamos que temos uma imagem 10x10 pixels, com bpp=1. O tamanho da linha seria de 10 bits? Será que tenho que inverter esses bits por linha, para ter o resultado almejado? Alguém sabe como se faz isso?
Eis o algoritmo que tenho:
int getBytesPerRow(int bpp, int width)
{
    switch (bpp)
    {
    case 1: return (width >> 3) + ((width & 0x7) == 0 ? 0 : 1);
    case 4: return (width >> 1) + ((width & 0x1) == 0 ? 0 : 1);
    case 8: return width;
    case 24: return width * 3;
    default: return -1;
    }
}

void ImageMirror(uchar *bmpBytes, int width, int height, int lenght, int bpp)
{

    int32 bmpRowLength;
    int32 imgRowLength;
    int32 imgRow;

    struct ImageInfo imageInfo;

    imageInfo.width = width;
    imageInfo.height = height;
    imageInfo.bpp = bpp;

    // imRowLength is the number of bytes that represent each line
    // bmpRowLength is the length of line in pixels and should be rounded to the next 32 bits boundary
    imgRowLength = getBytesPerRow(imageInfo.bpp, imageInfo.width);
    bmpRowLength = (imgRowLength & 0xFFFC) + ((imgRowLength & 3) == 0 ? 0 : 4);

    imageInfo.imageLength = imgRowLength * imageInfo.height;

    imageInfo.imageBytes = wabaVm->Malloc(imageInfo.imageLength);

    // invert the image, so it's stored upside up
    for (imgRow = 0; imgRow < imageInfo.height; imgRow++)
    {
        // if row size is less than the number of pixels per row
        int index = imgRow * imgRowLength;
        uchar *bmpRow = &bmpBytes[(imageInfo.height - imgRow - 1) * bmpRowLength];
        uchar *imgRow = &imageInfo.imageBytes[index];
        memcpy(imgRow, bmpRow, imgRowLength);
    }
    memset(bmpBytes, 0, lenght);
    memcpy(bmpBytes, imageInfo.imageBytes, lenght);
    Free(imageInfo.imageBytes);
}

A: Considerando que sua imagem seja algo como:
/* Imagem 13x10 */
char image[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
                 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0,
                 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0,
                 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0,
                 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0,
                 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

Para inverte-la, você pode fazer a troca dos pixels contidos no começo da imagem com os pixels contidos no final da imagem, veja só:
void image_mirror( char * img, int width, int height )
{
     /* Pixel auxiliar */
    char aux = 0;

    /* Pixel canto superior esquerdo */
    char * a = img;

    /* Pixel canto inferior direito */
    char * b = &img[ ( height * width ) - 1 ];

    /* Troca os pixels do comeco com os pixels do final */
    for( ; a < b; a++, b-- )
    {
        aux = *a;
        *a = *b;
        *b = aux;
    }
}

Colocando tudo junto:
#include <stdio.h>

void image_show( char * img, int width, int height )
{
    int i = 0;
    int w = 0;
    int h = 0;

    for( h = 0; h < height; h++ )
    {
        for( w = 0; w < width; w++ )
            printf( "%s", img[i++] ?  "X " : "  " );
        printf( "\n" );
    }
}

void image_mirror( char * img, int width, int height )
{
    char aux = 0;
    char * a = img;
    char * b = &img[ ( height * width ) - 1 ];

    for( ; a < b; a++, b-- )
    {
        aux = *a;
        *a = *b;
        *b = aux;
    }
}

int main( int argc,char ** argv )
{
    /* Imagem 13x10 */
    char image[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                     0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                     0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
                     0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0,
                     0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0,
                     0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                     0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0,
                     0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0,
                     0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0,
                     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

    printf("Imagem Original:\n");
    image_show( image, 13, 10 );

    /* Inverte imagem de ponta a cabeca */
    image_mirror( image, 13, 10 );

    printf("Imagem Invertida:\n");
    image_show( image, 13, 10 );

    return 0;
}

Saída:
Imagem Original:

    X X           X
        X       X
      X X X X X X X
    X X   X X X   X X
  X X X X X X X X X X X
  X   X X X X X X X   X
  X   X           X   X
        X X   X X

Imagem Invertida:

        X X   X X
  X   X           X   X
  X   X X X X X X X   X
  X X X X X X X X X X X
    X X   X X X   X X
      X X X X X X X
        X       X
      X           X X

Veja funcionando no Repl.it

A: "(...) como faço para espelhar uma imagem. (...) Será que tenho que inverter esses bits por linha, para ter o resultado almejado? (...)"
Se a intenção é espelhar uma imagem na horizontal com 1 bit por pixel (1bpp), a resposta à pergunta é sim. Da mesma forma que é necessário inverter a ordem byte por linha, também é necessário inverter a ordem pixel dentro de 1 byte.
O exemplo de "modelo de imagem para testar" da pergunta  é uma imagem BMP com 4 bits por pixel (4bpp), neste caso é necessário inverter, não a ordem bit, mas a ordem nibble (4 bits).
Imagens BMP 1bpp, 4bpp e 8bpp:
Para fazer espelhos na horizontal no formato pixel 1bpp (1 pixel por bit, ou seja, 8 pixeis por byte) é necessário inverter a ordem bit. Por exemplo, inverter a ordem bit de um byte (8 pixeis):
mirrored_Pixels_Per_Byte = (b & 128) >> 7 | (b & 64) >> 5 | (b & 32) >> 3 | (b & 16) >> 1 | (b & 8) << 1 | (b & 4) << 3 | (b & 2) << 5 | (b & 1) << 7;
Para fazer espelhos na horizontal no formato pixel 4bpp (1 pixel por cada 4 bits, ou seja, 2 pixeis por byte) é necessário inverter a ordem nibble (4 bits). Por exemplo, inverter a ordem nibble de um byte (2 pixeis):
mirrored_Pixels_Per_Byte = (b & 15) << 4 | (b >> 4);
Para fazer espelhos na horizontal no formato pixel 8bpp (1 pixel por cada 8 bits, ou seja, 1 pixel por byte) basta copiar.
Este é o formato mais simples, visto que um pixel é igual a um byte. Por exemplo:
mirrored_Pixel = b;
O problema é que para 1bpp (quando o valor "width" da imagem em pixeis não é um múltiplo de 8) e 4bpp (quando o valor "width" da imagem em pixeis não é um múltiplo de 2) nem tudo são pixeis dentro de um byte.
Por exemplo uma imagem 1bpp com 9 pixeis x 2 pixeis (width x height):
Como 9 bit-pixeis por linha ("width") não cabem em 2 bytes completos (16 bit), o último byte de cada linha de pixeis é composto por 1 bit-pixel + 7 bits de valor 0.
Estes 7 bits de valor 0 não são pixeis e devem ser mantidos no final de cada linha de pixeis.
Se forem movidos para o início de cada linha serão interpretados erradamente como pixeis e verá uma linha adicional (vertical) com 7 pixeis de largura do lado esquerdo da imagem.
Isto é válido para eventuais bytes de preenchimento "padding for 4 byte alignment" especificados para o formato de imagem BMP.
Por exemplo como 2 bytes (8 bit-pixeis + 1 bit-pixel + 7 bits de valor 0) não são um múltiplo de 4 bytes, "padding for 4 byte alignment", cada linha da imagem, neste caso, será composta por 2 bytes + 2 bytes adicionais de preenchimento. Os valores byte de preenchimento para "padding for 4 byte alignment" podem ser 0 ou qualquer outro e o seu valor não é importante.
Este "padding for 4 byte alignment" é obrigatório e a sua ausência, quando uma linha de pixeis não for um múltiplo de 4 bytes, gera um erro na imagem.
#include <stdio.h>

unsigned char icon[] ={ // bitmap 4bpp
// BITMAP FILE HEADER
       66, 77, //   0-1 (2 bytes uint16) "BM"
 246, 7, 0, 0, //   2-5 (4 bytes uint32) File size in bytes. Exemplo de como transfromar 4 bytes LE em um número: ( ( 246 ) << 0) | ( ( 7 ) << 8) | ( ( 0 ) << 16) | ( ( 0 ) << 24) = 2038
         0, 0, //   6-7 (2 bytes uint16) Reserved
         0, 0, //   8-9 (2 bytes uint16) Reserved
 118, 0, 0, 0, // 10-13 (4 bytes uint32) Offset where the image data (pixel array) can be found
// DIB HEADER
  40, 0, 0, 0, // 14-17 (4 bytes uint32) Size of DIB header in bytes
  60, 0, 0, 0, // 18-21 (4 bytes  int32) Image Width in pixels
  60, 0, 0, 0, // 22-25 (4 bytes  int32) Image Height in pixels
         1, 0, // 26-27 (2 bytes uint16) Number of color planes (must be 1)
         4, 0, // 28-29 (2 bytes uint16) Number of bits per pixel (bpp) (must be 1, 2, 4, 8, 16, 24 or 32). Exemplo de como transfromar 2 bytes LE em um número: ( ( 4 ) << 0) | ( ( 0 ) << 8) = 4
   0, 0, 0, 0, // 30-33 (4 bytes uint32) Value of compression method (can be 0, 1, 2, 3, 4, 5 or 6) (0 == compression none BI_RGB)
   0, 0, 0, 0, // 34-37 (4 bytes uint32) Size of image data (pixel array); a dummy 0 can be given for BI_RGB bitmaps
196, 14, 0, 0, // 38-41 (4 bytes uint32) Horizontal resolution of the image (pixels per meter)
196, 14, 0, 0, // 42-45 (4 bytes uint32) Vertical resolution of the image (pixels per meter)
  16, 0, 0, 0, // 46-49 (4 bytes uint32) Number of colors in the color palette
  16, 0, 0, 0, // 50-53 (4 bytes uint32) Number of important colors used, or 0 when every color is important; generally ignored
// COLOR PALETTE (color array)
  0,   0,   0, 255, // RGB (BGR LE)
  0,   0, 128, 255, // The number of entries is equal to the maximum size possible for the color palette (ncolors = 1 << bpp; or pow(2, bpp);)
  0, 128,   0, 255, // O valor da 4ª coluna deve ser ignorado e intrepretado como padding.
  0, 128, 128, 255, // O valor da 4ª coluna pode, ou deveria, ser 0.
128,   0,   0, 255, // Quando DIB header size == 12 só existem 3 colunas.
128,   0, 128, 255,
128, 128,   0, 255,
128, 128, 128, 255,
192, 192, 192, 255,
  0,  0,  255, 255,
  0, 255,   0, 255,
  0, 255, 255, 255,
255,   0,   0, 255,
255,   0, 255, 255,
255, 255,   0, 255,
255, 255, 255, 255,
// IMAGE DATA (pixel array)
/** Row of pixels (scan-line) ---> (60 pixeis * 4bpp / 8 = 30 bytes)                                                                               */
/** Para 4bpp cada byte contem 2 pixeis                                                                                */
/** 4bpp (1 pixel por cada 4 bits ---> 2 pixeis por byte) (2 nibbles por byte)                                                                     */
/** Row of pixels tem que ser um múltiplo de 8 bits. Exemplo: ((59 pixeis * 4bpp) + 8 - 1 - ((59 pixeis * 4bpp) + 8 - 1) % 8) / 8 = 30 bytes       */
/** Se o valor Width não for múltiplo de 2 o último byte de Row of pixels é composto por 1 nibble-pixel + 1 nibble de valor 0(extra padding nibble)*/
/** Para 4bpp cada nibble-pixel representa um índice referente a uma cor contida na palete de cores                                                */
/** Para extrair 2 nibbles (2 índices) de 1 byte: left_nibble = byte >> 4; right_nibble = byte & 15                                                */
/** Para inverter a ordem nibble de 1 byte (espelhar 1 byte composto por 2 nibbles): (byte & 15) << 4 | (byte >> 4)                                */
/** Para transformar 2 nibbles em 1 byte: (left__nibble << 4) | right_nibble                                                                       */
/** Se o valor Height da imagem for positivo os pixeis são armazenados a partir do canto inferior direito (1º pixel) para o canto superior esquerdo*/
/** Se o valor Height da imagem for negativo os pixeis da imagem são armazenados do canto superior esquerdo para o canto inferior direito          */
/** O valor Height negativo é válido para bitmaps sem compressão e DIB header size > 12                                                            */
/** Para converter um número negativo para 4 bytes LE, por exemplo -60:                                                                            */
/** nB1 = ( -60 ) >> 0 & 255; nB2 = ( -60 ) >> 8 & 255; nB3 = ( -60 ) >> 16 & 255; nB4 = ( -60 ) >> 24 & 255;                                      */
/**/255,/*<--- os últimos 2 pixeis da imagem*/ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /**/0, 0,/** Padding for 4 byte alignment (scan-line boundary padding), could be a value other than zero. */
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /**/0, 0,/** Se "Row of Pixels" (scan-line) não for um múltiplo de 4 bytes "Total Row Size" (stride) será (RowOfPixelsize + 4 - 1 - (RowOfPixelsize + 4 - 1) % 4) */
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /**/0, 0,/** Exemplo: 30 bytes + 4 - 1 - (30 bytes + 4 - 1) % 4 = 32 bytes */
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 131, 153, 153,  51,  59, 184, 143, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248, 153, 153, 153, 153,  51, 187, 179,  59, 143, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 248, 153, 153, 153, 153,  51, 139, 187, 179, 187,  59, 143, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 153, 153, 153, 143, 255, 255, 255, 255, 248, 179,  59,  59, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 137, 153, 151, 255, 255, 255, 255, 255, 255, 255, 255, 139,  59,  56, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 248, 153, 147, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 179, 179, 143, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 121, 153, 143, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248,  59,  56, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 248, 153, 152, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 179, 143, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 137, 153, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 187,  56, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 153, 152, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 243, 179, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 249, 153, 143, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248,  59, 191, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 137, 147, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 131,  56, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 153, 159, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 187, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 248, 153, 143, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248,  51, 143, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 249, 153, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 179, 191, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 137, 152, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 131,  56, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 153, 159, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251,  59, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 136, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 136, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 119, 143, 255, 255, 119, 143, 255, 248, 119, 255, 119, 119, 127, 255, 248, 119, 119, 143, 248, 119, 255, 255, 247, 120, 247, 120, 255, 255, 0, 0,
255, 255,  64, 127, 255, 255,  68, 111, 255, 244,  68, 244,  68,  68,  68, 143, 128,  68,  68,  70, 248,   0, 127, 255, 132,   7, 244,   6, 255, 255, 0, 0,
255, 255,  68, 127, 255, 255, 116,  79, 255, 244,  71, 246,  70, 102,  68,  79, 132,  70, 100,  68, 127,  68, 111, 255, 116,  72, 246,  70, 255, 255, 0, 0,
255, 255,  68, 127, 255, 255, 132,  70, 102, 100,  72, 255, 255, 255, 100,  15, 248, 255, 248,  68, 111, 116,  70, 103, 100,  79, 246,  70, 255, 255, 0, 0,
255, 255,  68, 127, 255, 255, 244,  68,  68,  68,  79, 255, 255, 255, 116,  15, 255, 255, 255,  68, 111, 132,  68,  68,  68, 111, 246,  70, 255, 255, 0, 0,
255, 255,  68,  68,  70, 143, 246,  68, 119,  68, 127, 255, 248, 118,  68,  79, 255, 248, 118,  68, 111, 244,  70, 119,  68, 143, 246,  70, 255, 255, 0, 0,
255, 255,  68,  68,  68,  72, 247,  68, 255,  68, 143, 255, 100,  68,  68, 127, 248, 100,  68,  68, 143, 246,  70, 247,  68, 255, 246,  70, 255, 255, 0, 0,
255, 255,  68, 103, 116,  68, 255,  68, 136,  68, 255, 246,  68,  68, 104, 255, 244,  68,  68, 104, 255, 247,  68, 246,  70, 255, 246,  70, 255, 255, 0, 0,
255, 255,  68, 127, 246,  68, 255,  68, 119,  70, 255, 244,  68, 143, 255, 255, 132,  70, 255, 255, 255, 255,  68, 132,  71, 255, 246,  70, 255, 255, 0, 0,
255, 255,  68, 127, 246,  68, 255, 116, 100,  71, 255, 244,  70, 255, 255, 255, 116,  72, 255, 255, 255, 255,  68, 116,  72, 255, 246,  70, 255, 255, 0, 0,
255, 255,  68, 103, 116,  68, 255, 132,  68,  72, 255, 244,  68, 119, 118, 143, 132,  68, 119, 118, 255, 255, 116,  68,  79, 255, 246,  70, 255, 255, 0, 0,
255, 255,  68,  68,  68,  72, 255, 244,  68,  79, 255, 247,  68,  68,  64, 111, 246,  68,  68,  64, 143, 255, 132,  68, 127, 255, 244,  70, 255, 255, 0, 0,
255, 255, 102, 102, 102, 143, 255, 247, 102, 127, 255, 255, 134,  68, 102, 143, 255, 118,  68, 103, 255, 255, 246, 100, 143, 255, 246, 103, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 143, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 247,   6, 143, 255, 0, 0,
255, 255, 255, 255, 187, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 102, 255, 100,   8, 255, 0, 0,
255, 255, 255, 255, 139, 184, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 134, 104, 255, 247,  79, 255, 0, 0,
255, 255, 255, 255, 251, 187, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 230, 111, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 248, 187, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248, 102, 127, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 187, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 102, 143, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 139, 184, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 134, 103, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 251, 187, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 102, 111, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 187, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 102, 143, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 139, 187, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 102, 103, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 251, 187, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 102, 111, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 187, 187, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248, 102, 102, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 251, 187, 184, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 134, 102, 111, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 187, 187, 184, 255, 255, 255, 255, 255, 255, 255, 255, 134, 102, 102, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 248, 187, 187, 184, 255, 255, 255, 255, 255, 255, 134, 102, 102, 143, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 187, 187, 187, 136, 136, 136, 135, 102, 102, 102, 239, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 187, 187, 187, 187, 102, 102, 102, 102, 104, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248, 187, 187, 187, 102, 102, 110, 143, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248, 136, 136, 136, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /**/255,/*<--- os primeiros 2 pixeis da imagem*/ 0, 0,
};

A: "(...) como faço para espelhar uma imagem. (...) Será que tenho que inverter esses bits por linha, para ter o resultado almejado? (...)"
Continuação...
// continuação...
struct BMInfos {
    int isBM;
    int bpp;
    int Width;
    int absHeight;
    int StartOfImageDataOffset;
    int ImageDataSize;
    int TotalRowSize;
    int PixelRowSize;
    int PadSize;
    int isCompressed;
} inf;

void SetInfos() {
    inf.isBM = (icon[0] == 'B' && icon[1] == 'M');
    inf.StartOfImageDataOffset = (icon[10] << 0) | (icon[11] << 8) | (icon[12] << 16) | (icon[13] << 24);
    int dibSize = (icon[14] << 0) | (icon[15] << 8) | (icon[16] << 16) | (icon[17] << 24);
    inf.Width = (dibSize == 12) ? (icon[18] << 0) | (icon[19] << 8) : (icon[18] << 0) | (icon[19] << 8) | (icon[20] << 16) | (icon[21] << 24);
    int Height = (dibSize == 12) ? (icon[20] << 0) | (icon[21] << 8) : (icon[22] << 0) | (icon[23] << 8) | (icon[24] << 16) | (icon[25] << 24);
    inf.absHeight = (Height + (Height >> 31)) ^ (Height >> 31); /** O valor de "Height" pode ser negativo ou positivo. */
    inf.bpp = (dibSize == 12) ? (icon[24] << 0) | (icon[25] << 8) : (icon[28] << 0) | (icon[29] << 8);
    int Compression = (dibSize != 12) ? (icon[30] << 0) | (icon[31] << 8) | (icon[32] << 16) | (icon[33] << 24) : 0;
    inf.isCompressed  = (!(Compression == 0 || (Compression == 3 && (inf.bpp == 16 || inf.bpp == 32))));
    inf.ImageDataSize = ((((inf.Width * inf.bpp) + 31) & ~31) >> 3) * inf.absHeight;
    inf.PixelRowSize  = ((((inf.Width * inf.bpp) +  7) &  ~7) /  8); /** Tem que ser um múltiplo de 8 bits. (scan-ine)*/
    inf.TotalRowSize  = ((((inf.Width * inf.bpp) + 31) & ~31) >> 3); /** Tem que ser um múltiplo de 4 bytes. (stride)*/
    inf.PadSize = inf.TotalRowSize - inf.PixelRowSize; /** Os valores byte de prenchimento de linha para TotalRowSize "padding for 4 byte alignment" podem ser zero(s) ou qualquer outro valor. */
    int extraPaddingBitLevel = ((inf.PixelRowSize * 8) - (inf.Width * inf.bpp)) / inf.bpp; /** n bits|nibbles de prenchimento (nível bit) para PixelRowSize, "padding for 8 bit alignment". */

    printf( "\nBits per pixel: %d bpp", inf.bpp );
    printf( "\nImage width: %d pixels", inf.Width );
    printf( "\nImage height: %d pixels", inf.absHeight );
    printf( "\nStart of image data offset: %d", inf.StartOfImageDataOffset );
    printf( "\nImage data size: %d bytes", inf.ImageDataSize );
    printf( "\nTotal row size: %d bytes", inf.TotalRowSize );
    printf( "\nPixel row size: %d bytes", inf.PixelRowSize );
    printf( "\nPadding size: %d bytes", inf.PadSize );
    printf( "\nExtra padding, bit level: %d %s", extraPaddingBitLevel, inf.bpp == 1 ? "bits" : inf.bpp == 4 ? "nibbles" : "" );
    printf( "\nCompression value: %d", Compression );
    printf( "\nIs compressed: %s\n", inf.isCompressed ? "true" : "false" );
}

void Mirror() { // Espelhar um bitmap na horizontal
    int s = inf.StartOfImageDataOffset;
    int e = inf.StartOfImageDataOffset + (inf.ImageDataSize - 1) - inf.PadSize;

    if (inf.bpp == 1) {
        /** 1bpp (8 pixels por byte ---> 1 pixel por cada bit) (2 cores indexadas RGB (BGR LE)) */
        char auxT[inf.ImageDataSize * 8];
        int extraPaddingBits = ((inf.PixelRowSize * 8) - (inf.Width * inf.bpp)) / inf.bpp; /** Extra "padding", nível bit. Se existir, ... */
        /** ... por exemplo quando o valor "Width" da imagem não é um múltiplo de 8 os últimos bit-pixeis de cada linha de pixeis não cabem em 1 byte completo sendo este último byte constituído por n bit-pixeis + n bits de valor 0. */

        /** Converte todas as sequências byte em bit-pixeis (índices) invertendo a sua ordem por linha mas mantendo os bits de preenchimento no final de cada linha. Todos os bits serão armazenados temporariamente em auxT. */
        int k = 0;
        while (s <= e) {
            int i = 0;
            int j = inf.PixelRowSize;
            while (j--) {
                int l = (extraPaddingBits != 0 && i == 0) ? extraPaddingBits : 0; /** Mantêm os bits de preenchimento (nível bit) no final da linha de pixeis, se existirem. */
                while (l < 8) {
                    auxT[k + i] = icon[s + j] >> l & 1;
                    i++;
                    l++;
                }
            }
            s += inf.TotalRowSize;
            k += inf.TotalRowSize * 8;
        }
        /** Converte os bits para bytes e armazena-os nos dados da imagem */
        s = 0;
        e = sizeof(auxT) - 1;
        k = inf.StartOfImageDataOffset;
        while (s <= e) {
            char bit7 = auxT[s + 0];
            char bit6 = auxT[s + 1];
            char bit5 = auxT[s + 2];
            char bit4 = auxT[s + 3];
            char bit3 = auxT[s + 4];
            char bit2 = auxT[s + 5];
            char bit1 = auxT[s + 6];
            char bit0 = auxT[s + 7];
            icon[k] = (bit7 << 7) | (bit6 << 6) | (bit5 << 5) | (bit4 << 4) | (bit3 << 3) | (bit2 << 2) | (bit1 << 1) | (bit0 << 0);
            s += 8;
            k++;
        }
    }

    if (inf.bpp == 4) {
        /** 4bpp (2 pixeis por byte ---> 1 pixel por cada 4 bits) (2 nibbles por byte) (16 cores indexadas RGB (BGR LE)) */
        char auxT[inf.ImageDataSize * 2];
        int extraPaddingNibble = ((inf.PixelRowSize * 8) - (inf.Width * inf.bpp)) / inf.bpp; /** Extra "padding", nível bit. Se existir, ... */
        /** ... por exemplo quando o valor "Width" da imagem não é um múltiplo de 2 o último nibble-pixel de cada linha de pixeis não cabe em 1 byte completo sendo este último byte constituído por 1 nibble-pixel + 1 nibble de valor 0. */

        /** Converte todas as sequências byte em nibble-pixeis (índices) invertendo a sua ordem por linha mas mantendo os nibbles de preenchimento no final de cada linha. Todos os nibbles serão armazenados temporariamente em auxT. */
        int k = 0;
        while (s <= e) {
            int i = 0;
            int j = inf.PixelRowSize;
            while (j--) {
                if (!(extraPaddingNibble != 0 && i == 0)) auxT[k + i++] = icon[s + j] & 15; /** Mantêm o nibble de preenchimento (nível bit) no final da linha de pixeis, se existir. */
                auxT[k + i++] = icon[s + j] >> 4;
            }
            s += inf.TotalRowSize;
            k += inf.TotalRowSize * 2;
        }
        /** Converte as sequências nibble para byte e armazena todos os bytes nos dados da imagem */
        s = 0;
        e = sizeof(auxT) - 1;
        k = inf.StartOfImageDataOffset;
        while (s <= e) {
            icon[k] = (auxT[s + 0] << 4) | auxT[s + 1];
            s += 2;
            k++;
        }
    }

    if (inf.bpp >= 8) {
        /** 8bpp (1 pixel por byte ---> 1 pixel por cada 8bits) (256 cores indexadas RGB (BGR LE)) */
        /** 16bpp RGB ou ARGB (BGR ou BGRA LE) (1 pixel por cada 2 bytes ----> 1 pixel por cada 16 bits) (até 65536 cores únicas não indexadas) */
        /** 24bpp RGB (BGR LE) (1 pixel por cada 3 bytes ----> 1 pixel por cada 24 bits) (até 16777216 cores únicas não indexadas) */
        /** 32bpp ARGB (BGRA LE) (1 pixel por cada 4 bytes ----> 1 pixel por cada 32 bits) (até 4294967296 cores únicas não indexadas) */

        /** A partir de 8bpp todas as sequências índice (8bpp), RBG (16 e 24bpp) ou ARGB (16 e 32bpp) cabem em bytes completos. */
        /** A regra "padding for 4 byte alignment" continua a ser válida para 8, 16 e 24bpp. */
        /** 32bpp contêm naturalmente sequências de 4 bytes (1 B + 1 G + 1 R + 1 byte para o canal Alpha = 4 bytes). 32bpp nunca terá "paddings". */
        char b0, b1, b2, b3;
        int l, r, u, v, w;
        while (s <= e) {
            l = 0;
            r = inf.PixelRowSize - 1;
            while (l <= r) {
                                                   u = 0, w = 0;
                               if (inf.bpp >=  8) b0 = icon[s + l + u++];
                               if (inf.bpp >= 16) b1 = icon[s + l + u++];
                               if (inf.bpp >= 24) b2 = icon[s + l + u++];
                               if (inf.bpp >= 32) b3 = icon[s + l + u++];
                                                   v = u;
                if (inf.bpp >=  8) icon[s + l + w++] = icon[s + r - --u];
                if (inf.bpp >= 16) icon[s + l + w++] = icon[s + r - --u];
                if (inf.bpp >= 24) icon[s + l + w++] = icon[s + r - --u];
                if (inf.bpp >= 32) icon[s + l + w++] = icon[s + r - --u];
                if (inf.bpp >=  8) icon[s + r - --w] = b0;
                if (inf.bpp >= 16) icon[s + r - --w] = b1;
                if (inf.bpp >= 24) icon[s + r - --w] = b2;
                if (inf.bpp >= 32) icon[s + r - --w] = b3;
                l += v;
                r -= v;
            }
            s += inf.TotalRowSize;
        }
    }
}

void Flip() { // Espelhar um bitmap verticalmente
    int s = inf.StartOfImageDataOffset;
    int e = inf.StartOfImageDataOffset + inf.ImageDataSize;
    while (s < e) {
        int u = inf.TotalRowSize;
            while (u--) {
                                       char b0 = icon[s + u];
                                   icon[s + u] = icon[e - inf.TotalRowSize + u];
                icon[e - inf.TotalRowSize + u] = b0;
            }
        s += inf.TotalRowSize;
        e -= inf.TotalRowSize;
    }
}

void DIBFlip() { // Espelhar um bitmap verticalmente invertendo o sinal do valor "Height"
    int dibSize = (icon[14] << 0) | (icon[15] << 8) | (icon[16] << 16) | (icon[17] << 24);
    if (dibSize == 12) return; /** DIB Filp incompativel com OS/2 1.x BITMAPCOREHEADER (dibSize == 12) */
    int Height  = (icon[22] << 0) | (icon[23] << 8) | (icon[24] << 16) | (icon[25] << 24);
    int dib_flip = -(Height); /** Inverte o sinal do valor Height da imagem. */
    icon[22] = dib_flip >>  0 & 255;
    icon[23] = dib_flip >>  8 & 255;
    icon[24] = dib_flip >> 16 & 255;
    icon[25] = dib_flip >> 24 & 255;
}

void MirrorFlip() { // Espelhar um bitmap na horizontal e na vertical ao mesmo tempo
    int s = inf.StartOfImageDataOffset;
    int e = inf.StartOfImageDataOffset + (inf.ImageDataSize - 1) - inf.PadSize;

    /*
    if (inf.bpp == 1) { // Implementação mais simples, mas não funciona corretamente se o "Width" da imagem não for múltiplo de 8.
        // 1bpp (8 pixels por byte ---> 1 pixel por cada bit) (até 2 cores indexadas RGB (BGR LE))
        while (s <= e) {
            char b0 = icon[s];
            char b1 = icon[e];
               icon[s] = (b1 & 128) >> 7 | (b1 & 64) >> 5 | (b1 & 32) >> 3 | (b1 & 16) >> 1 | (b1 & 8) << 1 | (b1 & 4) << 3 | (b1 & 2) << 5 | (b1 & 1) << 7;
               icon[e] = (b0 & 128) >> 7 | (b0 & 64) >> 5 | (b0 & 32) >> 3 | (b0 & 16) >> 1 | (b0 & 8) << 1 | (b0 & 4) << 3 | (b0 & 2) << 5 | (b0 & 1) << 7;
            s++;
            e--;
        }
    }
    */

    if (inf.bpp == 1) {
        /** 1bpp (8 pixels por byte ---> 1 pixel por cada bit) (2 cores indexadas RGB (BGR LE)) */
        char auxT[inf.ImageDataSize * 8];
        int extraPaddingBits = ((inf.PixelRowSize * 8) - (inf.Width * inf.bpp)) / inf.bpp; /** Extra "padding", nível bit. */
        /** Converte todas as sequências byte em bit-pixeis (índices) invertendo totalmente a sua ordem mas mantendo os bits de preenchimento no final de cada linha. Todos os bits serão armazenados temporariamente em auxT. */
        int k = 0;
        while (s <= e) {
            int j = (extraPaddingBits != 0 && k == 0) ? extraPaddingBits : 0; /** Mantêm os bits de preenchimento (nível bit) no final da linha de pixeis, se existirem. */
            while (j < 8) {
                auxT[k] = icon[e] >> j & 1;
                j++;
                k++;
            }
            e--;
        }
        /** Converte os bits para bytes e armazena-os nos dados da imagem */
        /** Durante o processo de conversão eventuais bytes de preenchimento, "padding for 4 byte alignment", poderão adquirir novos valores diferentes dos seus valores originais. Estes, possíveis, novos valores não são importantes. */
        s = 0;
        e = sizeof(auxT) - 1;
        k = inf.StartOfImageDataOffset;
        while (s <= e) {
            char bit7 = auxT[s + 0];
            char bit6 = auxT[s + 1];
            char bit5 = auxT[s + 2];
            char bit4 = auxT[s + 3];
            char bit3 = auxT[s + 4];
            char bit2 = auxT[s + 5];
            char bit1 = auxT[s + 6];
            char bit0 = auxT[s + 7];
            icon[k] = (bit7 << 7) | (bit6 << 6) | (bit5 << 5) | (bit4 << 4) | (bit3 << 3) | (bit2 << 2) | (bit1 << 1) | (bit0 << 0);
            s += 8;
            k++;
        }
    }

    /*
    if (inf.bpp == 4) { // Implementação mais simples, mas não funciona corretamente se o "Width" da imagem não for múltiplo de 2.
        // 4bpp (2 pixeis por byte ---> 1 pixel por cada 4 bits) (2 nibbles por byte) (até 16 cores indexadas RGB (BGR LE))
        while (s <= e) {
            char b0 = icon[s];
               icon[s] = (icon[e] & 15) << 4 | (icon[e] >> 4);
               icon[e] = (     b0 & 15) << 4 | (     b0 >> 4);
            s++;
            e--;
        }
    }
    */

    if (inf.bpp == 4) {
        /** 4bpp (2 pixeis por byte ---> 1 pixel por cada 4 bits) (2 nibbles por byte) (16 cores indexadas RGB (BGR LE)) */
        char auxT[inf.ImageDataSize * 2];
        int extraPaddingNibble = ((inf.PixelRowSize * 8) - (inf.Width * inf.bpp)) / inf.bpp; /** Extra "padding", nível bit. */
        /** Converte todas as sequências byte em nibble-pixeis (índices) invertendo totalmente a sua ordem mas mantendo os nibbles de preenchimento no final de cada linha. Todos os nibbles serão armazenados temporariamente em auxT. */
        int k = 0;
        while (s <= e) {
            if (!(extraPaddingNibble != 0 && k == 0)) auxT[k++] = icon[e] & 15; /** Mantêm o nibble de preenchimento (nível bit) no final da linha de pixeis, se existir. */
            auxT[k++] = icon[e] >> 4;
            e--;
        }
        /** Converte as sequências nibble para byte e armazena todos os bytes nos dados da imagem */
        /** Durante o processo de conversão eventuais bytes de preenchimento, "padding for 4 byte alignment", poderão adquirir novos valores diferentes dos seus valores originais. Estes, possíveis, novos valores não são importantes. */
        s = 0;
        e = sizeof(auxT) - 1;
        k = inf.StartOfImageDataOffset;
        while (s <= e) {
            icon[k] = (auxT[s + 0] << 4) | auxT[s + 1];
            s += 2;
            k++;
        }
    }

    if (inf.bpp >= 8) {
        /** 8bpp (1 pixel por byte ---> 1 pixel por cada 8bits) (256 cores indexadas RGB (BGR LE)) */
        /** 16bpp RGB ou ARGB (BGR ou BGRA LE) (1 pixel por cada 2 bytes ----> 1 pixel por cada 16 bits) (até 65536 cores únicas não indexadas) */
        /** 24bpp RGB (BGR LE) (1 pixel por cada 3 bytes ----> 1 pixel por cada 24 bits) (até 16777216 cores únicas não indexadas) */
        /** 32bpp ARGB (BGRA LE) (1 pixel por cada 4 bytes ----> 1 pixel por cada 32 bits) (até 4294967296 cores únicas não indexadas) */

        /** A partir de 8bpp todas as sequências índice (8bpp), RBG (16 e 24bpp) ou ARGB (16 e 32bpp) cabem em bytes completos. */
        /** A regra "padding for 4 byte alignment" continua a ser válida para 8, 16 e 24bpp. */
        /** Os eventuais bytes de preenchimento, "padding for 4 byte alignment", são facilmente mantidos no final de cada linha bastando para isso criar um desfasamento no valor "end" do laço while ou for: e = inf.StartOfImageDataOffset + (inf.ImageDataSize - 1) - inf.PadSize;. */
        int u, v, w;
        char b0, b1, b2, b3;
        while (s <= e) {
                                           u = 0, w = 0;
                       if (inf.bpp >=  8) b0 = icon[s + u++];
                       if (inf.bpp >= 16) b1 = icon[s + u++];
                       if (inf.bpp >= 24) b2 = icon[s + u++];
                       if (inf.bpp == 32) b3 = icon[s + u++];
                                           v = u;
            if (inf.bpp >=  8) icon[s + w++] = icon[e - --u];
            if (inf.bpp >= 16) icon[s + w++] = icon[e - --u];
            if (inf.bpp >= 24) icon[s + w++] = icon[e - --u];
            if (inf.bpp == 32) icon[s + w++] = icon[e - --u];
            if (inf.bpp >=  8) icon[e - --w] = b0;
            if (inf.bpp >= 16) icon[e - --w] = b1;
            if (inf.bpp >= 24) icon[e - --w] = b2;
            if (inf.bpp == 32) icon[e - --w] = b3;
            s +=  v;
            e -=  v;
        }
    }
}

void SaveFile(char fname[]) {
    FILE *fout = fopen(fname, "wb");
    fwrite(icon, sizeof(icon), 1, fout);
    fclose(fout);
}

void Choice() {
    printf( "\nPress: 1 to Mirror | 2 to Mirror-Flip | 3 to Flip | 4 to DIB-Flip | 5 to Exit.\n" );
    char r;
    gets(&r);
    switch (r) {
        case '1':
            Mirror();
            SaveFile("Mirror.bmp");
            break;
        case '2':
            /*
            Mirror();
            Flip();
            SaveFile();
            */
            MirrorFlip();
            SaveFile("Mirror-Flip.bmp");
            break;
        case '3':
            Flip();
            SaveFile("Flip.bmp");
            break;
        case '4':
            DIBFlip();
            SaveFile("DIB-Flip.bmp");
            break;
        case '5':
            return;
        default:
            Choice();
    }

    printf("Continue... [y,n]?\n");
    gets(&r);
    switch (r) {
        case 'y':
            Choice();
            break;
        default:
            return;
    }
}

int main() {
    SetInfos();
    if (!inf.isBM) return -1; // O arquivo está danificado ou não é suportado.
    if (inf.Width < 0) return -1; // Tem que ser positivo (mandatório).
    if (inf.isCompressed) return -1; // Não suporta compressão.
    if (inf.bpp == 2) return -1; // Não suporta 2bpp.
    Choice();
    return 0;
}


text:
Q: how to display page's attachment image in wordpress custom widget So I have this custom widget where you can select a page from a drop box and the widget will lead you to this page. The problem is i have no idea how to display the page's attachment image.
wp_get_attachment_image($page, 'full') doesn't work. In the codex there's an example with a loop, but here I need just that one image.
// This is where you run the code and display the output
$page = $instance['selected']; ?>
<a href="<?= get_the_permalink($page); ?>">
<?php wp_get_attachment_image( $page, 'full' ); ?>

<?php echo $title; ?>

<?php echo $instance['content'];  ?>

Read more

<?php
echo $args['after_widget'];

}

A: Okay, I found the solution to my problem
echo get_the_post_thumbnail($page,array(540,260));

redpajama_set_name: RedPajamaStackExchange


text:
Q: Codificar correctamnte una url en Android Java Estoy intentando de codificar correctamente una dirección web, solicitada al usuario mediante un EditText, es decir que los carácteres esten escapados correctamente como especifica aquí, preseverando su estructura y tipo de codificación adecuada en cada segmento.
Los espacios en los directorios representados con ˋ%20ˋ y la entrada de parametros, despues del ˋ?ˋ los espacios sean ˋ+ˋ
Es decir que si el usurio separa parte de la url con espacios se codifiqu correctamnte
Ejemplo:
http://miestanteria.es/mi%20coleccion/libros.php?año=2018&autor=mi+autor+preferido

A: Una forma sería limpiando la cadena por partes, es decir primero lo que esta antes del ? y luego la otra parte:
Ejemplo:
String urlText = "http://miestanteria.es/mi coleccion/libros.php?año=2018&autor=mi autor preferido";
    String urlBase = urlText.split("\\?")[0];
    String urlParameter= urlText.split("\\?")[1];
    String urlLimpia = urlBase.replace(" ","%20")+"?"+urlParameter.replace(" ","+");
    Log.i("*****",urlLimpia);


text:
Q: Create a Customer Community User in Test to Login Connected Application Please help out in any way possible with the below challenge;
We have an application connected to salesforce which is logged in by our customers(accounts) through community users which are created for their accounts.
These community users are created through the class: "site.createExternalUser(user, accountId, password)" when the customer registers himself on the application from the app interface.
However, now we are trying to create some test customer community users to test a few things. I tried using site.createExternalUser but it did not work.
If someone can help me with this, let me know.
OR
Secondly, I am trying to directly create the customer community users through an apex class and the user is created but I do not know how to setup the "PASSWORD" for these users using the code. I mean when I try to login my app, what would be the password to login?
My code to create a new contact+user & then assign them to an account is below and the contact+user are created successfully but I am unable to login the app (most probably because I do not have a password)
public class createUsersv4 {

    public user createPartnerUser(){

        Account a = [select name from Account where Id='0010Q00000DO8b7QAD'];
       // system.debug('Account = ' + a.Name);

        Contact c = New Contact(LastName = 'Test', AccountID = a.id);
        insert c;
       // system.debug('Contact = ' + c.Id);

        Profile p = [SELECT Id FROM Profile WHERE Name = 'Customer Community user' LIMIT 1];

        user u = New User(
            UserName = 'test_' + math.random() + '@test.com',
            FirstName = 'Test-First',
            LastName = 'Test-Last',
            Alias = 'test',
            email = 'test' + math.random() + '@test.com',
            CommunityNickName = string.valueOf(math.random()).substring(0,6),
            ProfileID = p.id,
            TimeZoneSidKey = 'America/New_York',
            LocaleSidKey = 'en_US',
            EmailEncodingKey = 'UTF-8',
            LanguageLocaleKey = 'en_US',
            ContactID = c.Id

            );

        system.debug('User = ' + u.Id);

        insert u;

        return u;

    }

}

A: If you are just hard coding the user's password for testing ONLY you could, after the user is inserted add another line as below:
insert u;
System.setPassword(u.Id, 'yourpasswordhere');
return u;


text:
Q: how do I link to a page elsewhere in the app from a Devise page? My app uses Devise for sign in. I installed it according to the wiki and got it working fine. I recently added a "terms of service" page to my app at "http://127.0.0.1:3000/tos", it routes via a static controller:
match ':action' => 'static#:action'
I've put a link to it in the bottom of my application.html.erb file. I want a link to Terms of Service and Privacy Policy to be at the bottom of each page. But when I go to the users/sign_in page it won't show the link to the TOS page -- instead there's an error (below).
I've removed all the routes in my app except for these (for the purpose of tracking down this issue):
   root :to => 'home#index'
   #devise routes
   devise_for :users, :admins
   #static
   match ':action' => 'static#:action'

The link is specified like so: <%= link_to "Terms of Service", :controller => "static", :action => "tos" %>
The error is:
No route matches {:controller=>"devise/static", :action=>"tos"}
So Devise is sorta getting in the way of my routing to this static
page. How do I specify the route to go to the root of the app instead
of starting with Devise?
Update: in the short term, the answer was to hardcode it:
  <%= link_to "Terms of Service", "/tos" %> -- not an ideal answer though.

A: In addition to generating the views
rails generate devise:views

you need to configure devise to use the scoped views instead of the views from the gem
config.scoped_views = "true"

in the config/initializers/devise.rb file

A: This should work then:
match ':action' => 'static#:action', :as => :static
and your link should be generated with something like:
<%= link_to "Terms of Service", static_path(:action => 'tos') %>

A: I've gotten this error many times. I fix it by adding the route to the devise routing block
like this( in your case )
Update added different routes to try
devise_for :users, admins do
  match '/:action' => 'static#:action'
end

match '/:action' => 'static#:action'

devise_for :users, admins do
      match '/tos' => 'static#tos'
    end

    match ':action' => 'static#:action'

I also leave the route outside the block. Not very DRY, but it works.


text:
Q: Firebase Realtime Database - how to manage database rules using java sdk I would like to set the database rules for my realtime database using the java sdk. I created a FirebaseDatabase object but I wasn't able to find out how to get/set the database rules using it.
val options = FirebaseOptions.builder()
    .setDatabaseUrl("https://my-database.europe-west1.firebasedatabase.app/")
    .setCredentials(GoogleCredentials.fromStream(File("/path/tom/my/key.json").inputStream()))
    .build()
val defaultApp = FirebaseApp.initializeApp(options)

val defaultDatabase = FirebaseDatabase.getInstance(defaultApp);
// and here I would like to fetch the current rules and be able to set the new one

I've found this piece of docs: https://firebase.google.com/docs/database/rest/app-management and tried
println(defaultDatabase.getReference(".settings/rules.json"))

but I got only

com.google.firebase.database.DatabaseException: Invalid Firebase Database path: .settings/rules.json. Firebase Database paths must not contain '.', '#', '$', '[', or ']'

How to do it ?

A: The .settings pseudo-node is not exposed in the Java Admin SDK. If you want to manipulate the rules from your Java code, you'll have to call the REST API from there.


text:
Q: How to check if a file exists in a folder starting with a substring and ending with a substring in Python I wanna wait for a file to donwload, and I want to check on a folder while the file not exists I'll put a time untill the file finish the download. The problem is I wanna check if the file exists starting with a substring variable called 'final_name' and ends with '.csv'. Could someone help me?
    final_name = name.replace(" ", "").replace('(', '').replace(')', '').replace('-', '')\
        .replace('/', '').replace(r"'", '')

    print(final_name)

    time.sleep(5)

    while not os.path.exists(final_name):
        time.sleep(1)

A: You can use this function to check if the file exists. It lists all files in a directory and loops over them and checks if a file starts and ends with the specified strings.
Code:
import os

def path_exists(directory, start, end):
    files = os.listdir(directory)
    for file in files:
        if file.startswith(start) and file.endswith(end):
            return True
    return False

# "./" is the current directory.
print(path_exists("./", final_name, ".csv"))


text:
Q: How to set password expiration in Weblogic 12c SQL Authentication Provider I have an SQL authentication provider in Weblogic 12c, my passwords in the database get automatically change frequently (daily). I have not been able to figure out why this happens or where to disable this frequent changing.
Can someone point me to where this can be changed/disabled.


text:
Q: red black tree insert implementation - what is a sentinel? I got this code from http://web.mit.edu/~emin/www.old/source_code/cpp_trees/index.html
and its constructor for a red black node is
RedBlackTree::RedBlackTree()
{
  nil = new RedBlackTreeNode;
  nil->left = nil->right = nil->parent = nil;
  nil->red = 0;
  nil->key = MIN_INT;
  nil->storedEntry = NULL;

  root = new RedBlackTreeNode;
  root->parent = root->left = root->right = nil;
  root->key = MAX_INT;
  root->red=0;
  root->storedEntry = NULL;
}

What is nil and why is it initialized in the constructor? Can I just declare a nil node in my private data field and initialize it in my insert function?

A: It is basically a place holder.
From the codes README:
/*  A sentinel is used for root and for nil.  These sentinels are
  created when RedBlackTreeCreate is caled.  root->left should always  point to the node which is the root of the tree.  nil points to a node which should always be black but has aribtrary children and   parent and no key or info.  The point of using these sentinels is so that the root and nil nodes do not require special cases in the code */
From wikipedia red-black tree
1.A node is either red or black.
2.The root is black. (This rule is sometimes omitted. Since the root can always be changed from red to black, but not necessarily vice-versa, this rule has little effect on analysis.)
3.All leaves (NIL) are black. (All leaves are same color as the root.)
4.Every red node must have two black child nodes.
5.Every path from a given node to any of its descendant leaves contains the same number of black nodes.

A: a sentinel is an empty node, it's used instead of nullptr,
because it removes the need for special handling of all the
corner-cases, ie last node, first node etc.


text:
Q: CakePHP 3.3: on tests, it asks for error templates I've a plugin with only one controller with only one action:
class AssetsController extends Controller
{
    /**
     * Renders an asset
     * @param string $filename Asset filename
     * @param string $type Asset type (`css` or `js`)
     * @return Cake\Network\Response|null
     */
    public function asset($filename, $type)
    {
        $this->response->type($type);
        $this->response->file(ASSETS . DS . $filename);

        return $this->response;
    }
}

This only sends an asset file.
Now I'm writing a test for an asset file that does not exist.
public function testAssetNoExistingFile()
{
    $this->get('/assets/css/noexistingfile.css');

    $this->assertResponseFailure();
}

But it asks for error template:
1) Assets\Test\TestCase\Controller\AssetsControllerTest::testAssetNoExistingFile
Cake\View\Exception\MissingTemplateException: Template file "Error/error500.ctp" is missing.

The plugin does not have template and there is no app with templates. So I would expect that it uses templates from CakePHP core, but this does not happen. Where am I wrong?

A: There is no Error/error500.ctp template in the core, that's something that the application has to supply.
When testing plugins, you should register a proper test application environment, and provide the necessary templates for it. If you look at how the CakePHP core and plugins do it, they create/register a dummy application in the tests folder where such template files can then be placed.
See also

*

*Setting up CakePHP 3 Plugin testing

*https://github.com/cakephp/cakephp/tree/3.3.3/tests

*https://github.com/cakephp/debug_kit/tree/3.3.3/tests

*https://github.com/cakephp/bake/tree/1.2.8/tests


text:
Q: TV as display that rotates multiple monitors I have multiple monitor setup and I wish to show the screens on a TV one at a time for "X" second intervals before showing the next.  Preferable that I can specify which screens (ie may only be 2 of the 4 screens)
Hoping someone might have suggestions on how I could do this.
Thanks, Shane


text:
Q: Implementing a Forest Data Structure in Java Name of data structure that's tree-like with multiple root nodes
I stumbled upon someone's answer to a question regarding implementing a tree that has > 2 nodes above. I just wanted to get someone's thoughts on using a Forest Data Structure to implement a Family Genealogy Tree that consist of multiple nodes with 0-multiple children. I may use a Forest Tree, however from most representations that I searched up on and found, it looks similar to a disjointed set, but I do not want a parent node to already be pre-destined to have no children.
I hope it makes sense what I am saying.
Any advice or comments you could offer would be much appreciated.

A: I hope I have a clear enough understanding of what your problem is. If I'm off-track let me know, otherwise the following should be of some help to you.
Just to be clear: I will consider all of the below under the context of genealogy.
A tree is simply a branching structure. In genealogy, you could consider the latest child as the root and create a tree that describes the ancestry of this person. Yes, the latest child is the root, not the oldest known ancestor. This is quite counter-intuitive and probably not really what you want anyways.
Now, once you have more complicated family issues, like a man having children with two different women, you'll run into problems with trees. If you have a separate tree for each child, then the father needs to be duplicated to be able to occur in each of these trees. Unpractical to say the least.
As Neil mentioned in his comment above, it is time to switch to a graph model. Most important for this is to clear up a typical confusion: The general populace speaks of something called a "Family genealogy tree", but as a computer scientist you must realize that such a tree is no tree as per the definitions given in computer science (or biology for that matter). We have a very clear and concise mathematical definition of a tree data structure, and a "genealogy tree" does not match it.
Why is that? Simply because in computer science trees, the different branches are not able to grow back together. With families, this is possible. Quite drastically, you could have the case of a father with two childrens, which again spawn an off-spring. Moral implications aside, this results in a diamond-like view, which is not representable in a tree.
Enter the world of graphs: A graph is just a generic term of things that are connected to each other. Hence, every computer science tree is also a graph. A very special and restricted one of course. In a graph, there is no root anymore, but there are nodes with similar properties (called sources). There are also no leaves anymore, but again nodes with similar properties (called sinks).
In terms of genealogy you can limit the result graph by making it a DAG, a directed acyclic graph. It is directed, because between two nodes, you can declare one as the parent side, one as the child side. For example, you could always point from parent to child (that's one direction, the other is feasible too). If you want to be able to traverse this structure in both directions, you may even consider an undirected variant.
Acyclicity simply means, that there are no circles in your data structure. It is pretty clear that this applies to genealogy (unless you want to count in time traveling and the implied option of becoming your own father or mother). In a DAG, you can have any number of nodes and connections between them. You can however add arbitrary limitations. For example, if all connections go from parent to child, then each child node could be restricted to have a maximum fan-in of 2. That's just graph theory lingo for saying that a person cannot have more than two parents.
Hence, I suggest to take a close look at directed acyclic graphs and the underlying graph theory in general. Also note that it'll pay off. If you want to do software development you should know about graphs. They are one of the most general data structures and apply to almost everything. They are not always the best choice of course, but they will be one of the most powerful things in your arsenal.

A: These posts are old, but here is my input anyway.
First of, I think the solution is much simpler than using graphs.
I would implement a class, let us call it Node, which has person name and other attributes that you may like to keep for each person in the family.  Then we need another attribute to add it to class Node, which is an array of (references) of the same type (Node).  These are the children of a particular parent. At first they all will be set to null, then you can instantiate any number of children based on what you have and link them to this particular parent. For example, the class may start like this:
class Node
{
    private string name;  // person name
    private int data; // any data about the person i.e number of teeth :)
    private Node [] children;  // reference to array of children
    public void Node() // constructor
    {
        // here put code to instantiate the array, for example
    }
    // other methods, for example setters and getters
}

This way the oldest known grandfather will be in the root Node.  each Node has number of children based on the real case, which are references to objects of the same type etc...  You will probably need to write some methods for traversing the forest, in order to be able to print it, or search for particular person, etc.  You may look at data structures books in java or C# to learn more about implementing linked-based trees in general. I hope this is useful for any one need to implement a forest using object-oriented paradigm.


text:
Q: no matching function for call to 'lower_bound' with newer gcc I'm having some trouble compiling code that uses std::lower_bound on systems with newer versions of gcc. From my tests, 4.1 works, but 4.6 fails.
Here is the relevant code snippet:
template <typename RandomAccessIterator, typename Value, typename Comparer>
int my_binary_search(RandomAccessIterator const  first, RandomAccessIterator const  last, Value const& value, Comparer comparer)
{
    RandomAccessIterator it(std::lower_bound(first, last, value, comparer));
    //some more code below
}

The error I am seeing is:
error: no matching function for call to 'lower_bound(const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&, const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&, const int&, bool (*&)(int, int))'
testing.h:37:75: note: candidate is:
/usr/include/c++/4.6/bits/stl_algobase.h:936:5: note: template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)

Does anybody have ideas on how to fix this?

A: For anyone finding this on google:
I had the same issue
Includes were "functional" and "list", didnt give me any error lower_bound wasnt defined or anything, just that it couldnt find a matching function.
Including "algorithm" did the trick.. nearly an hour of searching around for such a stupid thing


text:
Q: Django: Accessing full User information via ManyToMany field everyone- I'm new to Django and working on my first big project and I'm having trouble with accessing default Django User model information via a ManyToMany relationship.  I've spent a great deal of time searching and can't crack it.
models.py
class Event(models.Model):
  event_name = models.CharField(max_length=200, null=True, unique=True)
  #etc...

class School(models.Model):
  user = models.ManyToManyField(User)
  event = models.ForeignKey(Event, null=True, on_delete=models.PROTECT)
  #etc...

My url contains the id  of the Event, so...
views.py
def schools(request, pk):
   event = Event.objects.get(id=pk)
   school = School.objects.filter(event=event)
   return render(request, 'accounts/schools.html', {'event':event, 'school':school})

template
{% for school in school %}

      {{school.name}}
      {{school.user.all}}
{% endfor %}

On my template, I'm able to use {{school.user.all}} to get me a Queryset displayed with the username of each User, but I want the first_name and last_name and can't see to figure out how to get that..
Thank you for any suggestions.  I greatly appreciate your time!

A: You should include both schools and users to your context.
You can do this with a dictionary. Add each school as a key, and users of each school as its values. Then you can pass this dictionary to your template.
View function:
def schools(request):
    school_dict = dict()
    schools = School.objects.all()
    for school in schools:
        school_dict[school] = school.user.all()
    return render(request, 'accounts/schools.html', {'schools': school_dict})

And in your template:
{% for school, users in schools.items %}

{{ school.title }}

    {% for user in users %}

        {{ user.first_name }}
        {{ user.last_name }}

    {% endfor %}

{% endfor %}

A: I was able to add this to my school model to get what I wanted:
    def director(self):
        test = ",".join([str(p) for p in self.user.all()])
        user = User.objects.get(username=test)
        return user.first_name + " " + user.last_name

HOWEVER: if there is more than one user associated with "School" it displays blank


text:
Q: custom ADO.NET data provider with NHibernate I am writing an application that connect to ESRI's File Geodatabase, which is a proprietary database.
I found a custom ADO.NET data provider for this File Geodatabase.
I like to access this database with NHibernate.
Can I use this ADO.NET data provider with NHibernate without writing any customization code for NHibernate?
is there a driver that deal with generic ado.net provider?
so far what I found, they told me to implement IDriver, and IDialect in order to acheive that.
And in case I have to write my own implementation, is there any document that describe how to do that?

A: There is a GenericDialect (not quite full-featured, as few things are less standard than SQL), but you need to implement a driver so NH can connect to the db.
You can take any of the simpler drivers in https://github.com/nhibernate/nhibernate-core/tree/master/src/NHibernate/Driver as a starting point.


text:
Q: How to get the name of child class from base class when an object of child class is created I want to get the name of my child class in the base class so that whenever an object of child class is created I get the name of the child class in my base class. Something like this:
class Base_class {
    function __construct() {
        // Some code Here to get the name of the child class
    }
}

class Child_class extends Base_Class {}

class Another_child_class extends Base_Class {}

$object = new Child_Class;
$object2 = new Another_child_class;

When the $object is created I want the constructor to give me the name of the class from which the object was created.

A: This is certainly possible using static::class (or get_class($this) or get_called_class()) in the base class to get the name of the child (which is initially called at runtime):
<?php

class Foo
{

    public function __construct()
    {
        var_dump(static::class, get_class($this), get_called_class());
    }

}

class Bar extends Foo { }

class Baz extends Bar { }

new Foo();
new Bar();
new Baz();

Produces:
string(3) "Foo"
string(3) "Foo"
string(3) "Foo"
string(3) "Bar"
string(3) "Bar"
string(3) "Bar"
string(3) "Baz"
string(3) "Baz"
string(3) "Baz"

This is called late static binding. Here's a demo of the above.

A: You can use get_class() passing it the current object reference, like so:
class Base_class {

    function __construct() {
        $calledClassName = get_class($this);
    }

}

Edit: You can find more info on get_class() in the PHP manual http://php.net/manual/en/function.get-class.php

A: Yes, to an extent. In PHP 5.5, the ::class class constant was added, which returns the class name of class to which it is applied. You can then use this in conjunction with parent, self, or static. Consider this code:
<?php

class A {}

class B extends A
{
    public function foo() {
        echo parent::class . "\n";    // A
        echo __CLASS__ . "\n";        // B
        echo self::class . "\n";      // B
        echo static::class . "\n";    // D
        echo get_class($this) . "\n"; // D
    }
}

class C extends B {}
class D extends C {}

(new D)->foo();

self::class will return the same thing as __CLASS__, the class belonging to the function currently executing (in this case, B).
parent::class will return the name of the method's parent class (A).
static::class, by way of Late Static Binding, will return the class name of the method that was actually invoked (D).
Note, however, that you can not get the immediate child descendent of your current function (C) without using more advanced means (parsing the call stack via debug_backtrace, or via reflection).

A: Well, just pass it explicitly then:
class BaseClass{

  function __construct($tableName){
    // do stuff w/ $tableName
  }

}

class ChildClass extends BaseClass{

  function __construct(){
    parent::__construct('ChildClass');
  }

}


text:
Q: Microsoft Access 2003 Shared DBF, file is already in use Friend I am using MS Access 2003
I want to share MDB file on the network for this I put it in the shared folders with options shared database, and define user rights read only. because i just want to give them view only.
What I did I made another file & through link the tables from the shared database lying on the network.
Problem:
If file is open in any pc so other user is not accessing he is getting message file is already in use. While file is in shared mode.
Please help me out.

A: Move the "Front End" to each users' pc, and link to the "Back End" on the shared folder/drive so each user has their own copy of the front end to view the data.

A: If the user has read only rights on the folder which contains the back-end MDB/ACCDB, the first user in will lock the database, because the .ldb (lock file) needs to be updated. I usually give the user full permissions on the folder, but others say delete permissions are not necessary, because even though the .ldb file is normally deleted by Access when the last user leaves, it is not essential that this should happen.

A: Quoting Remou, David W. Fenton and Tony Toews:
As regards the folder on the server where the MDB/ACCDB containing the tables resides, you need to have appropriate permissions on both the SHARE and on the underlying folder that the share is making available across the LAN.
If the user has read only rights on the folder, the first user in will lock the database, because the .ldb (lock file) needs to be updated. I usually give the user full permissions on the folder, but others say delete permissions are not necessary, because even though the .ldb file is normally deleted by Access when the last user leaves, it is not essential that this should happen.


text:
Q: "Continued on next page" at page break with xsl I have a html document that a user needs to print by using File -> Menu -> Print. When I look at the document using "Print Preview", it shows 6 pages. Now I want to display a message (i.e. "Section continued to next page") at the bottom of the page, when a page break occurs. I tried lots of option but didn't get the desired result. Does any body know the solution for this problem?

A: This has little to do with XSLT, more with HTML/CSS.
If you want to have a footer on every page, see here. You can have your XSLT add a DIV with position:fixed.
The difficult part is to have it appear on every but the last page. A quick hack that might work (not tested) is to have another DIV with position:absolute and bottom: 0 that has a higher z-index and hides the footer.

A: I don't believe you can use XSL-FO with the browser natively (as flyx mentioned). You could implement this server-side through a button on your page, but intervening in the browser implementation of File > Print will not be possible for security reasons.
If you do choose the server-side way, you can use XSL-FO, but I'm not familiar enough with it to help you there.


text:
Q: Spark Job Speed Relational To SQL Server Size My setup:

*

*I have a MS SQL server running Azure (V12)

*I have a Spark cluster running in Azure HDInsights

*Spark.Version: 1.6.2

*Scala.Version:2.10.5

I am pulling in my data (about 5 million rows) from SQL server, via the jdbc driver, and then updating the column names. Then I perform my logic.
Here is how I read from the server:
println("SQL Load Start: " + TimeStamp.getCurrentTime.toDateString)
val options: Map[String, String] = Map("url" -> connectionString,
    "dbtable" -> ("(SELECT * FROM Data)" + "Data"))
val data = sQLContext.read.format("jdbc").options(options).load()
println("DF Count: " + data.count().toString)
println("Partition Count: " + data.rdd.partitions.length.toString)
println("SQL Load End: " + TimeStamp.getCurrentTime.toDateString)

When I scale the SQL server up, my data is read in quickly and my logic runs in about 10 seconds.
When the SQL server is small, my data is read in at a slower pace (expected), but my logic also takes much longer (UNEXPECTED) taking about 3 - 4 minutes.
The cluster size is not changing.
The number of partitions in the DataFrame does not appear to change. I am only changing the size of the SQL server.
Does anyone have any ideas on why the logic portion of my Spark job would fluctuate based on the size of my SQL server?

A: I figured this out. One of my teammates reminded me about something I learned in training. If you don't cache the data after retrieving it from MS SQL, it will go and retrieve the data again when you work on it.
The updated could looks like the following:
println("SQL Load Start: " + TimeStamp.getCurrentTime.toDateString)
val options: Map[String, String] = Map("url" -> connectionString,
    "dbtable" -> ("(SELECT * FROM Data)" + "Data"))
val data = sQLContext.read.format("jdbc").options(options).load()

data.cache()   // NEW CODE

println("DF Count: " + data.count().toString)
println("Partition Count: " + data.rdd.partitions.length.toString)
println("SQL Load End: " + TimeStamp.getCurrentTime.toDateString)


text:
Q: Plot solution of partial integro-differentiatial equation I would like to plot solution to a differential equation using ParametricNDSolve3D. The indepedent variable f has arguments q and t where q represents angle between 0 and 2pi while t represents time. So, I would like to plot the solution on a circle and watch it evolve in time possibly using Manipulate function. But I am not able to do it. I keep getting error while plotting for reasons that are not clear to me.

A: Rewrite your code slightly as
sol = Flatten@NDSolve[{D[f[q, t], t] == -f[q, t] + Max[0, a f[q, t] +
   c D[f[q, t], q, q] - b Integrate[f[q, t], {q, 0, 2 Pi}] + 1], f[q, 0] == Cos[q] + 1,
   f[2 Pi, t] == f[0, t]}, f, {t, 0, 2}, {q, 0, 2 Pi}]
ParametricPlot3D[{f[q, 1] /. sol, Cos[q], Sin[q]}, {q, 0, 2 Pi}, ImageSize -> Large]

to add a periodic boundary condition in q and to eliminate a pair of curly brackets in sol.


text:
Q: Passing a variable from one Controller Action to another I would like to pass a variable from one Controller Action to another and display the value on the view script.
class ImportController extends Zend_Controller_Action
    {
        public function ImportrecordsAction()
        {
            //Do some processing and in this case I select
            //23 to be the value of total records imported;
            &totalcount = 23;
            //On success go to success page;
            $this->_redirect('/import/success');
        }

        public function SuccessAction()
        {
            //Display the value at the resulting view
            $this->view->count = &totalcount;
        }

    }

However the &totalcount is returning no value meaning that the variable is not passed to the next action.
How can I solve this?

A: Instead of a redirect you may want to use a forward. This allows you to forward to another action within your application without doing a complete redirect.
class ImportController extends Zend_Controller_Action
{
    public function ImportrecordsAction()
    {
        //Do some processing and in this case I select
        //23 to be the value of total records imported;
        $totalcount = 23;
        //On success go to success page;
        $this->_forward('success','import','default',array('totalcount'=>$totalcount));
    }

    public function SuccessAction()
    {
        $this->view->count = $this->_request->getParam('totalcount',0);
    }

}

Take a look at http://framework.zend.com/manual/en/zend.controller.action.html for more details.

A: You could do it this way:
class ImportController extends Zend_Controller_Action
    {
        public function ImportrecordsAction()
        {
            $session = new Zend_Session_Namespace('session');

            //Do some processing and in this case I select
            //23 to be the value of total records imported;
            $session->totalcount = 23;
            //On success go to success page;
            $this->_redirect('/import/success');
        }

        public function SuccessAction()
        {
            $session = new Zend_Session_Namespace('session');

            //Display the value at the resulting view
            $this->view->count = $session->totalcount;
        }

    }

You can use that value anywhere in your web app now.

A: You could pass it as an additional action parameter, and grab it using $this->_getParam('count');:
class ImportController extends Zend_Controller_Action
    {
        public function ImportrecordsAction()
        {
            //Do some processing and in this case I select
            //23 to be the value of total records imported;
            &totalcount = 23;
            //On success go to success page;
            $this->_redirect('/import/success/count/' + &$totalCount);
        }

        public function SuccessAction()
        {
            //Display the value at the resulting view
            $this->view->count = $this->_getParam('count');
        }


text:
Q: Retrieving the instance of a variable on which a data frame was split in R To iterate over different splits of a data frame, I am trying to retrieve the category  on which it was split. Consider this basic set:
value <- c(1, 2, 3, 4, 5, 6)
year <- c(2010, 2011, 2012, 2010, 2011, 2012)
category <- c(X, X, X, Y, Y, Y)

Data <- data.frame(Value = value, Year = year, Category = category)

To find separate trends throughout years in terms of Value for each category, I split the set as follows:
Split_data <- split(Data, f = Category)

Then, I want to iterate over the set using a for-loop:
for (i in 1:length(Split_data){
   print(Split_data[i])
}

However, now I want to create a new data frame, in which I want to add the category from the specific split of the data frame.
for (i in 1:length(Split_data)){
  model <- lm(Value ~ year, data = Split_data[i])
  prediction <- data.frame(year = prediction_years, Value = rep(0, length(jaar)))
  prediction$Value <- predict(model, prediction)
  prediction$Category <- ????
  data <- rbind(data, prediction)
}

I know I can access it through Split_data$X$Category[1], but how do I do this during iteration?
I can access Splits of the set through Split_data[x], but Split_data[i]$Category returns NULL, Split_data[i][1] still returns a frame and I have no idea to do it differently.
I have tried retrieving the value from the list of columns in the original set, but the order in which the splits are organized in the split data frame seems to be random...

A: #object type
class(Split_data)
[1] "list"

#first list
Split_data[[1]]
#  Value Year Category
#1     1 2010        X
#2     2 2011        X
#3     3 2012        X

#first list and first column
Split_data[[1]][,1]
#[1] 1 2 3

#first list and first line
Split_data[[1]][1,]
#  Value Year Category
#1     1 2010        X

#first list, first line and first column
Split_data[[1]][1,1]
#[1] 1


text:
Q: Java String remove all non numeric characters but keep the decimal separator Trying to remove all letters and characters that are not 0-9 and a period.  I'm using Character.isDigit() but it also removes decimal, how can I also keep the decimal?

A: Solution
With dash
String phoneNumberstr = "Tel: 00971-557890-999";
String numberRefined = phoneNumberstr.replaceAll("[^\\d-]", "");

Result: 0097-557890-999.
Without dash
If you also do not need "-" in String you can do like this:
String phoneNumberstr = "Tel: 00971-55 7890 999";
String numberRefined = phoneNumberstr.replaceAll("[^0-9]", "");

Result: 0097557890999.

A: Try this code:
String str = "a12.334tyz.78x";
str = str.replaceAll("[^\\d.]", "");

Now str will contain "12.334.78".

A: Currency decimal separator can be different from Locale to another. It could be dangerous to consider . as separator always.
i.e.
╔════════════════╦═══════════════════╗
║    Locale      ║      Sample       ║
╠════════════════╬═══════════════════╣
║ USA            ║ $1,222,333.44 USD ║
║ United Kingdom ║ £1.222.333,44 GBP ║
║ European       ║ €1.333.333,44 EUR ║
╚════════════════╩═══════════════════╝

I think the proper way is:

*

*Get decimal character via DecimalFormatSymbols by default Locale or
specified one.

*Cook regex pattern with decimal character in order to obtain digits only

And here how I am solving it:
code:
import java.text.DecimalFormatSymbols;
import java.util.Locale;

    public static String getDigit(String quote, Locale locale) {
    char decimalSeparator;
    if (locale == null) {
        decimalSeparator = new DecimalFormatSymbols().getDecimalSeparator();
    } else {
        decimalSeparator = new DecimalFormatSymbols(locale).getDecimalSeparator();
    }

    String regex = "[^0-9" + decimalSeparator + "]";
    String valueOnlyDigit = quote.replaceAll(regex, "");
    try {
        return valueOnlyDigit;
    } catch (ArithmeticException | NumberFormatException e) {
        Log.e(TAG, "Error in getMoneyAsDecimal", e);
        return null;
    }
    return null;
}

I hope that may help,'.

A: For the Android folks coming here for Kotlin
val dirtyString = " Account Balance: $-12,345.67"
val cleanString = dirtyString.replace("[^\\d.]".toRegex(), "")

Output:
cleanString = "12345.67"

This could then be safely converted toDouble(), toFloat() or toInt() if needed

A: A way to replace it with a java 8 stream:
public static void main(String[] args) throws IOException
{
    String test = "ab19198zxncvl1308j10923.";
    StringBuilder result = new StringBuilder();

    test.chars().mapToObj( i-> (char)i ).filter( c -> Character.isDigit(c) || c == '.' ).forEach( c -> result.append(c) );

    System.out.println( result ); //returns 19198.130810923.
}

A: With guava:
String input = "abx123.5";
String result = CharMatcher.inRange('0', '9').or(CharMatcher.is('.')).retainFrom(input);

see http://code.google.com/p/guava-libraries/wiki/StringsExplained

A: str = str.replaceAll("\\D+","");

A: I would use a regex.
String text = "-jaskdh2367sd.27askjdfh23";
String digits = text.replaceAll("[^0-9.]", "");
System.out.println(digits);

prints
2367.2723

You might like to keep - as well for negative numbers.

A: Simple way without using Regex:
Adding an extra character check for dot '.' will solve the requirement:
public static String getOnlyNumerics(String str) {
    if (str == null) {
        return null;
    }
    StringBuffer strBuff = new StringBuffer();
    char c;
    for (int i = 0; i < str.length() ; i++) {
        c = str.charAt(i);
        if (Character.isDigit(c) || c == '.') {
            strBuff.append(c);
        }
    }
    return strBuff.toString();
}

A: This handles null inputs, negative numbers and decimals (you need to include the Apache Commons Lang library, version 3.8 or higher, in your project):
import org.apache.commons.lang3.RegExUtils;
result = RegExUtils.removeAll(input, "-?[^\\d.]");

Library reference: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/RegExUtils.html

A: The below code should remove all non-digit characters and allow periods.
String newString = currentString.replaceAll("[\\D.]", "");


text:
Q: How to redirect an output to wc by pipeline? count=`cat "Main Dir/$param/sent.txt"|sort -k2|tail -n-$LAST_SENT_EMAILS_TO_CONSIDER|cut -f1 -d" " -d"  "|cut -f2 -d"@"|cut -f1 -d"."|wc -w $domain`

Until the wc, I take "LAST_SENT_EMAILS_TO_CONSIDER" strokes from sent.txt sorted by some parameter that I took.
Now, I want to count how much the content of domain ($domain) repeat in the cut strokes.
I did see similar questions and answers, which say that by reorganizing that command line in other way, it could work.
Can somebody help me with this concrete example?

A: Without knowing the input, I can't test my solution. But if I understand you correctly, you just want to do
... | grep -F "$domain" | wc -l

i.e. count how many times $domain appears in the output. -F is used to prevent interpreting of special characters (e.g. . normally matches anything, but if your domain is example.com, you don't want to match exampleXcom).
BTW, grep can count the line itself, so you can shorten it to
... | grep -Fc "$domain"

A: Apology, my mistake, wc doesn't count <"expressions">, but only words, strokes or chars.
Yes, as choroba said, that's what I wanted to do, and I can use for it only:
...|grep -c "$domain"


text:
Q: How to take the Laplace transform of floor(t) So I am trying to take the Laplace transform of $\text{floor}(t)$, and I am stuck.
First of all $\text{floor}(t)$ is defined to be the highest integer $<=t$
With that in mind, here is what I tried to do:
$$f(t)=\text{floor}(t)$$
$$f(t)=u(t-1)+u(t-2)+u(t-3)+...$$
Where $~u(t)~$ is the unit step function.
By using the definition of the Laplace transform:
$$ \mathcal{L}{f}=\int_0^\infty e^{-st}\sum_{i=1}^\infty u(t-i)dt $$
$$ \mathcal{L}{f}= \int_1^2e^{-st}1dt + \int_2^3 e^{-st}2dt + \int_3^4 e^{-st}3dt  + ... $$
$$ \mathcal{L}{f} = \sum_{i=1}^{\infty} n\int_n ^{n+1}e^{-st} dt$$
$$ \mathcal{L}{f} = \frac{1}{s}(1-e^{-s}) \sum_{i=1}^{\infty} ne^{-sn}  $$
Since I don't know how to compute this infinite series I don't know how to go forward from here. If anyone can help me with that it would be much appreciated. Also if there is a "better" way to solve this or I am doing something wrong, which is likely, I would appreciate if you point it out:)

A: Consider the sum:
$\begin{align*}
   S(s)
     &= \sum_{n \ge 0} e^{-n s} \\
     &= \frac{1}{1 - e^{-s}}
\end{align*}$
So your mystery sum is just:
$\begin{align*}
   -S'(s)
      &= \sum_{n \ge 0} n e^{- n s} \\
      &= \frac{e^s}{(1 - e^s)^2}
\end{align*}$
The frobbing is valid as long as $e^{-s} < 1$, i.e., $s > 0$.

A: I think I would add to vonbrand answer
$\begin{align*}
   S(s)
     &= \sum_{n \ge 0} e^{-n s} \\
     &= \frac{1}{1 - e^{-s}}
\end{align*}$
How does he get that?
Let's start with
$$   S(s) = \sum_{n \ge 0} e^{-n s} $$
That's how we define it.
Let's multiply both side by $e^{- s}$
$$  e^{- s} S(s) =e^{- s} \sum_{n \ge 0} e^{-n s} $$
$$= \sum_{n \ge 0} e^{-(n+1) s} $$
$$= \sum_{n \ge 1} e^{-n s} $$
Notice that multiplying with $e^{- s}$ we still have the same sum but losing it's first term. Hence,
$$  (1-e^{- s}) S(s)= \sum_{n \ge 0} e^{-n s}- \sum_{n \ge 1} e^{-n s} = e^{-0 s}=1 $$
Dividing both sides with  $(1-e^{- s})$  we got
$$   S(s) = \sum_{n \ge 0} e^{-n s} =\frac{1}{1-e^{-s}}$$