Re: GtkPixbuf from Char buffer

2008-10-19 Thread Arto Karppinen
This looks like what we need. Thanks.

Kemal Hadimli wrote:
From Maemopad+ 
(https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/unified/src/ui/callbacks.c?revision=94root=maemopadplusview=markup
 )
 
 GdkPixbufLoader *pl = gdk_pixbuf_loader_new_with_type(png, NULL);
 GError *err = NULL;
 gdk_pixbuf_loader_write(pl, (guchar *) blob, blobsize, err);
 f (err != NULL)
 {
 //error
 g_error_free(err);
 return;
 }
 gdk_pixbuf_loader_close(pl, NULL);
 GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(pl);
 
 if (GDK_IS_PIXBUF(pixbuf))
 {
 //do stuff
 }
 g_object_unref(pl);
 
 

-- 
Arto Karppinen
--
[EMAIL PROTECTED]
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


GtkPixbuf from Char buffer

2008-10-16 Thread Arto Karppinen

Hi, were developing an application which is supposed to show user images 
downloaded from web server using xmlrpc. The problem is that we cant 
quite figure out how to create a pixbuf from a buffer which contains the 
RAW contents of a file.

Functions like:

gdk_pixbuf_new_from_data
gdk_pixbuf_new_from_inline
gdk_pixbuf_from_pixdata

all seem to expect the image to be in some particular format already, 
while what we need is more like gdk_pixbuf_new_from_file() which is able 
to autodetect everything and just read the file.

All information that our application has about the image are:
  - Name of file.
  - Size of file.
  - Contents of file.

-- 
Arto Karppinen
--
[EMAIL PROTECTED]
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: GtkPixbuf from Char buffer

2008-10-16 Thread gary liquid
arto,

have you considered caching the downloaded file to disk and reading from
there using the standard function?

This would give you the obvious benefit of allowing offline usage and faster
requerying.
There isn't an infinite amount of memory available and having to download
images everytime could cause user angst.

I believe /tmp is mapped to real memory and not the flash drive, so would
not cause real problems and wouldn't be much slower  (someone can confirm
this?)

Even though it may require a little bit more time to organise a cache file
plan, it may be worth it in the end?

Gary (lcuk on #maemo)

On Thu, Oct 16, 2008 at 3:12 PM, Arto Karppinen 
[EMAIL PROTECTED] wrote:


 Hi, were developing an application which is supposed to show user images
 downloaded from web server using xmlrpc. The problem is that we cant
 quite figure out how to create a pixbuf from a buffer which contains the
 RAW contents of a file.

 Functions like:

gdk_pixbuf_new_from_data
gdk_pixbuf_new_from_inline
gdk_pixbuf_from_pixdata

 all seem to expect the image to be in some particular format already,
 while what we need is more like gdk_pixbuf_new_from_file() which is able
 to autodetect everything and just read the file.

 All information that our application has about the image are:
  - Name of file.
  - Size of file.
  - Contents of file.

 --
 Arto Karppinen
 --
 [EMAIL PROTECTED]
 ___
 maemo-developers mailing list
 maemo-developers@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers

___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: GtkPixbuf from Char buffer

2008-10-16 Thread Daniil Ivanov
Hello!

  One way is to create GdkPixbufLoader and feed your image with
gdk_pixbuf_loader_write.
  It will parse it and give you GdkPixbuf.

  Another way is to save data into temporary file and do
gdk_pixbuf_new_from_file ().

Thanks, Daniil.

On Thu, Oct 16, 2008 at 5:12 PM, Arto Karppinen
[EMAIL PROTECTED] wrote:

 Hi, were developing an application which is supposed to show user images
 downloaded from web server using xmlrpc. The problem is that we cant
 quite figure out how to create a pixbuf from a buffer which contains the
 RAW contents of a file.

 Functions like:

gdk_pixbuf_new_from_data
gdk_pixbuf_new_from_inline
gdk_pixbuf_from_pixdata

 all seem to expect the image to be in some particular format already,
 while what we need is more like gdk_pixbuf_new_from_file() which is able
 to autodetect everything and just read the file.

 All information that our application has about the image are:
  - Name of file.
  - Size of file.
  - Contents of file.

 --
 Arto Karppinen
 --
 [EMAIL PROTECTED]
 ___
 maemo-developers mailing list
 maemo-developers@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers

___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: GtkPixbuf from Char buffer

2008-10-16 Thread Eero Tamminen
Hi,

ext gary liquid wrote:
 have you considered caching the downloaded file to disk and reading from
 there using the standard function?
 
 This would give you the obvious benefit of allowing offline usage and faster
 requerying.
 There isn't an infinite amount of memory available and having to download
 images everytime could cause user angst.
 
 I believe /tmp is mapped to real memory and not the flash drive, so would
 not cause real problems and wouldn't be much slower  (someone can confirm
 this?)

