Print images upscaled
This commit is contained in:
parent
3c84665f50
commit
0774ed43f5
|
@ -1 +1 @@
|
|||
464
|
||||
472
|
||||
|
|
|
@ -26,7 +26,7 @@ int main(void)
|
|||
while(!Camera_Captured);
|
||||
|
||||
extern uint8_t ImageBuffer[CAMERA_IMAGE_WIDTH * CAMERA_IMAGE_HEIGHT / 8];
|
||||
Print_Image(ImageBuffer, CAMERA_IMAGE_WIDTH, CAMERA_IMAGE_HEIGHT);
|
||||
Print_Image(ImageBuffer, CAMERA_IMAGE_WIDTH, CAMERA_IMAGE_HEIGHT, 2);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <stdlib.h>
|
||||
#include "stm32f1xx.h"
|
||||
|
||||
#define CAMERA_IMAGE_WIDTH 176
|
||||
#define CAMERA_IMAGE_WIDTH 160
|
||||
#define CAMERA_IMAGE_HEIGHT 144
|
||||
|
||||
extern volatile int Camera_Captured;
|
||||
|
|
24
src/print.c
24
src/print.c
|
@ -39,27 +39,35 @@ void Print_Text(const char *text, const Font_t *font)
|
|||
}
|
||||
|
||||
// Width needs to be divisible by 8
|
||||
void Print_Image(const uint8_t *data, int width, int height)
|
||||
void Print_Image(const uint8_t *data, int width, int height, int scale)
|
||||
{
|
||||
int currentline = 0;
|
||||
while(height)
|
||||
{
|
||||
int lines = PRINT_BUFFER_LINES;
|
||||
int lines = PRINT_BUFFER_LINES / scale;
|
||||
if(height < lines)
|
||||
{
|
||||
lines = height;
|
||||
}
|
||||
|
||||
for(int i = 0; i < lines; i++)
|
||||
memset(Print_Buffer, 0, sizeof(Print_Buffer));
|
||||
|
||||
for(int i = 0; i < lines * scale; i++)
|
||||
{
|
||||
memcpy(Print_Buffer + i * LTP1245_LINE_BYTES,
|
||||
data + currentline * width / 8,
|
||||
width / 8);
|
||||
memset(Print_Buffer + width / 8, 0, LTP1245_LINE_BYTES - width / 8);
|
||||
for(int j = 0; j < width * scale; j++)
|
||||
{
|
||||
int black = data[(currentline / scale * width + j / scale) / 8]
|
||||
& (0x80 >> ((j / scale) % 8));
|
||||
if(black)
|
||||
{
|
||||
Print_Buffer[i * LTP1245_LINE_BYTES + j / 8] |=
|
||||
(0x80 >> (j % 8));
|
||||
}
|
||||
}
|
||||
currentline++;
|
||||
}
|
||||
|
||||
LTP1245_Print(Print_Buffer, lines);
|
||||
LTP1245_Print(Print_Buffer, lines * scale);
|
||||
|
||||
height -= lines;
|
||||
}
|
||||
|
|
|
@ -8,4 +8,4 @@
|
|||
#define PRINT_BUFFER_LINES 64
|
||||
|
||||
void Print_Text(const char *text, const Font_t *font);
|
||||
void Print_Image(const uint8_t *data, int width, int height);
|
||||
void Print_Image(const uint8_t *data, int width, int height, int scale);
|
Loading…
Reference in a new issue