Jump to content


Photo

Loading Image Into Game Not Working


  • Please log in to reply
1 reply to this topic

#1 thespriteguy

thespriteguy

    GMC Member

  • New Member
  • 6 posts
  • Version:GM8

Posted 11 March 2012 - 09:24 PM

SOLVED: Kept remaking object untill it worked
Okay,
So I'm new to these forums...
What I'm trying to do is make an image editor. It works by using 1024 (32x32) objects. It runs fast and has pen, flood-fill, line, circle, rectangle and swap tools. You can also rotate and flip your image. You can also save your image. However, I'm having some trouble loading an image into it. I have tried replacing and adding sprites then using surface_getpixel, but it has always resulted in a black canvas. Any help would be appreciated.

The gmk file can be downloaded here:
http://www.mediafire.com/download.php?1hs8o1v0dnrde2m

My current codes for loading:

//in load object executed for itself
{
name=get_string("Load Image: (.pngs only!!!)",-1);
}

//in load object executed for itself
if (name != "")
then
{
if (file_exists(name+".png"))
then
{
sprite_replace(spr_test009,working_directory+name+".png\",0,0,0,0,0);
surf=surface_create(32,32);
surface_set_target(surf);
draw_sprite_stretched(spr_test009,0,0,0,32,32);
surface_reset_target();
}
}

//in load object executed for all obj_white_pixels
if ((obj_com_load).name != "")
then
{
if (file_exists((obj_com_load).name+".png"))
then
{
color=surface_getpixel((obj_com_load).surf,x/32,y/32);
}
}

Edited by thespriteguy, 11 March 2012 - 09:56 PM.

  • 0

#2 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1587 posts
  • Version:GM8.1

Posted 11 March 2012 - 09:33 PM

".png\" should only be ".png"

Also, many things could be happening. The pixel's code may be being executed before the loader's code.

Anyway, the best thing for you to do is try drawing that surface to the screen. This is a better way of drawing an editable image than objects, but more importantly, it will let you see where your problem is.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users