how do you export an image set ?

Hi all,
I have an image set (made of 3 pictures of different resolution)
there is a “make external” contextual menu on them
but it does not seems to do anything.
did I miss something ?
also you cannot export it, it does nothing.

As far as I understand, an image set is a simple picture with three stored images inside it.

Have a look at the Picture Class, Picture.ImageCount and you will start to understand.

Take a look at Picture.IndexedImage and the example code there.

I understand how it works, it’s just you can’t export it or make it external from the IDE.
(and use the same picture set in different apps)

These are in a module I call ImageSet

[code]Public Sub SaveSet(Extends Pic as picture, file As FolderItem, format As Integer = Picture.SaveAsPNG, quality As Integer = Picture.QualityDefault)

If Pic.ImageCount < 2 then
Pic.Save(file, format,Quality)
Return
End if

Dim ubImage as UInt16 = Pic.ImageCount-1

Dim FormatString As String

Select Case format
Case Picture.SaveAsMostCompatible,Picture.SaveAsMostComplete,Picture.SaveAsDefault, Picture.SaveAsDefaultRaster
#if TargetMacOS
FormatString = Picture.FormatPNG
#Else
FormatString = Picture.FormatBMP
#endif
Case Picture.SaveAsPNG
FormatString = Picture.FormatPNG
Case Picture.SaveAsJPEG
FormatString = Picture.FormatJPEG
Case Picture.SaveAsTIFF
FormatString = Picture.FormatTIFF
Case Picture.SaveAsWindowsBMP
FormatString = Picture.FormatBMP
Case Picture.SaveAsGIF
FormatString = Picture.FormatGIF
Else
Raise New UnsupportedFormatException
End Select

Dim Stream as BinaryStream = BinaryStream.Create(file, true)

Stream.WriteUInt64 XojoPict ’ “XojoPic” as ASCII codes
Stream.WriteUInt16 ubImage

Dim P as Picture
Stream.WriteUInt32 Pic.Width
Stream.WriteUInt32 Pic.Height

Dim PBlock as MemoryBlock

For i as Integer = 0 to ubImage
PBlock = Pic.IndexedImage(i).GetData(FormatString,quality)
Stream.WriteUInt32 PBlock.Size
Stream.Write PBlock
Next

PBlock = NIL
Stream.Close
End Sub
[/code]

[code]Protected Function Open(file As FolderItem) as Picture
DIm P as Picture = Picture.Open(file)

If NOT (P is NIL) Then Return P

Dim Stream as BinaryStream = BinaryStream.Open(file)

If Stream.ReadUInt64 <> XojoPict Then
Stream.Close
Return NIL
End if

Dim ubPic as UInt16 = Stream.ReadUInt16
Dim PicWidth as UInt32 = Stream.ReadUInt32
Dim PicHeight as UInt32 = Stream.ReadUInt32

Dim PSize As UInt32, PicArr() as Picture, i As Integer
ReDim PicArr(ubPic)

While NOt Stream.EOF
PSize =Stream.ReadUInt32
PicArr(i) = Picture.FromData(stream.Read(PSize))
i= i + 1
Wend

Return New PictureSet(PicWidth,PicHeight, PicArr)

End Function
[/code]

Better code than explanation.

Sorry, Iwas a bit short in my explanation. I meant “you can built your own set using…“.

[quote=356164:@Jean-Yves Pochez]Hi all,
I have an image set (made of 3 pictures of different resolution)
there is a “make external” contextual menu on them
but it does not seems to do anything.
did I miss something ?
also you cannot export it, it does nothing.[/quote]

export should work but if you’re finding its not file a report & I’ll have a peek

Thanks for sharing, can I make one little suggestion? Please set the littleEndian on the binary stream when reading and writing, this way if you even need to move between a processor that uses BigEndian and LittleEndian your code is already set.

Just a quick follow-up for future people reading this thread. TIFF, HEIF & JP2K all support multiple images in the same file. TIFF is an open format, the specification is available from Adobe, and it’s possible to create a reader/write from native Xojo code, it will be slow. But you could easily make the export function write out a multi-image TIFF file, and in theory you should be able to use Picture.open( tiffFile) and it should automagically load in all the representations.

<https://xojo.com/issue/50146>

<https://xojo.com/issue/50119>

=)
at least you now have a test project to verify the case …
… and my case also tells the “make external” does not work too.

Make external wasnt supposed to
That was filed & fixed in a separate case
Dont have the # handy