Jump to content


Photo

picture viewer/ importer


  • Please log in to reply
2 replies to this topic

#1 Rholad

Rholad

    GMC Member

  • GMC Member
  • 61 posts

Posted 06 July 2012 - 04:26 PM

I want to make a game where I can import pictures i take with my camera to game maker in game. For example: i just to a picture of my family..Now i plug my digital camera in and open my game maker game. Now i wish to left click on a box that will allow me to open up to a folder and file selection and i will be able to upload into that square in game. Is there a code for searching and selecting files i can use or an extension package i can use?
  • 0

#2 Johnjwj

Johnjwj

    Question.

  • GMC Member
  • 111 posts
  • Version:GM8

Posted 06 July 2012 - 06:21 PM

Here's an extract from the manual:

"To manipulate files in the file system you can use the following functions:


file_exists(fname) Returns whether the file with the given name exists (true) or not (false).
file_delete(fname) Deletes the file with the given name.
file_rename(oldname,newname) Renames the file with name oldname into newname.
file_copy(fname,newname) Copies the file fname to the newname.
directory_exists(dname) Returns whether the indicated directory does exist. The name must include the full path, not a relative path.
directory_create(dname) Creates a directory with the given name (including the path towards it) if it does not exist. The name must include the full path, not a relative path.
file_find_first(mask,attr) Returns the name of the first file that satisfies the mask and the attributes. If no such file exists, the empty string is returned. The mask can contain a path and can contain wildchars, for example 'C:\temp\*.doc'. The attributes give the additional files you want to see. (So the normal files are always returned when they satisfy the mask.) You can add up the following constants to see the type of files you want:

fa_readonly read-only files
fa_hidden hidden files
fa_sysfile system files
fa_volumeid volume-id files
fa_directory directories
fa_archive archived files

file_find_next() Returns the name of the next file that satisfies the previously given mask and the attributes. If no such file exists, the empty string is returned.
file_find_close() Must be called after handling all files to free memory.
file_attributes(fname,attr) Returns whether the file has all the attributes given in attr. Use a combination of the constants indicated above."


I would try looking for a extension first, but if don't find one that suits, I'd look for a code solution, using the functions above or from the rest of the "file" section in the manual.
  • 0

#3 Frigg

Frigg

    GMC Member

  • New Member
  • 94 posts

Posted 06 July 2012 - 06:40 PM

Use "get_open_filename" to retrieve the location of the picture.
Then use "sprite_add" or "background_add" to add the picture as a sprite or background
Then use "draw_sprite" or "draw_background" to draw the picture to the screen.

Code Snippet
Create
back = noone
When button pressed
var fname;
fname = get_open_filename('Images|*.bmp;*.png;*.jpg',"");
if(file_exists(fname))
    back = background_add(fname,0,0);
Draw
if(background_exists(back))
    draw_background(back,0,0);

Edited by Frigg, 06 July 2012 - 06:57 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users