Print images upscaled

This commit is contained in:
fruchti 2018-08-23 13:39:45 +02:00
parent 3c84665f50
commit 0774ed43f5
5 changed files with 20 additions and 12 deletions

View file

@ -1 +1 @@
464 472

View file

@ -26,7 +26,7 @@ int main(void)
while(!Camera_Captured); while(!Camera_Captured);
extern uint8_t ImageBuffer[CAMERA_IMAGE_WIDTH * CAMERA_IMAGE_HEIGHT / 8]; 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(;;) for(;;)
{ {

View file

@ -3,7 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "stm32f1xx.h" #include "stm32f1xx.h"
#define CAMERA_IMAGE_WIDTH 176 #define CAMERA_IMAGE_WIDTH 160
#define CAMERA_IMAGE_HEIGHT 144 #define CAMERA_IMAGE_HEIGHT 144
extern volatile int Camera_Captured; extern volatile int Camera_Captured;

View file

@ -39,27 +39,35 @@ void Print_Text(const char *text, const Font_t *font)
} }
// Width needs to be divisible by 8 // 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; int currentline = 0;
while(height) while(height)
{ {
int lines = PRINT_BUFFER_LINES; int lines = PRINT_BUFFER_LINES / scale;
if(height < lines) if(height < lines)
{ {
lines = height; 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, for(int j = 0; j < width * scale; j++)
data + currentline * width / 8, {
width / 8); int black = data[(currentline / scale * width + j / scale) / 8]
memset(Print_Buffer + width / 8, 0, LTP1245_LINE_BYTES - width / 8); & (0x80 >> ((j / scale) % 8));
if(black)
{
Print_Buffer[i * LTP1245_LINE_BYTES + j / 8] |=
(0x80 >> (j % 8));
}
}
currentline++; currentline++;
} }
LTP1245_Print(Print_Buffer, lines); LTP1245_Print(Print_Buffer, lines * scale);
height -= lines; height -= lines;
} }

View file

@ -8,4 +8,4 @@
#define PRINT_BUFFER_LINES 64 #define PRINT_BUFFER_LINES 64
void Print_Text(const char *text, const Font_t *font); 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);