Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An idea for those wanting to fetch and view large images on the 3DS off the internet #62

Open
LexiBigCheese opened this issue Jan 19, 2025 · 1 comment

Comments

@LexiBigCheese
Copy link

The 3DS does not have much RAM, a large image might end up filling the whole RAM if downloaded, swizzled, then uploaded to a texture.
Instead, you may want a custom image loader, in which you use chunked transfering, in ehttp terms, this is streaming, in minreq terms, this is .send_lazy.
For PNG, if i remember correctly, you only need to know the pixel above and the pixel to the left to decode a pixel, so you will be storing at most two rows of pixels, the width of the image, to decode.
You may want to do some form of either sampling a pixel every so often to be loaded into the texture, or storing rolling sums that, when filled, are divided by however many pixels that rolling sum stores, and you generate what could be thought of as an "on the fly mipmap".
For JPEG, you may be able to make use of the properties of sin and cos (and the way their integrals work) to convert the blocks into "average color", and then store and convert those blocks into pixels.
Note that the 3DS seems to bork out if using a texture with a side length greater than 1024, so unless the server you're connecting to has some sort of https://somecdn/image/keysmash?format=FORMAT&width=WIDTH&height=HEIGHT, you're going to have to either create a proxy server that can more easily transcode images, likely using imagemagick, which the 3DS then loads trivially, at least under egui with egui_extras, or you're going to have to implement these custom loading routines.
If you do implement these custom loading routines, let the rust3ds team know, so others may use your hard work.

@LexiBigCheese
Copy link
Author

width height format channels size calculation
1Ki 1Ki RGBA8 4 4MiB 1Ki × 1Ki × 4
1Ki 1Ki A8 1 1MiB 1Ki × 1Ki × 1
1Ki 1Ki ETC1 3 512KiB 4 pixels × 4 pixels = 1 block
1 block = 8 bytes
1Ki × 1Ki = 0x10000 blocks
0x80000 bytes = 512KiB
1Ki 1Ki ETC1A4 4 1MiB 1Ki × 1Ki × 0.5 = 512KiB
512KiB + Above Result = 1MiB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant