www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - PNG Loading

reply Trevor Parscal <Trevor_member pathlink.com> writes:
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
next sibling parent Hasan Aljudy <hasan.aljudy gmail.com> writes:
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.com

I 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
prev sibling next sibling parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
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.
May 10 2005
prev sibling parent reply Tom S <h3r3tic remove.mat.uni.torun.pl> writes:
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
next sibling parent reply Trevor Parscal <Trevor_member pathlink.com> writes:
In article <d5s9o4$bu1$1 digitaldaemon.com>, Tom S says...
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 +/

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.com
May 11 2005
next sibling parent Peter Mackay <a_pointy_stick.NoJunkMail yahoo.co.uk> writes:
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

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.

Peter

 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.

May 11 2005
prev sibling parent Mike Parker <aldacron71 yahoo.com> writes:
Trevor Parscal wrote:

 Thanks, I diddn't notice that derelict had made some D bindings for DevIL.
 

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
prev sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
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
parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
 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

Agreed, 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