Re: [AD] [ alleg-Bugs-2121233 ] JPEG loader

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2008-09-22, Elias Pschernig <elias.pschernig@xxxxxxxxxx> wrote:
> On Mon, 2008-09-22 at 14:18 +0000, SourceForge.net wrote:
> > 
> > Message:
> > I have a libjpeg addon for A4, will try adding that.
> > 
> 
> Attached (scons build only so far). Saving is implemented but completely
> untested, so likely needs some fixes before it works.

Great!

> Index: addons/iio/jpg.c
> ===================================================================
> --- addons/iio/jpg.c	(revision 0)
> +++ addons/iio/jpg.c	(revision 0)
> @@ -0,0 +1,280 @@
> +/* loadpng, Allegro wrapper routines for libpng
> + * by Peter Wang (tjaden@xxxxxxxxxx).
> + */
> +

Of course, you want to fix that.

The code looks good.  Please reindent to 3 spaces before committing.

> Index: examples/ex_bitmap.c
> ===================================================================
> --- examples/ex_bitmap.c	(revision 10927)
> +++ examples/ex_bitmap.c	(working copy)

> @@ -53,16 +66,23 @@
>          al_wait_for_event(queue, &event);
>          if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
>              break;
> -        if (event.type == ALLEGRO_EVENT_KEY_DOWN &&
> -                event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
> -            break;
> +        if (event.type == ALLEGRO_EVENT_KEY_DOWN) {
> +            if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE)
> +                break;
> +            if (event.keyboard.unichar == '+')
> +                zoom *= 1.1;
> +            if (event.keyboard.unichar == '-')
> +                zoom /= 1.1;
> +            if (event.keyboard.unichar == 'f')
> +                zoom = 320.0 / al_get_bitmap_width(bitmap);

Don't hard code 320 here.

>          }
>          if (event.type == ALLEGRO_EVENT_TIMER)
>              redraw = true;
>              
>          if (redraw && al_event_queue_is_empty(queue)) {
>              redraw = false;
> -            al_draw_bitmap(bitmap, 0, 0, 0);
> +            al_clear(al_map_rgb_f(0, 0, 0));
> +            al_draw_rotated_scaled_bitmap(bitmap, 0, 0, 0, 0, zoom, zoom, 0, 0);
>              al_flip_display();
>          }
>      }

Maybe call al_draw_bitmap() if zoom == 1.0 so that we still have a
simple test case for al_draw_bitmap()?

Peter





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/