summaryrefslogtreecommitdiffstats
path: root/friendfinder/barcode.c
blob: 21915db9bb8771db3923c427df1b36a833291366 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "qrencode.h"
#include "Imlib2.h"
#include "barcode.h"
#include "Evas.h"
#include "Ecore.h"
#include "Ecore_Evas.h"

void write_img(QRcode *code)
{
	Ecore_Evas *ee;
	Evas_Object *pic;
	Evas *e;
	

	ee = ecore_evas_buffer_new(1, 1);
   	e = ecore_evas_get(ee);
   	
	if (!e)
     	{
        	fputs("ERROR: could not create ecore evas buffer\n", stderr);
        	return;
     	}
 
	evas_image_cache_set(e, 0);
   	evas_font_cache_set(e, 0);

	pic =  evas_object_image_add(e);
	evas_object_image_file_set(pic, "barcode.png", NULL);

	evas_object_image_size_set(pic, code->width, code->width);
	//evas_object_image_alpha_set(pic, 0); 	
	evas_object_image_data_set(pic, code->data);
	evas_object_image_data_convert(pic, EVAS_COLORSPACE_ARGB8888);
	evas_object_image_save(pic, "barcode.png", NULL, "quality=100 compress=9");
//	return pic;
}

void generate_barcode(char* key)
{
	QRcode *code;

	code = QRcode_encodeString8bit(key, 0, QR_ECLEVEL_M);//, QR_MODE_8, 1); 	

	write_img(code);

	QRcode_free(code);
/*
	Evas_Object *pic;
	size_t width, height, bytesPerPixel;
	unsigned char  *pxl;
	DmtxEncode     *enc;

	enc = dmtxEncodeCreate();
	if (enc != NULL);
   		dmtxEncodeDataMatrix(enc, strlen(key), key);

	width = dmtxImageGetProp(enc->image, DmtxPropWidth);
   	height = dmtxImageGetProp(enc->image, DmtxPropHeight);
   	bytesPerPixel = dmtxImageGetProp(enc->image, DmtxPropBytesPerPixel);

   	pxl = (unsigned char *)malloc(width * height * bytesPerPixel);
	
	if(pxl != NULL);
   		memcpy(pxl, enc->image->pxl, width * height * bytesPerPixel);

	dmtxImageSetProp(enc->image, DmtxPropImageFlip, DmtxFlipNone);
	
	write_img(enc, win);
	
	if (pic != NULL)	
		printf("barcode created...\n");	*/

//	return pic;
}