[Implemented] ConvertImage()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Phantomas
User
User
Posts: 96
Joined: Wed Jul 01, 2009 12:59 pm

[Implemented] ConvertImage()

Post 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?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: ConvertImage()

Post 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.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Fred
Administrator
Administrator
Posts: 18161
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: ConvertImage()

Post by Fred »

I think he wants to compress image in memory, for example sending it trough a socket without writing it to the disk.
Phantomas
User
User
Posts: 96
Joined: Wed Jul 01, 2009 12:59 pm

Re: ConvertImage()

Post 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).
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: ConvertImage()

Post 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.
"Have you tried turning it off and on again ?"
A little PureBasic review
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: ConvertImage()

Post by Polo »

Could be useful, libjpeg and such probably support that?
Phantomas
User
User
Posts: 96
Joined: Wed Jul 01, 2009 12:59 pm

Re: ConvertImage()

Post 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.
Post Reply