Alpha Video Training
Results 1 to 6 of 6

Thread: image file from clipboard data

  1. #1
    Member
    Real Name
    John Michaels
    Join Date
    May 2013
    Posts
    54

    Default image file from clipboard data

    Code:
    	dim cc as C
    	dim bb as B
    	cc = clipboard.Get_Data(8)	
    	bb = char_to_blob(cc)	
    	file.From_blob(vyg_lbl_folder+"import.bmp",bb)
    From MS Paint I cut an image (to clipboard). I'm trying to get that clipboard data to an image file. I've been through the docs and the MB looking and trying various things and I just can't get it. Neither cc as C or B works. The "*" parameter is because the docs list this as bitmap data. No joy. Can anyone point me in the right direction please. Much appreciated.
    John Michaels
    "The only thing needed for evil to flourish is for good men to do nothing" - great quote but probably not Sir Edmund Burke

  2. #2
    "Certified" Alphaholic Ronald Anusiewicz's Avatar
    Real Name
    Ronald Anusiewicz
    Join Date
    Oct 2000
    Location
    Southampton, MA
    Posts
    1,583

    Default Re: fimage file from clipboard data

    Years ago I did something similar however I used files. My script would open microsoft excel, copy a range of cells from a workbook page to the clipboard, paste the clipboard into paint, save the paint as a file and then enter the file into a field in a table.

    I found this in the help files. It worked perfectly. This may be a viable option.

    <FIELD>.MEMO_READ_FROM_FILE()
    Syntax
    <FIELD>.MEMO_READ_FROM_FILE( Filename as C [, Flag as N ] )
    <TABLE>.<FIELD>.MEMO_READ_FROM_FILE( Filename as C [, Flag as N ] )
    Argument
    Description

    Filename
    A fully qualified file name.

    Flag
    Optional.

    Default = "" (Overwrite memo).

    MEMO_APPEND = Appends Filename to the existing memo, rather than overwriting it.


    Description

    The <FIELD>.MEMO_READ_FROM_FILE() method transfers the contents of a file to the memo or bitmap field referenced by the <FIELD> object pointer.

    This function is especially useful for putting Windows Bitmap files (.BMP) into bitmap image fields.

    Flag is an optional parameter that you can specify in the case of memo fields (not bitmap fields) to append the contents of the file to the existing memo, rather than overwriting it.

    Supported By Alpha Five Version 5 and Above

    Example
    This script inserts the selected bitmap file into the Picture field in a new record in the Library table.

    dim tbl as P
    filename = ui_get_file("Choose Bitmap", "Bitmaps(*.BMP)","","X")
    if (filename = "") then
    end
    end if

    tbl = table.current()
    tbl.enter_begin()
    tbl.description = filename
    tbl.picture.memo_read_from_file(filename)
    tbl.enter_end(.T.)
    parent.resynch()

  3. #3
    Member
    Real Name
    John Michaels
    Join Date
    May 2013
    Posts
    54

    Default Re: fimage file from clipboard data

    Ron, good to know about that method, but I am starting from cutting image data to the clipboard, wanting that data on the clipboard to get into an image file using xbasic.
    John Michaels
    "The only thing needed for evil to flourish is for good men to do nothing" - great quote but probably not Sir Edmund Burke

  4. #4
    "Certified" Alphaholic Ted Giles's Avatar
    Real Name
    Ted Giles
    Join Date
    Aug 2000
    Location
    In the Wolds, Louth, Lincolnshire, UK
    Posts
    4,363

    Default Re: fimage file from clipboard data

    Look at the Clipboard actions you can use. The clipboard contains whatever you have copied.

    Description

    The CLIPBOARD.GET_DATA() method gets data from the clipboard and stores it in Variable. The type of data retrieved from the clipboard is determined by Clipboard_Format. You can register a new Clipboard_Format value with the CLIPBOARD.REGISTER_TYPE() method.

    Supported By

    Alpha Five Version 5 and Above

    Limitations

    Desktop applications only.

    Example

    This script puts the record into change mode and writes data from the clipboard into the account_number field.

    tbl = table.current()

    tbl.change_begin()

    tbl.account_number = :clipboard.get_data()

    tbl.change_end(.T.)


    See Also

    CLIPBOARD Methods
    Ted Giles
    Example Consulting - UK
    .

    http://ec12.example-software.com//
    See our site for Alpha Support, Conversion and Upgrade.

  5. #5
    "Certified" Alphaholic Ronald Anusiewicz's Avatar
    Real Name
    Ronald Anusiewicz
    Join Date
    Oct 2000
    Location
    Southampton, MA
    Posts
    1,583

    Default Re: fimage file from clipboard data

    John, I seem to recall trying to do this myself back in December 2011. For some reason I do not think I could get this to work. Hence, I took the file method. I do have a post dated 1-18-12 called "file.to_blob code works in Windows XP, doesn't work in Windows 7".

    I posted a test sample that you may want to down load and try. I don't remember all the details.

    Ron

  6. #6
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Grand Rapids, Michigan
    Posts
    4,200

    Default Re: fimage file from clipboard data

    I came upon this thread, and since I had been part of the one Ron referenced without providing any help there, I thought I better do better. I found this great intermediary function that allows the clipboard data to be previewed, adjusted, and then capable of being made into a bmp or jpg file. Heck I've got lot's of uses for this!! Into the code library with this one!

    Steps: Cut an image to the clipboard and run this script

    Code:
    'set the file to be made from the clipboard image data
    	dim vf_new as C="C:\text_clip.jpg"
    	
    'acquire the image data from the clipboard, 
    	dim vblb as b
    	vblb=clipboard.Get_Data(8)
    	b2 = a5_image_transform(vblb)            ' <<<--- fun new function I found
    	
    'convert to jpg file
    	dim vjpg as B
    	vjpg = bitmap_to_jpeg(b2)
    	file.From_blob(vf_new,vjpg)
    
    'Query user to preview new jpg image file
    	dim vnR as N
    	vnR=ui_msg_box("PREVIEW IMAGE FILE","Preview the new image file now?",65)
    		if vnR=2
    			end
    		end if
    
    'load the selected image and view in dialog  
    	dim inow as C
    	dim rgb_data as B
    	f = file.open(vf_new,FILE_RO_SHARED)
    	ui_bitmap_load("inow",f.readb(10000000))
    	f.close()
    
    	ui_dlg_box("Image Preview",<<%dlg%
    	{lf};
    	{image=inow};
    	{lf};
    	<OK>;
    	%dlg%)
    Last edited by Mike Wilson; 11-24-2013 at 05:15 PM.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

Similar Threads

  1. Delete Image: Image File Reference fields & File
    By MarcP in forum Application Server Version 11 - Web/Browser Applications
    Replies: 1
    Last Post: 03-06-2012, 04:38 PM
  2. Data entry for Image File Reference field
    By Sandy Garrett in forum Alpha Five Version 8
    Replies: 6
    Last Post: 10-27-2009, 09:39 PM
  3. Could not create temporary file containing data from the Image field. Server issue.
    By peteconway in forum Application Server Version 9 - Web/Browser Applications
    Replies: 2
    Last Post: 03-27-2009, 05:42 PM
  4. Trimming Clipboard Data
    By Ed Merritt in forum Alpha Five Version 9 - Desktop Applications
    Replies: 2
    Last Post: 01-31-2009, 03:23 PM
  5. Paste image from clipboard
    By Steve Eyler in forum Alpha Five Version 5
    Replies: 8
    Last Post: 07-23-2004, 02:25 AM

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
  •