Re: [E-devel] image loading questions

2007-07-20 Thread The Rasterman
On Sun, 15 Jul 2007 14:54:38 -0600 Eric Wasylishen [EMAIL PROTECTED]
babbled:

 Hi, I have a few questions related image loading.
 
 One thing I'm working on is an xmms2 client using ETK/evolve. I'd like
 it to show album cover art; the way the xmms2 client lib handles this
 is it gives you a pointer to an image file that was copied in to
 memory but not decoded. People using gtk have a function in gdk_pixbuf
 for this, which automatically determines the image format (probably
 jpg or png for covers) and decodes it, but as far as I can tell
 imlib2/evas lack this feature? (though I noticed epeg can load a jpeg
 file from memory.)

correct. no such feature.

 One option I though of is just copying the loader code for say JPG and
 PNG from evas or imlib2 in to my app, and modifying it to do what I
 need. Or, would loading images from memory be useful enough to go in
 evas or imlib2?

well personally i put imlib2 on life support. i don't want to put things into
it. if it goes anywhere - it's evas. as for being useful - definitely. but to
date it has not been a hard requirement.

 Another project I'd like to do is an image viewer where image loading
 doesn't block the GUI. After some reading my plan is to write a daemon
 which loads the image data in to shared memory for the gui app to
 access, though I'm not sure what advantages/disadvantages this would
 have over doing it in a thread.
 To get the best performance possible, I want it to load jpg's at a
 reduced size (epeg and evas can) and be able to cancel loading an
 image (only imlib2 can?) So far the best solution I can see is to use
 epeg and imlib2. Any better ideas?
 
 I greatly appreciate any tips or advice.. thanks :)

ok - this goes into a whole new world. as discussed before - evas is getting to
the stage where it may need threads/ipc connections etc. of its own (to talk to
shared image cache daemons, etc.) and we may need to export an FD from evas -
much like xlib and xcb export fd's and allow ecore to listen on them waiting
for events. why talk about this? this allows us to now have something like

evas_object_image_load_policy_set(obj, EVAS_LOAD_POLICY_ASYNC);

and that will hit to evas to load image data in the background - that means
either a thread or daemon does this and writes back to evas via a file
descriptor as progress happens. this can allow the load to go on in the
background. existing loaders will need to be modified to support this, but it
is possible. then when evas's fd becomes active you call

evas_process(evas);

to read any data on the fd (events) and process anything - then:

evas_render(evas);

to render any updates - if there are any. this would give you your progressive
loading, non-blocking, and make it available to anyone. a first SIMPLE
implementation could be to just load the whole image in the bg in a thread that
is spawned IF the image is set for async load policy - and when it is 100%
done, write and event back to evas. you won't see the decode as it loads, but
you won't block - it will be blank, then suddenly appear. later loaders can be
made smarter to send events as they decode (registering which sections of
the image decoded).

as for loading from memory - i see no reason we cant have a

evas_object_image_memory_set(obj, pointer_to_data, size_of_data);

(and a get too). this will match with evas_object_image_file_set() and get.
again - loaders will need to be adjusted to handle this, and not all loaders
could necessarily do it (depending on the back-end decoder lib being used).
evas can't do a quick-guess on extension as to what loader to try first, so it
will need to use a brute-force try and use all loaders until one succeeds.

 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 enlightenment-devel mailing list
 enlightenment-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
 


-- 
- Codito, ergo sum - I code, therefore I am --
The Rasterman (Carsten Haitzler)[EMAIL PROTECTED]
裸好多
Tokyo, Japan (東京 日本)

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] image loading questions

2007-07-17 Thread Eric Wasylishen
Cool, glad to hear you guys think memory loading is a sane idea!

haha, that is funny that we came up with the same plan, CodeWarrior.
I'll try to come on IRC sometime again to disucss it further. :)

On 7/16/07, Cedric BAIL [EMAIL PROTECTED] wrote:
 On Monday 16 July 2007 12:26:51 Hisham Mardam Bey wrote:
  On 7/15/07, Eric Wasylishen [EMAIL PROTECTED] wrote:
   Hi, I have a few questions related image loading.
  
   One thing I'm working on is an xmms2 client using ETK/evolve. I'd like
   it to show album cover art; the way the xmms2 client lib handles this
   is it gives you a pointer to an image file that was copied in to
   memory but not decoded. People using gtk have a function in gdk_pixbuf
   for this, which automatically determines the image format (probably
   jpg or png for covers) and decodes it, but as far as I can tell
   imlib2/evas lack this feature? (though I noticed epeg can load a jpeg
   file from memory.)
  
   One option I though of is just copying the loader code for say JPG and
   PNG from evas or imlib2 in to my app, and modifying it to do what I
   need. Or, would loading images from memory be useful enough to go in
   evas or imlib2?
 
  Would be nice to have in evas.

 Definitively. I started looking at this and only wrote a patch for eet. This
 patch add a new eet_memopen_read. So you can add eet file also to your
 idea :)

 Cedric

 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 enlightenment-devel mailing list
 enlightenment-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/enlightenment-devel




-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] image loading questions

2007-07-16 Thread Hisham Mardam Bey
On 7/15/07, Eric Wasylishen [EMAIL PROTECTED] wrote:
 Hi, I have a few questions related image loading.

 One thing I'm working on is an xmms2 client using ETK/evolve. I'd like
 it to show album cover art; the way the xmms2 client lib handles this
 is it gives you a pointer to an image file that was copied in to
 memory but not decoded. People using gtk have a function in gdk_pixbuf
 for this, which automatically determines the image format (probably
 jpg or png for covers) and decodes it, but as far as I can tell
 imlib2/evas lack this feature? (though I noticed epeg can load a jpeg
 file from memory.)

 One option I though of is just copying the loader code for say JPG and
 PNG from evas or imlib2 in to my app, and modifying it to do what I
 need. Or, would loading images from memory be useful enough to go in
 evas or imlib2?



Would be nice to have in evas.


 Another project I'd like to do is an image viewer where image loading
 doesn't block the GUI. After some reading my plan is to write a daemon
 which loads the image data in to shared memory for the gui app to
 access, though I'm not sure what advantages/disadvantages this would
 have over doing it in a thread.
 To get the best performance possible, I want it to load jpg's at a
 reduced size (epeg and evas can) and be able to cancel loading an
 image (only imlib2 can?) So far the best solution I can see is to use
 epeg and imlib2. Any better ideas?


You can read minds cant you? (=

I am currently working on this for Exhibit. The idea is to have a
worker process and the viewer, communicating (over dbus right now).
The worker does everything from loading large dirs, thumbs, sorting,
etc... When the results are ready, they are placed in SHM and a
message is sent to the client with the shmid. The client can then read
the data from SHM and do whatever it wants with it.

If you would like to discuss this idea some more, and perhaps
contribute, you can find me in #etk (CodeWarrior).

-- 
Hisham Mardam Bey
http://hisham.cc/
+9613609386
Codito Ergo Sum (I Code Therefore I Am)

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] image loading questions

2007-07-16 Thread Cedric BAIL
On Monday 16 July 2007 12:26:51 Hisham Mardam Bey wrote:
 On 7/15/07, Eric Wasylishen [EMAIL PROTECTED] wrote:
  Hi, I have a few questions related image loading.
 
  One thing I'm working on is an xmms2 client using ETK/evolve. I'd like
  it to show album cover art; the way the xmms2 client lib handles this
  is it gives you a pointer to an image file that was copied in to
  memory but not decoded. People using gtk have a function in gdk_pixbuf
  for this, which automatically determines the image format (probably
  jpg or png for covers) and decodes it, but as far as I can tell
  imlib2/evas lack this feature? (though I noticed epeg can load a jpeg
  file from memory.)
 
  One option I though of is just copying the loader code for say JPG and
  PNG from evas or imlib2 in to my app, and modifying it to do what I
  need. Or, would loading images from memory be useful enough to go in
  evas or imlib2?

 Would be nice to have in evas.

Definitively. I started looking at this and only wrote a patch for eet. This 
patch add a new eet_memopen_read. So you can add eet file also to your 
idea :)

Cedric
--- e17-clean/libs/eet/src/lib/eet_lib.c	2007-07-04 15:00:23.0 +0200
+++ e17-dev/libs/eet/src/lib/eet_lib.c	2007-07-04 15:02:25.0 +0200
@@ -464,21 +464,207 @@
 		  num++;
 	   }
 	  }
-	
+
 	for (i = 0; i  num; i++)
 	  eet_close(closelist[i]);
  }
 }
 
