Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: PNG coding |
| Date | 2016-11-16 20:31 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <o0ifld$cjv$1@dont-email.me> (permalink) |
| References | <o0foak$4cu$1@reader2.panix.com> <o0idjd$4b5$1@dont-email.me> |
On 16/11/2016 19:55, Jean-marc Lienher wrote:
> ruben safir wrote:
>> Does anyone know of any sample code for reading PNG files that doesn't
>> include using libpng.... just straight direct access.
>>
>>
> Yes:
> https://github.com/nothings/stb/blob/master/stb_image.h
That worked, eventually, but rather over-complicated by trying to have a
.h file that both contained shared declarations, and code.
So you can't just stick a main() routine at the end of the file. And you
can't just #include the file as a header, it needs an extra #define.
It's better than the majority of such libraries however.
(I still wouldn't like to have to fix a bug in it, even if it's only
6000 lines instead of 40000.)
-----------------------------------
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.c" // or .h
int main(void){
char* data;
int x,y,n;
data = stbi_load("file.jpg", &x, &y, &n, 0);
printf ("data = %p\n",data);
printf ("x = %d y = %d n = %d\n",x,y,n);
}
(I use stb_image.c not .h as my IDE can't compile standalone .h files.)
--
bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PNG coding ruben safir <ruben@mrbrklyn.com> - 2016-11-15 14:40 -0500
Re: PNG coding "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-15 12:02 -0800
Re: PNG coding ruben safir <ruben@mrbrklyn.com> - 2016-11-15 15:20 -0500
Re: PNG coding "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-15 12:25 -0800
Re: PNG coding "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-15 15:34 -0500
Re: PNG coding Popping mad <rainbow@colition.gov> - 2016-11-15 20:57 +0000
Re: PNG coding "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-15 16:12 -0500
Re: PNG coding jadill33@gmail.com - 2016-11-15 14:00 -0800
Re: PNG coding Jorgen Grahn <grahn+nntp@snipabacken.se> - 2016-11-20 11:14 +0000
Re: PNG coding Richard Heathfield <rjh@cpax.org.uk> - 2016-11-15 21:45 +0000
Re: PNG coding "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-15 17:15 -0500
Re: PNG coding Richard Heathfield <rjh@cpax.org.uk> - 2016-11-15 22:41 +0000
Re: PNG coding Melzzzzz <mel@zzzzz.com> - 2016-11-15 23:49 +0100
Re: PNG coding Anton Shepelev <anton.txt@g{oogle}mail.com> - 2016-11-16 15:23 +0300
Re: PNG coding Richard Heathfield <rjh@cpax.org.uk> - 2016-11-16 13:57 +0000
Re: PNG coding BGB <cr88192@hotmail.com> - 2016-11-18 01:24 -0600
Re: PNG coding BartC <bc@freeuk.com> - 2016-11-18 11:56 +0000
Re: PNG coding BGB <cr88192@hotmail.com> - 2016-11-18 12:48 -0600
Re: PNG coding BartC <bc@freeuk.com> - 2016-11-19 00:21 +0000
Re: PNG coding BGB <cr88192@hotmail.com> - 2016-11-19 01:50 -0600
Re: PNG coding Melzzzzz <mel@zzzzz.com> - 2016-11-15 23:42 +0100
Re: PNG coding BGB <cr88192@hotmail.com> - 2016-11-15 17:53 -0600
Re: PNG coding "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-15 16:25 -0800
Re: PNG coding raltbos@xs4all.nl (Richard Bos) - 2016-11-18 08:15 +0000
Re: PNG coding jameskuyper@verizon.net - 2016-11-18 09:35 -0800
Re: PNG coding supercat@casperkitty.com - 2016-11-20 14:34 -0800
Re: PNG coding BartC <bc@freeuk.com> - 2016-11-16 19:38 +0000
Re: PNG coding Richard Heathfield <rjh@cpax.org.uk> - 2016-11-16 22:16 +0000
Re: PNG coding "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-16 21:14 +0800
Re: PNG coding Jean-marc Lienher <jean-marc.lienher@bluewin.ch> - 2016-11-16 20:55 +0100
Re: PNG coding BartC <bc@freeuk.com> - 2016-11-16 20:31 +0000
Re: PNG coding Richard Heathfield <rjh@cpax.org.uk> - 2016-11-16 22:24 +0000
csiph-web