|
I like the creativity it requires.
Here I get called back with rectangles I'm getting from "converting" a jpeg - in this case into a raw rgb565BE bitmap form, compatible with the frame buffer of the LCD display I'm using. I'm them telling the device to do a DMA transfer from the ram I just gave it, in effect, loading the JPEG onto the display one rectangle at a time:
jpg_state js;
js.tft=&tft;
js.dma_space=dma_space;
js.size = dma_size;
io::file_stream inp("/spiffs/warhol320x240.jpg",file_mode::read);
jpeg::convert(
inp,
[](const rect16& rect,size16 size,const rgb888* bitmap, const void* state){
jpg_state s = *((jpg_state*)state);
const rgb888* end = bitmap+(sizeof(rgb888)*rect.width()*rect.height());
assert((((end-bitmap)/sizeof(rgb888))*sizeof(rgb565))<=s.size);
uint16_t* buf=(uint16_t*)s.dma_space;
while(bitmap!=end) {
rgb565 col = color::reduce(*bitmap++);
*(buf++)=env::platform::mkbe(col.value);
}
return result::success==s.tft->write(rect,s.dma_space);
},
&js);
Real programmers use butterflies
|
|
|
|
|
Many moons ago (Before Windows), I wrote graphics packages for the CGA, EGA, and Hercules. These ran on the IBM PC (640KB, 8088at 4.77 MHz) with reasonable performance. This, despite arcane addressing and slow I/O.
Even if I/O is slow, how difficult could it be to write graphics packages for a 32-bit processor with tons (8 mega bytes!) of memory?
Without going into details, perhaps you're over-engineering the problem. For example, unless there is a specific requirement for supporting JPEG images in runtime, why not convert them offline to a more amenable format? I am certain that many other shortcuts are possible if you think of the problems in the right way.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Daniel Pfeffer wrote: For example, unless there is a specific requirement for supporting JPEG images in runtime, why not convert them offline to a more amenable format?
I thought about it. But then I remembered that 320*240*16 is a really big number, and my flash storage size isn't a much bigger number, even on the ESP32 which is fairly generous.
But actually, that's not the main reason I support it. I support it because SD cards and cameras exist for these monsters and both typically can produce or source pictures or frames in JPEG format
I wrote the JPEG library. I have andy warhols sunglassed face starting at me from inside the ESP32 Wrover Kit's LCD and rippling weirdly under the effect I'm running right now.
If it makes you feel any better, I thought about supporting PNG too, before catching myself.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: I love coding for these little things because you're so close to the metal, but when you want to go your own way with something, because existing offerings are too heavy or limited, you have to start over from scratch. Something about cake and eating it too comes to mind .
I've implemented a couple graphics libraries in my time. Instead of run-time polymorphism, try build-time polymorphism. Instead of a device 'driver' that has to be all things to all people, have a device-specific bottom layer with an interface that's sufficiently generic for the graphics library's purposes, but no more than that. This device layer provides only essential primitives: line drawing, curve drawing if you need it, region fills, essentially only the device coordinate primitives you might want. A lot of Bresenham's algorithms are useful here. I've not implemented significant text capabilities, but there are primitive operations for that the device layer can provide (draw a block of pixels, for example). Since footprint is a concern, the device layer should be granular in a way that lets the linker prune parts that aren't used.
Needless to say, K.I.S.S. should be your guide here.
Software Zen: delete this;
|
|
|
|
|
I'm on the fence about using templates for that. flash program space is almost more valuable than RAM so templates are problematic because of the code bloat they tend to introduce. I'm not fully opposed to them in this case, and i've used one or two little ones (mainly for templating a piece of hardware's physical pin assignments) but I haven't been doing any generic programming as a rule.
The driver does exactly what you're talking about. And the challenge is coming up with something high level enough that it satisfies the better devices in terms of being able to use their hardware features like line drawing, without incurring a bunch of overhead for most drivers that don't have it and typically just deal in bltting.
My attempted approach right now is to build the fundamentals into the library such that the compiler and linker can eliminate what's not used - for example, if your hardware supports line drawing the software won't link the line drawing code into the library.
I'm doing this by creating static helpers that do basic drawing. The drivers call the hardware or return a not_supported result. If it's not supported, a canvas can fallback on using the software, at which point it will be included in the final source.
This is tricky. The other thing I'm running into is if I expose a canvas from a given bitmap, then I have to support any graphics features used by that canvas in software, since no video card is involved, leading to potential inclusion of much of the library under many situations. =(
Real programmers use butterflies
|
|
|
|
|
March 14 (3-14) is national pi day!
Get me coffee and no one gets hurt!
|
|
|
|
|
What! It'll be stale and nasty with soggy pastry that sticks to the roof your mouth.
Make it on the day, it's the best way to enjoy them ... Scotch Pie; Pork Pie; Snake and Pygmy Pie; Chicken, BACON, and Mushroom pie; all damn good!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Quote: Pygmy Pie You bake pygmies into pies?
Get me coffee and no one gets hurt!
|
|
|
|
|
Well, you can Devil[^] them as well ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Snake and Pygmy no less!
Does the snake have to consume the Pygmy first or are the ingredients separate?
If you can't laugh at yourself - ask me and I will do it for you.
|
|
|
|
|
My grandmother made a great steak and kidney pie. Well, as long as you didn't have to smell the kidneys cooking.
She was from Bolton.
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
Judging by the list of things you apparently consider as edible I can only deduce that the UK has been too close to France for too long.
Better had you been assimilated by the Borg.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
The reason they started an empire was so some of them could get away from their mothers cooking!
If you can't laugh at yourself - ask me and I will do it for you.
|
|
|
|
|
OriginalGriff wrote: Scotch Pie I'm salivating just thinking of that.
|
|
|
|
|
Pi is filth! Tau is the only true path!
|
|
|
|
|
e is the truth and the light! (8 out of 10 clubbers can't be wrong.)
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Shepards' Pi it is then.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
What's so special about 14-3?
|
|
|
|
|
Sander Rossel wrote: What's so special about 14-3? 11 - It's prime and a palindromic number, what more could you want?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Arghhh! I've got aibohphobia!
|
|
|
|
|
Sander Rossel wrote: aibohphobia Now THAT's a new one!
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Is the easiest time to add insult to injury when you're signing somebody's cast?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
What fracture of the time do people get signable casts anymore? Those days are in distant plaster. That sets the crutch of the problem as intractionalbe.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Quote: If all that machine learning language sounds complicated, well, that’s because it is. Don’t worry, though — the Super Resolution feature we built around this technology is very simple to use — press a button and watch your 10-megapixel photo transform into a 40-megapixel photo. It’s a bit like how Mario eats a mushroom and suddenly balloons into Super Mario, but without the nifty sound effects. Eric Chan is a Senior Principal Scientist on the Adobe Camera Raw team.,
I posted an "Insider News" item with links to Eric's blog on this newly released technology: [^]
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|