

TBitmap can wrap these with a TCanvas and thus provide access to most of the functionality of the GDI through the canvas.Īdditionally almost all other formats can convert to and from TBitmap so there's no reason why all the other formats should duplicate the functionality in TBitmap/TCanvas/GDI.
FORMAT BLOB IMAGE DELPHI WINDOWS
TBitmap on the other hand implements the BMP encoding and is internally represented as a native Windows DIB or DDB. They are not optimized to handle image manipulation. Their internal representation is optimized to handle the features of the file format. The sole purpose of TPNGImage, TJPEGImage and TGIFImage is to read, write and display these formats. The Blob interface’s stream() method returns a ReadableStream which upon reading returns the data contained within the blob.Do you know what the reason might be for that design decision?īMP, PNG, JPEG, GIF etc.

You can easily create a ReadableStream from a blob.

And what’s more important – we can use this encoding in “data-urls”.Ī data url has the form data. That encoding represents binary data as a string of ultra-safe “readable” characters with ASCII-codes from 0 to 64. Blob to base64Īn alternative to URL.createObjectURL is to convert a Blob into a base64-encoded string. After the revocation, as the mapping is removed, the URL doesn’t work any more. In the previous example with the clickable HTML-link, we don’t call URL.revokeObjectURL(link.href), because that would make the Blob url invalid. In the last example, we intend the Blob to be used only once, for instant downloading, so we call URL.revokeObjectURL(link.href) immediately. URL.revokeObjectURL(url) removes the reference from the internal mapping, thus allowing the Blob to be deleted (if there are no other references), and the memory to be freed. So if we create a URL, that Blob will hang in memory, even if not needed any more. But if an app is long-living, then that doesn’t happen soon. The mapping is automatically cleared on document unload, so Blob objects are freed then. While there’s a mapping for a Blob, the Blob itself resides in the memory. And it allows to reference the Blob in, , basically any other object that expects a URL. So such URLs are short, but allow to access the Blob.Ī generated URL (and hence the link with it) is only valid within the current document, while it’s open. For each URL generated by URL.createObjectURL the browser stores a URL → Blob mapping internally.