This is a no-no.  The system /tmp is a RAM-disk with 1/2MB max size
and it's used by all applications.  It's intended for _small_ (few KB)
temporary files.  For larger or more permanent[1] things one should
use $TMPDIR i.e. /var/tmp which is on Flash.

[1] See the Filesystem Hierarchy Standard:
http://www.pathname.com/fhs/


 Even though it may require a little bit more time to organise a cache file
 plan, it may be worth it in the end?


- Eero
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: GtkPixbuf from Char buffer

2008-10-16 Thread gary liquid
i don't mind being wrong :)
thanks Eero, it was the principle more than the specifics I was trying to
indicate however.

On Thu, Oct 16, 2008 at 3:46 PM, Eero Tamminen [EMAIL PROTECTED]wrote:

 Hi,

 ext gary liquid wrote:

 have you considered caching the downloaded file to disk and reading from
 there using the standard function?

 This would give you the obvious benefit of allowing offline usage and
 faster
 requerying.
 There isn't an infinite amount of memory available and having to download
 images everytime could cause user angst.

 I believe /tmp is mapped to real memory and not the flash drive, so would
 not cause real problems and wouldn't be much slower  (someone can confirm
 this?)


 This is a no-no.  The system /tmp is a RAM-disk with 1/2MB max size
 and it's used by all applications.  It's intended for _small_ (few KB)
 temporary files.  For larger or more permanent[1] things one should
 use $TMPDIR i.e. /var/tmp which is on Flash.

 [1] See the Filesystem Hierarchy Standard:
http://www.pathname.com/fhs/



  Even though it may require a little bit more time to organise a cache file
 plan, it may be worth it in the end?



- Eero

___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: GtkPixbuf from Char buffer

2008-10-16 Thread Kemal Hadimli
From Maemopad+ 
(https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/unified/src/ui/callbacks.c?revision=94root=maemopadplusview=markup
)

GdkPixbufLoader *pl = gdk_pixbuf_loader_new_with_type(png, NULL);
GError *err = NULL;
gdk_pixbuf_loader_write(pl, (guchar *) blob, blobsize, err);
f (err != NULL)
{
//error
g_error_free(err);
return;
}
gdk_pixbuf_loader_close(pl, NULL);
GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(pl);

if (GDK_IS_PIXBUF(pixbuf))
{
//do stuff
}
g_object_unref(pl);


On Thu, Oct 16, 2008 at 5:12 PM, Arto Karppinen
[EMAIL PROTECTED] wrote:

 Hi, were developing an application which is supposed to show user images
 downloaded from web server using xmlrpc. The problem is that we cant
 quite figure out how to create a pixbuf from a buffer which contains the
 RAW contents of a file.

 Functions like:

gdk_pixbuf_new_from_data
gdk_pixbuf_new_from_inline
gdk_pixbuf_from_pixdata

 all seem to expect the image to be in some particular format already,
 while what we need is more like gdk_pixbuf_new_from_file() which is able
 to autodetect everything and just read the file.

 All information that our application has about the image are:
  - Name of file.
  - Size of file.
  - Contents of file.

 --
 Arto Karppinen
 --
 [EMAIL PROTECTED]
 ___
 maemo-developers mailing list
 maemo-developers@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers



--
Kemal
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: GtkPixbuf from Char buffer

2008-10-16 Thread Arto Karppinen
gary liquid wrote:
 arto,
 
 have you considered caching the downloaded file to disk and reading from 
 there using the standard function?
 
 This would give you the obvious benefit of allowing offline usage and 
 faster requerying.
 There isn't an infinite amount of memory available and having to 
 download images everytime could cause user angst.

This is about a small preview image for the complete Irreco Theme, so i 
don't feel there is any real need to cache it.

The theme will be saved to disk if the user likes the preview, and 
chooses do download the whole thing.


-- 
Arto Karppinen
--
[EMAIL PROTECTED]
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: GtkPixbuf from Char buffer

2008-10-16 Thread Alberto Garcia
On Thu, Oct 16, 2008 at 05:12:40PM +0300, Arto Karppinen wrote:

 Hi, were developing an application which is supposed to show user
 images downloaded from web server using xmlrpc. The problem is that
 we cant quite figure out how to create a pixbuf from a buffer which
 contains the RAW contents of a file.

You can use GdkPixbufLoader to do that.

A sample implementation here (function get_pixbuf_from_image()):

https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/src/util.c?root=vagalumeview=markup

-- 
Alberto García González
http://people.igalia.com/berto/
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers