2
I’d like to know how to mirror an image. I got an algorithm, but it only reverses images with 60x60 resolution and bpp=1.
I have the following image model to test:
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, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF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
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,
};
Anyone have any idea where I should make a better fit on this algorithm? Suppose we have an image 10x10 pixels, with bpp=1. Would the line size be 10 bits? Do I have to invert these bits per line to get the desired result? Does anyone know how to do this?
Here’s the algorithm I have:
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);
}
I don’t know what you understand as pure C, but at least some graphical library you will have to use.
– anonimo
C pure, not C++. C low level. What I want is to print image on a thermal printer. The image is coming out backwards and upside down. I need an algorithm to adjust the image.
– Bianca Nunes
Important [Dit] posting what tried and making clear the difficulty found. Ready codes, tutorials and questions that depend on various different knowledge applied usually do not fit well in the site scope in a single question. If you have doubt in specific parts, you can post a [mcve] of the current problem step, and by solving, you can open separate questions about the next steps, each focused on a specific problem.
– Bacco
@Bacco I put more information regarding my doubt.
– Bianca Nunes
You may find a C++ algorithm that you can compile to perform the inversion. The Opencv is an open computer vision library and has very efficient implementations for this type of operation.
– Pedro Henrique Monforte