Author Topic: Fast Image Copy-Paste Routine  (Read 5064 times)

0 Members and 1 Guest are viewing this topic.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Fast Image Copy-Paste Routine
« on: April 12, 2010, 04:09:56 pm »
So I recently made a copy and pasting program, some of you may know that already, but Builderboy gave me a idea about a different way of doing it that just has more restrictions. So since it is a pretty simple routine I came up with I thought I would share it here for anyone interested.

Note:
Really the only drawback with this method is that if you need to move the image somewhere where it would overlap the original position it will not work properly (sometimes it will, depending on the image; I may give an example of both).


Ok, the code for it:

Code: [Select]
For(A,Y',Y") //Y' is the starting Y coordinate and Y" is the ending.
For(B,X',X") //Same deal. X' is starting X coordinate and X" is the ending coordinate.
If pxl-Test(A,B
pxl-On(A±C,B±D //C and D are used to shift the image into the spot you want. Say the image is at (32,36) and
pxl-Off(A,B    //you want it at (0,0). C would equal -32 and D would be -36.
End
End

I hope this makes sense and is helpful to someone. I'll go over it later and try to show an example of when a pic can overlap coordinates, if I can manage it. Enjoy.

Edit:
I made it so that restriction is no longer applicable.
« Last Edit: April 12, 2010, 04:46:07 pm by meishe91 »
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Fast Image Copy-Paste Routine
« Reply #1 on: April 12, 2010, 10:39:51 pm »
Nice, it might come useful for moving sprites around in a sprite sheet when you don't have xLIB, CODEX or Celtic handy. It might be best if you added Input Y':Input Y":Input X':Input X" at the beginning, though, for more user-friendliness :P

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Fast Image Copy-Paste Routine
« Reply #2 on: April 12, 2010, 10:43:37 pm »
Well this is just the routine that does the work that I thought someone could just type in real fast when needed. I'm probably going to implement this method into my copy-paste program because this is smaller and more efficient.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Fast Image Copy-Paste Routine
« Reply #3 on: April 12, 2010, 11:35:40 pm »
Aaah ok, I just thought it might be better for user-friendliness. It's up to you, though.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Fast Image Copy-Paste Routine
« Reply #4 on: April 13, 2010, 12:08:39 am »
Well I mean I could its just that either way the person will have to type the program in manually because I don't plan to post a program file for that is all. They could just add it themselves. The reasons I put the variables there isn't to be used in the program but to be substituted for those values. I don't know if that makes sense but ya.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Fast Image Copy-Paste Routine
« Reply #5 on: April 13, 2010, 12:21:59 am »
Aaah ok I understand :)

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Fast Image Copy-Paste Routine
« Reply #6 on: April 13, 2010, 06:12:23 pm »
I figured out today that if speed is more important then use this. It just is a added Then and End, oh and take the parentheses off the For('s. It doesn't make it a whole lot faster but it is faster none the less :P It is only two bytes bigger too. So yup. Works the same way.

Code: [Select]
For(A,Y',Y" //Y' is the starting Y coordinate and Y" is the ending.
For(B,X',X" //Same deal. X' is starting X coordinate and X" is the ending coordinate.
If pxl-Test(A,B
Then
pxl-On(A±C,B±D //C and D are used to shift the image into the spot you want. Say the image is at (32,36) and
pxl-Off(A,B    //you want it at (0,0). C would equal -32 and D would be -36.
End
End
End
« Last Edit: April 13, 2010, 06:13:20 pm by meishe91 »
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Fast Image Copy-Paste Routine
« Reply #7 on: April 13, 2010, 06:38:48 pm »
Mhmm right I forgot about that part x.x

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Fast Image Copy-Paste Routine
« Reply #8 on: April 13, 2010, 06:54:12 pm »
What part?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Fast Image Copy-Paste Routine
« Reply #9 on: April 13, 2010, 07:34:18 pm »
the optimization you just did. I didn't realize about it until you posted it, even thought I did that before x.x

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Fast Image Copy-Paste Routine
« Reply #10 on: April 13, 2010, 07:47:06 pm »
Oh lol, ok. It doesn't make a huge difference in speed, about a second according to the timer fuction, but never tested with super big area.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)