+ Reply to Thread
Results 1 to 11 of 11

Array to Image/Picture in Excel 64 bit

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Question Array to Image/Picture in Excel 64 bit

    I have searched, I have tested, I have tried converting various 32 bit code to 64 bit - all to no avail. So now I put it to the floor of ExcelForum:

    What code do I need to create a picture from an array when running Excel 64 bit?

    When I say 'create' - I am open to either/both of the following outputs:
    1. save an image file to a folder
    2. display an image in a form control

    The byte array contains the contents of a JPEG image file (I have been testing with JPEG formats however I may wish to use other formats in future).


    Could someone please provide code that is known to work for 64 bit Excel.
    Last edited by mc84excel; 06-23-2016 at 08:04 PM.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Array to Image/Picture in Excel 64 bit

    If you have working 32bit code why not post it?

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Array to Image/Picture in Excel 64 bit

    Quote Originally Posted by rorya View Post
    If you have working 32bit code why not post it?
    Well I could but I cant see how that will help. I have worked long and hard at converting array-to-image code (working in Office 32bit) to 64 bit and I have come to the conclusion that it cant be done.

    Which is why I am asking for a forum user to post code that they know works in 64bit 'out of the box' so to speak.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Array to Image/Picture in Excel 64 bit

    Sorry, I don't understand what the issue is? Writing a byte array to a file is 3 lines of standard code and no Apis, what are you having problems with?

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Array to Image/Picture in Excel 64 bit

    Quote Originally Posted by Kyle123 View Post
    Sorry, I don't understand what the issue is? Writing a byte array to a file is 3 lines of standard code and no Apis, what are you having problems with?
    Hi Kyle. Sorry for the delay in replying (I've been away last week). I have created a testing XLSM for you (or any other interested member) to test.

    Note that you need to add your working array-to-image function and call it from the userform before testing (you can see where this needs to go when you compile the project)
    Attached Files Attached Files

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Array to Image/Picture in Excel 64 bit

    Where's your non-working code?

    If all you're trying to do with it is get it into a picture, doesn't the following work?
    Please Login or Register  to view this content.
    Last edited by Kyle123; 07-01-2016 at 03:43 AM.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Array to Image/Picture in Excel 64 bit

    Nevertheless, here's a working example:

    Read byte array
    Please Login or Register  to view this content.
    In context:

    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Array to Image/Picture in Excel 64 bit

    Quote Originally Posted by Kyle123 View Post
    Where's your non-working code?

    If all you're trying to do with it is get it into a picture, doesn't the following work?
    Please Login or Register  to view this content.
    My fault Kyle. I can see how dumb that looks - I have a file picker... hey I can't load the picture!

    I should have explained that I created the tester workbook for testing purposes only. In the real world, I don't have a JPEG file as my starting input. Instead I am extracting an embedded JPEG out of another file. So my starting input is actually the byte array not the JPEG file itself! For the purposes of creating a test workbook, I skipped all the code before/after the crux of the problem and just whacked in a file picker -> byte array instead.
    Last edited by mc84excel; 07-03-2016 at 11:07 PM. Reason: clarify

  9. #9
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Array to Image/Picture in Excel 64 bit

    Quote Originally Posted by Kyle123 View Post
    In context:

    Please Login or Register  to view this content.
    Thanks Kyle +1 Well that certainly works!

    What I have been doing up to now is method/goal #2 (image byte array straight to userform picture control i.e. without writing to disk first). I have working code for that in 32 bit (using OLE and GDI) but I cant convert it to 64 bit.

    The code provided by Kyle works but I am still hankering for 64 bit compatible code for array-to-picture-control.
    For two reasons - 1) I think it would complete slightly faster (no overhead of write to/read from disk) and 2) I don't have to worry about killing the files when I'm done.
    Does anyone know how this can be done?

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Array to Image/Picture in Excel 64 bit

    Once again, for the cheap seats in the back, post your code - you really do enjoy making things difficult don't you :p

    Think though actually I'm gonna duck out now, I think you're adding loads of work for no real reason - premature optimisation is a waste of time, but I hope you get the answer you're looking for :D
    Last edited by Kyle123; 07-04-2016 at 03:03 PM.

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Array to Image/Picture in Excel 64 bit

    Quote Originally Posted by Kyle123 View Post
    Once again, for the cheap seats in the back, post your code - you really do enjoy making things difficult don't you :p
    I don't intend to make things difficult! It's my opinion that, in certain cases, posting code prevents a thread getting solved. I put a lot of effort & multiple attempts to convert OLE & GDI code to 64 bit with no result. Rather than try to patch over working 32 bit code, I figured it would be easier if someone already had working 64 bit code.

    Quote Originally Posted by Kyle123 View Post
    Think though actually I'm gonna duck out now, I think you're adding loads of work for no real reason - premature optimisation is a waste of time, but I hope you get the answer you're looking for :D
    I really appreciate the help you gave Kyle. I know it may appear a mite ungrateful to keep seeking the other solution now that you have provided me with a working option but for the projects that I most want this code for, any additional delay is something I want to avoid. Hence trying to avoid the disk in/out overhead.


    UPDATE: I am thinking I should close this thread and create a new separate thread for the problem of the Array-to-Picture-Control in 64 bit.
    Last edited by mc84excel; 07-04-2016 at 07:37 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 11-03-2014, 01:30 PM
  2. Copy an Image from a User form Picture Box to Worksheet Picture Box
    By sledgehammer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-07-2014, 11:39 AM
  3. Need help copying a picture/image from excel to the body of an outlook email
    By kadames27 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-15-2014, 10:17 AM
  4. Excel 2007 VBA Copy Range EXcluding Picture/Image
    By Hudas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2012, 12:20 AM
  5. Image (Picture) Issue
    By David De Rainville in forum Excel General
    Replies: 0
    Last Post: 09-14-2011, 12:30 PM
  6. [SOLVED] image & picture
    By Tom Rudski in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2005, 03:35 PM
  7. Replies: 0
    Last Post: 04-01-2005, 02:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1