vb.net - Display Metadata-thumbnail of Jpeg in picturebox -


i need display image's thumbnail, saved in metadata in picturebox. i'm using vb.net

http://msdn.microsoft.com/en-us/library/windows/desktop/ee719904%28v=vs.85%29.aspx#_jpeg_metadata

so far came this. adding breakpoint displays getquery returns empty if know file indeed have thumbnail

    private sub form1_load(sender system.object, e system.eventargs) handles mybase.load     dim imagepath = "c:\xampp\htdocs\downloads\img_1322.jpg" ' path file     dim stream = new filestream(imagepath, filemode.open, fileaccess.read, fileshare.readwrite)     dim decoder = new jpegbitmapdecoder(stream, bitmapcreateoptions.none, bitmapcacheoption.none)     dim metadata = trycast(decoder.frames(0).metadata, bitmapmetadata)      dim ms new system.io.memorystream      dim bm bitmap     dim ardata() byte      ardata = metadata.getquery("/app0/{ushort=6}") '<--- breakpoint here: query returns nothing!       ms.write(ardata, 78, ardata.length - 78)      bm = new bitmap(ms)      picturebox1.image = bm     stream.close()  end sub 

you can try this:

private sub form1_load(sender system.object, e system.eventargs) handles mybase.load     dim imagepath = "c:\xampp\htdocs\downloads\img_1322.jpg" ' path file     dim stream = new filestream(imagepath, filemode.open, fileaccess.read, fileshare.readwrite)     dim decoder = new jpegbitmapdecoder(stream, bitmapcreateoptions.none, bitmapcacheoption.none)     dim metadata = trycast(decoder.frames(0).metadata, bitmapmetadata)      dim thumb bitmapmetadatablob     thumb = metadata.getquery("/app1/thumb/")     if not (thumb nothing)         dim src new bitmapimage         dim ms memorystream = new memorystream(thumb.getblobvalue())         src.begininit()         src.streamsource = ms         src.endinit()         picturebox1.source = src     end if     stream.close()  end sub 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -