~mil/mepo-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Add support for JPEG tiles

Details
Message ID
<20240611200623.43719-1-dev@open-music-kontrollers.ch>
DKIM signature
pass
Download raw message
Patch: +2 -1
The tile server [1] I'd like to use only provides JPEG tiles and `mepo`
currently refuses to load anything else than PNGs.

As nothing else in the code seems to depend on the PNG format
specifically and SDL can handle any image type it supports, this change
just adds a check for JPEG images.

Tested with tile server [1] (zoom in to Switzerland to see something).

[1] https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.pixelkarte-farbe/default/current/3857/%3$d/%1$d/%2$d.jpeg
---
 src/TileCache.zig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/TileCache.zig b/src/TileCache.zig
index 17e662c..d8d0269 100644
--- a/src/TileCache.zig
+++ b/src/TileCache.zig
@@ -420,10 +420,11 @@ fn download_loop_transfer_complete(tile_cache: *@This(), msg: *curl.CURLMsg) !vo
                        sdl.SDL_RWFromConstMem(@ptrCast(&datum_array[0]), @intCast(datum_array.len)),
                    );
                    const is_valid_png_data = sdl.SDL_TRUE == sdl.IMG_isPNG(memory);
                    const is_valid_jpg_data = sdl.SDL_TRUE == sdl.IMG_isJPG(memory);
                    try utilsdl.errorcheck(sdl.SDL_RWclose(memory));

                    // Save to FS
                    if (is_valid_png_data) {
                    if (is_valid_png_data or is_valid_jpg_data) {
                        const path = try png_path(tile_cache.allocator, p.get(p.pref.tile_cache_url).t.?, coords);
                        try cache_dir.writeFile(.{ .sub_path = path, .data = datum_array });
                    }
-- 
2.45.2
Details
Message ID
<49cd843c-6171-462b-9bb5-640e99ed2d35@app.fastmail.com>
In-Reply-To
<20240611200623.43719-1-dev@open-music-kontrollers.ch> (view parent)
DKIM signature
pass
Download raw message
On Tue, Jun 11, 2024, at 4:06 PM, Hanspeter Portner wrote:
> The tile server [1] I'd like to use only provides JPEG tiles and `mepo`
> currently refuses to load anything else than PNGs.
>
> As nothing else in the code seems to depend on the PNG format
> specifically and SDL can handle any image type it supports, this change
> just adds a check for JPEG images.
>
> Tested with tile server [1] (zoom in to Switzerland to see something).
>
> [1] 
> https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.pixelkarte-farbe/default/current/3857/%3$d/%1$d/%2$d.jpeg
> ---
>  src/TileCache.zig | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)


Thanks for sending - and apologies for the extended delay for review,
been caught up in a few other things.

JPEG support sounds good to me & this mostly looks good. However, we
would also need to modify the other references in the code for JPEG
support as well.

In src/Mepo.zig:
  - We would replace IMG_INIT_PNG to be IMG_INIT_PNG | IMG_INIT_JPG

In src/TileCache.zig:
  - png_path fn would need to be replaced to support .png or .jpg
    - As is current design with patch we'd be writing JPG data to .png files
  - Other references / labels for png would need to be replaced

Miles
Reply to thread Export thread (mbox)