0

I use the ExternalAccessory wrapper-based SDK to read the image source file with the following pseudo-code.

let read = buffer.withUnsafeMutableBytes { bufferPointer in
  self.sessionController.readFile(handle, data: bufferPointer, len: UInt32(min(remainingToRead, UInt64(bufferSize))))
}
            
if read == 0 {          
 completion(fileURL!, FileError.readFile)
 return // Read error      
}
remainingToRead -= UInt64(read)
fileHandle?.write(buffer)

What I want to achieve is that I read the file stream of the image thumbnail directly from the external device, not the file stream of the original image file, does anyone have a good solution for this?

I tried to read the image raw file and then compress it, but this will affect the speed of the image display.

Also, do I need to consider C language to process the file stream to implement this feature?

HangarRash
  • 7,314
  • 5
  • 5
  • 32
Kaaaaai
  • 113
  • 1
  • 10
  • What image thumbnail? Thumbnails are generated dynamically by file browsers. – Paulw11 Feb 01 '23 at 04:36
  • @Paulw11 The principle of thumbnail generation, as I understand it, is that if the image is 120*120 pixels, the whole image is divided equally by 9*9, and each area takes one pixel in the middle and combines it into one image, which is the thumbnail, but I want to know how the file stream is done. – Kaaaaai Feb 01 '23 at 07:39
  • My point is there isn't some separate "thumbnail data" you can access on the external device. You need to read the image data and generate the thumbnail image or access the thumbnail data if it is present in a file like a jpeg. e.g. https://stackoverflow.com/questions/10349622/extract-thumbnail-from-jpeg-file – Paulw11 Feb 01 '23 at 07:55
  • @Paulw11 Thank you very much, very helpful, but after reading all the answers, it feels like there is still a slight possibility of achieving it, although it's difficult, so if no other answers appear, I'll continue with the old solution. – Kaaaaai Feb 01 '23 at 08:51

0 Answers0