First public contribution.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
25 #define LOG_FILE "c:\\logs\\examples_jpeg_log1.txt"
26 #include "std_log_result.h"
27 #define LOG_FILENAME_LINE __FILE__, __LINE__
29 void create_xml(int result)
34 testResultXml("examples_jpeg");
40 void *getfile (char *path, int *n_bytes);
41 static void dump_pgm (unsigned char *ptr, int rowstride, int width, int height);
45 main (int argc, char *argv[])
50 char *fn = "c:\\data\\liboil\\test.jpg";
57 printf("jpeg_test <file.jpg>\n");
63 std_log(LOG_FILENAME_LINE, "Test Started examples_jpeg");
64 dec = jpeg_decoder_new (); //to create decoder instance
66 data = getfile (fn, &len);
68 jpeg_decoder_addbits (dec, data, len);
69 jpeg_decoder_decode (dec);
71 jpeg_decoder_get_component_ptr (dec, 1, &ptr, &rowstride);
72 jpeg_decoder_get_component_size (dec, 1, &width, &height);
74 dump_pgm (ptr, rowstride, width, height);
76 std_log(LOG_FILENAME_LINE, "Test Successful");
85 getfile (char *path, int *n_bytes)
92 fd = open (path, O_RDONLY);
96 ret = fstat (fd, &st);
102 ptr = malloc (st.st_size);
108 ret = read (fd, ptr, st.st_size);
109 if (ret != st.st_size) {
116 *n_bytes = st.st_size;
123 dump_pgm (unsigned char *ptr, int rowstride, int width, int height)
128 printf ("%d %d\n", width, height);
131 for (y = 0; y < height; y++) {
132 for (x = 0; x < width; x++) {
133 printf ("%d ", ptr[x]);
134 if ((x & 15) == 15) {