+static Eet_File*
+eet_internal_read (Eet_File *ef)
+{
+   const uint8_t	*dyn_buf = NULL;
+   const uint8_t	*p = NULL;
+   int			index = 0;
+   int			num_entries;
+   int			byte_entries;
+   int			i;
+
+   if (eet_test_close((ef-data == (void *)-1) || (ef-data == NULL), ef))
+ return NULL;
+
+   /* build header table if read mode */
+   /* geat header */
+   index += sizeof(int);
+   if (eet_test_close((int)ntohl(*((int *)ef-data)) != EET_MAGIC_FILE, ef))
+ return NULL;
+
+#define EXTRACT_INT(Value, Pointer, Index) \
+{ \
+	   int tmp; \
+	   memcpy(tmp, Pointer + Index, sizeof(int)); \
+	   Value = ntohl(tmp); \
+	   Index += sizeof(int); \
+}
+
+   /* get entries count and byte count */
+   EXTRACT_INT(num_entries, ef-data, index);
+   EXTRACT_INT(byte_entries, ef-data, index);
+
+   /* we cant have = 0 values here - invalid */
+   if (eet_test_close((num_entries = 0) || (byte_entries = 0), ef))
+ return NULL;
+
+   /* we can't have more entires than minimum bytes for those! invalid! */
+   if (eet_test_close((num_entries * 20)  byte_entries, ef))
+ return NULL;
+
+   /* allocate header */
+   ef-header = malloc(sizeof(Eet_File_Header));
+   if (eet_test_close(!ef-header, ef))
+ return NULL;
+
+   ef-header-magic = EET_MAGIC_FILE_HEADER;
+
+   /* allocate directory block in ram */
+   ef-header-directory = malloc(sizeof(Eet_File_Directory));
+   if (eet_test_close(!ef-header-directory, ef))
+ return NULL;
+
+   /* 8 bit hash table (256 buckets) */
+   ef-header-directory-size = 8;
+   /* allocate base hash table */
+   ef-header-directory-nodes = calloc(1, sizeof(Eet_File_Node *) * (1  ef-header-directory-size));
+   if (eet_test_close(!ef-header-directory-nodes, ef))
+ return NULL;
+
+   /* actually read the directory block - all of it, into ram */
+   dyn_buf = ef-data + index;
+
+   /* parse directory block */
+   p = dyn_buf;
+
+   for (i = 0; i  num_entries; i++)
+ {
+	Eet_File_Node	*efn;
+	void		*data = NULL;
+	int		indexn = 0;
+	int		name_size;
+	int		hash;
+	int		k;
+
+#define HEADER_SIZE (sizeof(int) * 5)
+
+	/* out directory block is inconsistent - we have oveerun our */
+	/* dynamic block buffer before we finished scanning dir entries */
+	if (eet_test_close(p + HEADER_SIZE = (dyn_buf + byte_entries), ef))
+	  return NULL;
+
+	/* allocate all the ram needed for this stored node accounting */
+	efn = malloc (sizeof(Eet_File_Node));
+	if (eet_test_close(!efn, ef))
+	  return NULL;
+
+	/* get entrie header */
+	EXTRACT_INT(efn-offset, p, indexn);
+	EXTRACT_INT(efn-compression, p, indexn);
+	EXTRACT_INT(efn-size, p, indexn);
+	EXTRACT_INT(efn-data_size, p, indexn);
+	EXTRACT_INT(name_size, p, indexn);
+
+	/* invalid size */
+	if (eet_test_close(efn-size = 0, ef))
+	  {
+	 free (efn);
+	 return NULL;
+	  }
+
+	/* invalid name_size */
+	if (eet_test_close(name_size = 0, ef))
+	  {
+	 free (efn);
+	 return NULL;
+	  }
+
+	/* reading name would mean falling off end of dyn_buf - invalid */
+	if (eet_test_close((p + 16 + name_size)  (dyn_buf + byte_entries), ef))
+	  {
+	 free (efn);
+	 return NULL;
+	  }
+
+	/* This code is useless if we dont want backward compatibility */
+	for (k = name_size; k  0  ((uint8_t) * (p + HEADER_SIZE + k)) != 0; --k)
+	  ;
+
+	efn-free_name = ((uint8_t) * (p + HEADER_SIZE + k)) != 0;
+
+	if (efn-free_name)
+	  {
+	 efn-name = malloc(sizeof(char) * name_size + 1);
+	 if (eet_test_close(efn-name == NULL, ef))
+	   {
+		  free (efn);
+		  return NULL;
+	   }
+
+	 strncpy(efn-name, (char *)p + HEADER_SIZE, name_size);
+	  

[E-devel] image loading questions

2007-07-15 Thread Eric Wasylishen
Hi, I have a few questions related image loading.

One thing I'm working on is an xmms2 client using ETK/evolve. I'd like
it to show album cover art; the way the xmms2 client lib handles this
is it gives you a pointer to an image file that was copied in to
memory but not decoded. People using gtk have a function in gdk_pixbuf
for this, which automatically determines the image format (probably
jpg or png for covers) and decodes it, but as far as I can tell
imlib2/evas lack this feature? (though I noticed epeg can load a jpeg
file from memory.)

One option I though of is just copying the loader code for say JPG and
PNG from evas or imlib2 in to my app, and modifying it to do what I
need. Or, would loading images from memory be useful enough to go in
evas or imlib2?

Another project I'd like to do is an image viewer where image loading
doesn't block the GUI. After some reading my plan is to write a daemon
which loads the image data in to shared memory for the gui app to
access, though I'm not sure what advantages/disadvantages this would
have over doing it in a thread.
To get the best performance possible, I want it to load jpg's at a
reduced size (epeg and evas can) and be able to cancel loading an
image (only imlib2 can?) So far the best solution I can see is to use
epeg and imlib2. Any better ideas?

I greatly appreciate any tips or advice.. thanks :)

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel