digitalmars.D - PNG Loading
- Trevor Parscal (17/17) May 10 2005 Before I went off and started my own D image library, I was wondering if...
- Hasan Aljudy (4/24) May 10 2005 I personally don't know, but for starters, why don't you put your
- Andrew Fedoniouk (51/51) May 10 2005 Hi, Trevor,
- Tom S (28/32) May 10 2005 /* You might want to try my DevIL D bindings:
- Trevor Parscal (11/43) May 11 2005 Thanks, I diddn't notice that derelict had made some D bindings for DevI...
- Peter Mackay (12/18) May 11 2005 Hello,
- Mike Parker (9/11) May 11 2005 Actually, it isn't in Derelict just yet. Tom created it for Derelict and...
- Stewart Gordon (16/18) May 11 2005 I've just been trying to find my way thorough it. It seems that the
- Andrew Fedoniouk (35/59) May 11 2005 Agreed,
Before I went off and started my own D image library, I was wondering if anyone knows of any such effort already underway wehre I could lend a hand. I have looked in www.dsource.org and in google of course, but I haven't found anything at all. Loading PNG's is 90% of my intended intial functionality :( I can't find a D libpng port anywhere :( I don't know enough about ZLib yet OpenGL support is the other 10% :) OpenGL already works with D Anyhoo, if there is anyone who knows of an image loading project, or knows enough about image loading they would like to start one, let me know, cause I think having a native image library, or a good port of an image library, could really help allot of developers out. Thanks, Trevor Parscal trevorparscal hotmail.com www.trevorparscal.com
May 10 2005
Trevor Parscal wrote:Before I went off and started my own D image library, I was wondering if anyone knows of any such effort already underway wehre I could lend a hand. I have looked in www.dsource.org and in google of course, but I haven't found anything at all. Loading PNG's is 90% of my intended intial functionality :( I can't find a D libpng port anywhere :( I don't know enough about ZLib yet OpenGL support is the other 10% :) OpenGL already works with D Anyhoo, if there is anyone who knows of an image loading project, or knows enough about image loading they would like to start one, let me know, cause I think having a native image library, or a good port of an image library, could really help allot of developers out. Thanks, Trevor Parscal trevorparscal hotmail.com www.trevorparscal.comI personally don't know, but for starters, why don't you put your project on dsource? you may find help there.. i.e. other people intersted may join the effort!
May 10 2005
Hi, Trevor, Here is the link: http://www.terrainformatica.com/harmonia/imageio.d.zip Harmonia is using this imageio.lib for loading PNG and JPEG images. There is one simple imageio.d (it is also attached) file and build.cmd which will build imageio.lib using DigitalMars C/C++ compiler on Windows, on other platforms you may use make utility with makefile provided. (EncodeImage is not implemented yet.) ----------------------- Internally Harmonia uses Win32 DIB API on Windows for dealing with images. So ::CreateDIBSection and DecodeImage is everything you need. class harmonia.gx.images.Image wrapps all this into simple object. It also supports AlphaBlend rendering (implemented in D). Best wishes, Andrew. begin 666 imageio.d M=&AO<CH 06YD<F5W($9E9&]N:6]U:RP :'1T<#HO+W1E<G)A:6YF;W)M871I M<VEO;B H5VEN9&]W<RD-"GL-"B <')A9VUA*&QI8BP (FEM86=E:6]<7&EM M8GD 0R!S:61E('=I=& <&%R86UE=&5R<SH-"B +R\ +2!P8W1O<E!R;2 M M9VAT(&]F(&EM86=E(&EN('!I>&5L<SL-"B +R\ +2!B>71E<U!E<E!I>&5L M("T 8V]L;W( 8V%P86-I='DL('!O<W-I8FQE('9A;'5E<SH ,R H<F=B*2!A M;F0 -"AR9V)A*0T*(" O+R M(')O=U!T<G, +2!V96-T;W( ;V8 =6)Y=&4J M(%MH96EG:'1=("T 87!P;&EC871I;VX <VAA;&P 9FEL;"!I="!B>2!V86QI M9"!P;VEN=&5R<R!T;PT*(" O+R (')O=W, ;V8 8W)E871E9"!I;6%G93L- M"B +R\ ("!2971U<FYS. T*(" O+R ](&YO;BUZ97)O+"!I9B!A<'!L:6-A M=&EO;B!C<F5A=&5D(&EM86=E('-T<G5C='5R92!A;F0 9FEL;&5D(')O=U!T M+ T*( T*("!A;&EA<R!I;G0 9G5N8W1I;VXH=F]I9"H <&-T;W)0<FTL('5I M;G0 =VED=& L('5I;G0 :&5I9VAT+"!I;G0 8GET97-097)0:7AE;"P =6)Y M92!F=6YC=&EO;BP <&%R86UE=&5R<SH-"B +R\ +2!P8W1O<B M(')E9F5R M96YC92!T;R!T:&4 8V%L;&)A8VL 9G5N=&EO;CL-"B +R\ +2!P8W1O<E!R M;2 M('!A<F%M971E<B!B96EN9R!P87-S960 (F%S(&ES(B!T;R!T:&4 8V%L M8F%C:R!F=6YC=&EO;CL-"B +R\ +2!S<F, +2!P;VEN=&5R('1O('-T87)T M(&]F('1H92!B=69F97( 8V]N=&%I;FEN9R!03D< ;W( 2E!%1R!E;F-O9&5D M(&EM86=E.PT*(" O+R M('-R8VQE;F=T:" M(&QE;F=T:"!O9B!S<F, 8G5F M<F\L(&EF(&EM86=E('=A<R!D96-O9&5D('-U8V-E<W-F=6QL>3L-"B +R\ M;W( <&-T;W(L('9O:60J('!C=&]R4')M+"!U8GET92H <W)C+"!U:6YT('-R ` end
May 10 2005
Trevor Parscal wrote:Anyhoo, if there is anyone who knows of an image loading project, or knows enough about image loading they would like to start one, let me know, cause I think having a native image library, or a good port of an image library, could really help allot of developers out./* You might want to try my DevIL D bindings: http://codeinsane.info/code/DevIL.zip You're gonna need the Build utility to create .lib files. I've provided a few .bat files to help you with that. Then you link your project against that libs (after putting them to dmd\lib): */ pragma (lib, "derelictIL.lib"); pragma (lib, "derelictILU.lib"); pragma (lib, "derelictILUT.lib"); /* import: */ import derelict.openil.il; import derelict.ilu.ilu; import derelict.ilut.ilut; /* and dynamically load functions from DevIL DLLs (the module is meant to be integrated in Derelict but it isn't a part of it yet): */ DerelictIL_Load(); DerelictILU_Load(); DerelictILUT_Load(); /* then you have to initialize DevIL: */ ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); /* after creating the rendering context, if you want to use DevIL with OpenGL */ After that you're ready to roll ;) The docs are here: http://openil.sourceforge.net/ -- Tomasz Stachowiak /+ a.k.a. h3r3tic +/
May 10 2005
In article <d5s9o4$bu1$1 digitaldaemon.com>, Tom S says...Trevor Parscal wrote:Thanks, I diddn't notice that derelict had made some D bindings for DevIL. I might end up making a native D image library though, cause the DevIL route, alhtough more robust than what I will initially be able to produce, is also not only complex to imliment, but also has many features I don't need. Thanks again for the tip, now I can get soemthing going for now, even if I make my own image lib later. Thanks, Trevor Parscal www.trevorparscal.com trevorparscal hotmail.comAnyhoo, if there is anyone who knows of an image loading project, or knows enough about image loading they would like to start one, let me know, cause I think having a native image library, or a good port of an image library, could really help allot of developers out./* You might want to try my DevIL D bindings: http://codeinsane.info/code/DevIL.zip You're gonna need the Build utility to create .lib files. I've provided a few .bat files to help you with that. Then you link your project against that libs (after putting them to dmd\lib): */ pragma (lib, "derelictIL.lib"); pragma (lib, "derelictILU.lib"); pragma (lib, "derelictILUT.lib"); /* import: */ import derelict.openil.il; import derelict.ilu.ilu; import derelict.ilut.ilut; /* and dynamically load functions from DevIL DLLs (the module is meant to be integrated in Derelict but it isn't a part of it yet): */ DerelictIL_Load(); DerelictILU_Load(); DerelictILUT_Load(); /* then you have to initialize DevIL: */ ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); /* after creating the rendering context, if you want to use DevIL with OpenGL */ After that you're ready to roll ;) The docs are here: http://openil.sourceforge.net/ -- Tomasz Stachowiak /+ a.k.a. h3r3tic +/
May 11 2005
Hello, I was wondering, what do you use to set up your OpenGL context? If it's SDL, then why not use SDL_image to load the image and SDL_ConvertSurface to convert the surface to a suitable OpenGL-friendly format? I've attached the SDL and OpenGL code I use to do this to this message. sdl.d is a thin wrapper around SDL_Surface and TTF_Font. opengl.d is a thin wrapper around OpenGL textures. Use/delete as you like :-) Probably the thing to keep in mind when converting surfaces to GL_RGB or GL_RGBA formats is the byte ordering, and that the surface probably needs to be flipped vertically for OpenGL. PeterI might end up making a native D image library though, cause the DevIL route, alhtough more robust than what I will initially be able to produce, is also not only complex to imliment, but also has many features I don't need. Thanks again for the tip, now I can get soemthing going for now, even if I make my own image lib later.
May 11 2005
Trevor Parscal wrote:Thanks, I diddn't notice that derelict had made some D bindings for DevIL.Actually, it isn't in Derelict just yet. Tom created it for Derelict and sent it to me to commit, but I haven't gotten around to it yet. I am toying with adding bindings for libpng and libjpeg, but I'm rather feeling it would be a better idea to port both to D instead of binding. There's so many different versions out there compiled with so many different preprocessor options, the only reliable way to use either would be to ship a specific version with your app. So to me, porting makes more sense.
May 11 2005
Tom S wrote: <snip>After that you're ready to roll ;) The docs are here: http://openil.sourceforge.net/I've just been trying to find my way thorough it. It seems that the tutorial is still under heavy construction. And at first it would appear that it allows only one image to be loaded at the time, until you discover ilBindImage.... I think D could benefit from a decent OO image library. Ideally it would: - provide format-independent access to common features (obviously) - provide some form of access to format-specific features (such as JPEG compression levels, GIF/PNG interlacing....) - allow for both access to the raw RGB (and maybe other colour models) data and conversion to/from OS API-compatible image objects Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
May 11 2005
I think D could benefit from a decent OO image library. Ideally it would: - provide format-independent access to common features (obviously) - provide some form of access to format-specific features (such as JPEG compression levels, GIF/PNG interlacing....) - allow for both access to the raw RGB (and maybe other colour models) data and conversion to/from OS API-compatible image objectsAgreed, I've made my attempt to do this: http://www.terrainformatica.com/harmonia/imageio.d.zip It is in C but with simple D wrapper as I don't think that it make too much sense to port PNG/JPEG/etc.into D natively. Not yet at least :) It is a seperate idependent package thus it could be used everywhere (not only in Harmonia currently) As an example of possible OO generic image approach you may consider Harmonia way: ------------------------------- Harmonia simple image object: class Image: ISurface, NativeImage /*on Win32 it is a DIB wrapper*/ { public: this( size sz , bool alpha ); // clear rgb or rgba image static Image create( ubyte[] bytes /*png,jpg,etc. encoded bytes*/); static Image loadFromURL(wchar[] uri); static Image load( wchar[] path ); // from local file system static Image loadFromResource( wchar[] name ); size dimension() { return nativeDimension(); } uint bytesPerPixel( ) { return nativeBytesPerPixel(); } } As Image is a ISurface then you can draw/copy/manipulate it using Graphics object: void Foo(Image pic) { auto Graphics gfx = new Graphics(pic); gfx.drawChars(point(10,10), "Hello world"); gfx.fillRect(rect rc, color c); gfx.copy(point dst , rect src); gfx.stretch(rect dst, rect src); // etc. } "Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:d5te8t$1aig$1 digitaldaemon.com...Tom S wrote: <snip>After that you're ready to roll ;) The docs are here: http://openil.sourceforge.net/I've just been trying to find my way thorough it. It seems that the tutorial is still under heavy construction. And at first it would appear that it allows only one image to be loaded at the time, until you discover ilBindImage.... I think D could benefit from a decent OO image library. Ideally it would: - provide format-independent access to common features (obviously) - provide some form of access to format-specific features (such as JPEG compression levels, GIF/PNG interlacing....) - allow for both access to the raw RGB (and maybe other colour models) data and conversion to/from OS API-compatible image objects Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
May 11 2005