Page 1 of 1

[Implemented] ConvertImage()

Posted: Sat Aug 04, 2012 10:32 am
by Phantomas
Implemented as EncodeImage()

Hello. Above all, sorry for my bad English. Subject:

Currently I can convert images (in BMP, JPEG, JPEG2000, PNG) only through SaveImage() function (with recording the output image in file).

I propose to add a new function called ConvertImage(). This function will convert image and write it in memory (RAM).

Like that:

Code: Select all

UseJPEGImageEncoder()
#img = 0
If CreateImage(#img, 32, 32)
  *memory_id = ConvertImage(#img, #PB_ImagePlugin_JPEG, 7)
  FreeImage(#img)
  If *memory_id
    ;done, now *memory_id — my JPEG image in memory
    FreeMemory(*memory_id)
  EndIf
EndIf
What you think?

Re: ConvertImage()

Posted: Sat Aug 04, 2012 10:44 am
by ts-soft
This make no sense, you have only a jpeg on filesystem but never in RAM. In RAM you have always the unpacked native OS-Format!
You can only show a image in native OS-Format.

Re: ConvertImage()

Posted: Sat Aug 04, 2012 11:12 am
by Fred
I think he wants to compress image in memory, for example sending it trough a socket without writing it to the disk.

Re: ConvertImage()

Posted: Sat Aug 04, 2012 12:16 pm
by Phantomas
Fred wrote:I think he wants to compress image in memory, for example sending it trough a socket without writing it to the disk.
Exactly!

With ConvertImage() we can more do much better. Another example:
Work with Image > ConvertImage() in JPEG > Edit Memory of Image (e.g., edit EXIF data) > Save Memory in file (create image).

Re: ConvertImage()

Posted: Sat Aug 04, 2012 4:56 pm
by luis
Under Windows you can save the image using a named pipe, if that's ok for you.
And the access the memory where the "saved" image is.

Re: ConvertImage()

Posted: Sat Aug 04, 2012 5:34 pm
by Polo
Could be useful, libjpeg and such probably support that?

Re: ConvertImage()

Posted: Mon Aug 06, 2012 10:12 am
by Phantomas
luis wrote:Under Windows you can save the image using a named pipe, if that's ok for you.
And the access the memory where the "saved" image is.
Yep, I also have this code.
But, I think this is "hack". Anyway, ConvertImage() would be more comfortably/easy/simple.