Jump to content


Photo

Preview In Browser Script Like In Photoshop


  • Please log in to reply
11 replies to this topic

#1 Mr. Limbojello

Mr. Limbojello

    Skater

  • GMC Member
  • 388 posts

Posted 23 October 2006 - 11:31 PM

Ok I was making a paint program when I develpoed this script. You know how in photoshop where theres the preview in browser feature? Well yea thats pretty much what I did. Its really easy to use and it only has four arguments so here it is.

But seriously looks can be deciving. This script is as easy as crap to use.
///////////////////////////////////////////////////////////////////
//Preview in browser script by Mr.Limbojello///////////////////////
///////////////////////////////////////////////////////////////////
//Argument0 = x to start the picture taking at/////////////////////
//Argument1 = the y to start taking picture at/////////////////////
//Argument2 = the width of the picture your taking a snapshot of///
//Argument3 = the height of the picture your taking a snapshot of//
///////////////////////////////////////////////////////////////////

direc=directory_create('C:\Documents and Settings\temp')
file=file_text_open_write('C:\Documents and Settings\temp\preview.html')
file_text_write_string(file,'<html>')
file_text_write_string(file,'<title>')
file_text_write_string(file,'Preview')
file_text_write_string(file,'</title>')
file_text_write_string(file,'<body>')
file_text_write_string(file,'<img src="pic.bmp" alt="pic">')
file_text_write_string(file,'</body>')
pic=screen_save_part('C:\Documents and Settings\temp\pic.bmp',argument0,argument1,argument2,argument3)
file_text_write_string(file,'</html>')
file_text_writeln(file)
file_text_close(file)
execute_shell('C:\Documents and Settings\temp\preview.html',0)

Now there is an example that comes with it so here is the download link.
Link to example

Well have fun
-Johnny

Edited by Mr. Limbojello, 24 October 2006 - 08:25 PM.

  • 0

#2 Mauros

Mauros

    GMC Member

  • New Member
  • 122 posts

Posted 24 October 2006 - 07:20 PM

Good!:medieval:
  • 0

#3 Knightmare

Knightmare

    OMGLOLWTFZORZ!1!1!!11

  • New Member
  • 867 posts
  • Version:Unknown

Posted 24 October 2006 - 07:49 PM

You know, adding multiple lines of file_text_write_string is actually pointless. You could either put them all together or add file_text_write_ln function.
  • 0

#4 arcooke

arcooke

    GMC Member

  • New Member
  • 1055 posts

Posted 24 October 2006 - 07:58 PM

There's no "temp" folder in documents and settings.

It's under c:\documents and settings\<user>\local settings\temp

Using the built-in temp_directory variable will remedy this.

Edited by adamsucks, 24 October 2006 - 08:00 PM.

  • 0

#5 Mr. Limbojello

Mr. Limbojello

    Skater

  • GMC Member
  • 388 posts

Posted 24 October 2006 - 08:16 PM

You know, adding multiple lines of file_text_write_string is actually pointless. You could either put them all together or add file_text_write_ln function.


Actually I didnt want it to get messy cause for me that often leads to errors. So I like to make multiple lines to avoid large lines of code.
@adamsucks
I know that. I was having problems with temp_directory so I decided to simulate that by creating a folder and deleting it at the end of the game.
  • 0

#6 OpticalLiam

OpticalLiam

    GMC Member

  • New Member
  • 782 posts

Posted 24 October 2006 - 08:18 PM

Fixed up the HTML and cleaned it a bit for you.

///////////////////////////////////////////////////////////////////
// Preview in browser script by Mr.Limbojello
///////////////////////////////////////////////////////////////////
// Argument0 = x to start the picture taking at
// Argument1 = the y to start taking picture at
// Argument2 = the width of the picture your taking a snapshot of
// Argument3 = the height of the picture your taking a snapshot of
///////////////////////////////////////////////////////////////////

direc=directory_create('C:\Documents and Settings\temp')
pic=screen_save_part('C:\Documents and Settings\temp\pic.bmp',argument0,argument1,argument2,argument3)
file=file_text_open_write('C:\Documents and Settings\temp\preview.html')
file_text_write_string(file,'<html>')
file_text_write_string(file,'<head>')
file_text_write_string(file,'<title>Preview</title>')
file_text_write_string(file,'</head>')
file_text_write_string(file,'<body>')
file_text_write_string(file,'<img src="pic.bmp" alt="pic">')
file_text_write_string(file,'</body>')
file_text_write_string(file,'</html>')
file_text_writeln(file)
file_text_close(file)
execute_shell('C:\Documents and Settings\temp\preview.html',0)

Edited by OpticalLiam, 24 October 2006 - 08:19 PM.

  • 0

#7 Mr. Limbojello

Mr. Limbojello

    Skater

  • GMC Member
  • 388 posts

Posted 24 October 2006 - 08:20 PM

Thanks man. Yea my coding is really sloppy but it works. Heh. Thanks again.
  • 0

#8 OpticalLiam

OpticalLiam

    GMC Member

  • New Member
  • 782 posts

Posted 24 October 2006 - 08:22 PM

Thanks man. Yea my coding is really sloppy but it works. Heh. Thanks again.

<{POST_SNAPBACK}>


Yea, you could get away with:

///////////////////////////////////////////////////////////////////
// Preview in browser script by Mr.Limbojello
///////////////////////////////////////////////////////////////////
// Argument0 = x to start the picture taking at
// Argument1 = the y to start taking picture at
// Argument2 = the width of the picture your taking a snapshot of
// Argument3 = the height of the picture your taking a snapshot of
///////////////////////////////////////////////////////////////////

direc=directory_create('C:\Documents and Settings\temp')
pic=screen_save_part('C:\Documents and Settings\temp\pic.bmp',argument0,argument1,argument2,argument3)
file=file_text_open_write('C:\Documents and Settings\temp\preview.html')
file_text_write_string(file,'<img src="pic.bmp" alt="pic">')
file_text_writeln(file)
file_text_close(file)
execute_shell('C:\Documents and Settings\temp\preview.html',0)

But for standards sakes, the other fluff is needed.
  • 0

#9 Ravotus

Ravotus

    GMC Member

  • GMC Member
  • 327 posts

Posted 24 October 2006 - 09:01 PM

Don't use a path like C:\Documents and Settings\temp. Documents and settings doesn't even exist under windows 9x. Use temp_directory.
  • 0

#10 Mr. Limbojello

Mr. Limbojello

    Skater

  • GMC Member
  • 388 posts

Posted 24 October 2006 - 11:18 PM

You could change the name.

Edited by Mr. Limbojello, 24 October 2006 - 11:27 PM.

  • 0

#11 the_mysterious_gamer

the_mysterious_gamer

    GMC Member

  • New Member
  • 431 posts

Posted 25 October 2006 - 06:18 PM

Why would anyone want that?
  • 0

#12 Mr. Limbojello

Mr. Limbojello

    Skater

  • GMC Member
  • 388 posts

Posted 25 October 2006 - 08:07 PM

Cause you can make sure the background color of the image fits in with that of the webpage, thats why I made it, or your own personal reasons.

Edited by Mr. Limbojello, 25 October 2006 - 08:08 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users