SRL Archive - General

auto colage


g0tp0t

2010-03-19 10:33:04

i need to make a colage(a bunch of pics pasted on a poster.) for class and i decided to do it with scar. heres my code that doesnt work :/

program New;

var i:integer;pic,npic: array of integer;
procedure Declareanddraw;
begin
wait(1000) //so i can pause and go through line by line before error
for i := 0 to 9 do
pic[i] := Loadbitmap('C:\bit\images_00'+inttostr(i)+'.bmp'); //load bmps into array
FastDrawTransparent(random(150)*i,random(150)*i,pic[i],npic[i]); //The higher i is the forther the pic will be drawn
//instead of drawing them on top of each other
||
for i := 10 to 19 do // \/------- since the filename has a three digit number i had to remove a 0
pic[i] := Loadbitmap('C:\bit\images_0'+inttostr(i)+'.bmp');
FastDrawTransparent(random(150)*i,random(150)*i,pic[i],npic[i]);
end;

begin
declare
end.

and i get this error:

Successfully compiled (57 ms)
[Runtime Error] : Out Of Range in line 8 in script

g0tp0t

2010-03-19 10:42:49

Got to turn this in today, any ideas? please post

nielsie95

2010-03-19 11:10:15

You have to set the length of your array before using it.

Quickmarch

2010-03-19 11:20:59

Remember to free your bitmaps aswell. ;)

nielsie95

2010-03-19 11:30:34

And load the target bitmaps ;)

g0tp0t

2010-03-19 11:38:50

k, I'm doing that now

Nava2

2010-03-19 11:39:47

SetLength(pics, 20); // at the beginning
for i := 0 to 19 do // at the end
FreeBitmap(pics[i]);

g0tp0t

2010-03-19 11:43:23

Now I have this:
program New;

var i:integer;pic,npic: array of integer;
procedure Declareanddraw;
begin
wait(1000) //so i can pause and go through line by line before error
for i := 0 to 9 do
pic[i] := Loadbitmap('C:\bit\images_00'+inttostr(i)+'.bmp'); //load bmps into array
FastDrawTransparent(random(150)*i,random(150)*i,pic[i],npic[i]); //The higher i is the forther the pic will be drawn
//instead of drawing them on top of each other
||
for i := 10 to 19 do // \/------- since the filename has a three digit number i had to remove a 0
pic[i] := Loadbitmap('C:\bit\images_0'+inttostr(i)+'.bmp');
FastDrawTransparent(random(150)*i,random(150)*i,pic[i],npic[i]);
end;

begin
declare
end.

Which gives me this:

Line 4: [Error] (4:4): colon (':') expected in script

EDIT: i added navas suggestion and still same exact error

MylesMadness

2010-03-19 16:22:08

program New;
var
i:integer;
pic,npic: array of integer;

procedure Declareanddraw;
begin
for i := 0 to 9 do
begin
pic[i] := Loadbitmap('C:\bit\images_00'+inttostr(i)+'.bmp');
FastDrawTransparent(random(150)*i,random(150)*i,pic[i],npic[i]);
end;
for i := 10 to 19 do
begin
pic[i] := Loadbitmap('C:\bit\images_0'+inttostr(i)+'.bmp');
FastDrawTransparent(random(150)*i,random(150)*i,pic[i],npic[i]);
end;
end;

begin
declareanddraw;
end.

Diddy Kong

2010-03-19 19:39:50

Just get a flippin poster and paste. You said that it to be done on a poster.

Camaro'

2010-03-19 22:14:54

From: Diddy Kong
Just get a flippin poster and paste. You said that it to be done on a poster.


It doesn't matter about that, he asked for scar help, if you don't know how to help him, please don't post.

g0tp0t

2010-03-24 20:23:18

When i said a bunch of pictures 'pasted to a poster' i was trying to give an idea of what i was trying to do.

i am trying Your code now, Ill edit in a sec

——

Myles, your code gives me this…


Successfully compiled (43 ms)
[Runtime Error] : Out Of Range in line 10 in script

MylesMadness

2010-03-24 20:39:29

program New;
var
i:integer;
pic,npic: array of integer;

procedure Declareanddraw;
begin
SetArrayLength(pic, 20);
for i := 0 to 19 do
begin
pic[i] := Loadbitmap('C:\bit\images_0'+Replicate('0', 2-length(inttostr(i)))+inttostr(i)+'.bmp');
FastDrawTransparent(random(150)*i,random(150)*i,pic[i],npic[i]);
end;
end;

begin
declareanddraw;
end.

Timer

2010-03-24 20:47:26

program SlideShow;

var
i, lx, ly, tx, ty: Integer;
pic: array of Integer;

procedure Declareanddraw;
begin
SetLength(pic, 20);
for i := 0 to 9 do
begin
pic[i] := Loadbitmap('C:\bit\images_00'+inttostr(i)+'.bmp');
GetBitmapSize(pic[i], tx, ty);
if (tx > lx) then
lx := tx;
if (ty > ly) then
ly := ty;
SafeDrawBitmap(pic[i], GetDebugCanvas, random(150),random(150));
Wait(1000 + Random(500));
end;
for i := 10 to 19 do
begin
pic[i] := Loadbitmap('C:\bit\images_0'+inttostr(i)+'.bmp');
SafeDrawBitmap(pic[i], GetDebugCanvas, random(150),random(150));
Wait(1000 + Random(500));
end;
for i := 0 to High(pic) do
try
FreeBitmap(pic[i]);
except
end;
end;

begin
DisplayDebugImgWindow(600, 600);
declareanddraw;
Writeln('Please change line 36 into: ' + Chr(13) +
'DisplayDebugImgWindow(' + IntToStr(lx + 150) + ', ' + IntToStr(ly + 150) + ');');
end.

try that

g0tp0t

2010-03-24 22:09:14

Timers program works!!!!!! kinda

it ran and the pictures were extremely spaced, and only the first 4 pics showed the first time i ran.

The second time it was perfect. How would it resize the pics randomly… is that even possible with scar?? and a random angle between -15 and 15 degrees would make it look more natural. neither of those i know how to do in the debug window.

i luffs yeww

2010-03-24 22:21:22

Those are both possible. :) the resizing would just be getting the dimensions and multiplying that by a decimal, I think. And rotating would just be a for loop along with RotatePoint.

I think. :p

g0tp0t

2010-03-24 22:32:50

[PHP]program SlideShow;

var
i, n, lx, ly, tx, ty: Integer;
pic: array of Integer;

procedure Declareanddraw;
begin
SetLength(pic, 20);
for i := 2 to 9 do
begin
pic := Loadbitmap('C:\bit\images_00'+inttostr(i)+'.bmp');
GetBitmapSize(pic, tx, ty);
if (tx > lx) then
lx := tx;
if (ty > ly) then
ly := ty;
SafeDrawBitmap(pic, GetDebugCanvas, random(150)*(random(9)+1),random(150)*(random(9)+1));
Wait(10 + Random(20));
end;
for i := 10 to 18 do
begin
pic := Loadbitmap('C:\bit\images_0'+inttostr(i)+'.bmp');
SafeDrawBitmap(pic, GetDebugCanvas, random(150)*(random(9)+1),random(150)*(random(9)+1));
Wait(10 + Random(20));
end;
for i := 0 to High(pic) do
try
FreeBitmap(pic);
except
end;
end;

begin
DisplayDebugImgWindow(600, 600);
for n := 1 to 50 do
begin
declareanddraw;
ClearReport;
AddToReport(inttostr(n));
end;

Writeln('Please change line 36 into: ' + Chr(13) + //whats this for? lol
'DisplayDebugImgWindow(' + IntToStr(lx + 150) + ', ' + IntToStr(ly + 150) + ');');
//how do I copy and save the debug image??
end.[/PHP]

i sped it up and made it repeat 50 times to eliminate black spots… all i need now is to save it to bmp.

Timer owns!!

Timer

2010-03-24 22:36:50

need any more help with it?

g0tp0t

2010-03-24 22:36:54

From: i luffs yeww
Those are both possible. :) the resizing would just be getting the dimensions and multiplying that by a decimal, I think. And rotating would just be a for loop along with RotatePoint.

I think. :p


rotate point? is that srl or scar?

and if i multiply the dimensions by a random value, then instead of resizing… wouldnt that just trim the pic? i was thinking something like a for loop inside a for loop to copy certain pixels into another bmp, Which would scale the pic… but i dont know how to retrieve a single point either :P


===========

need any more help with it?

lol, the last semi-important piece is saving to bmp from debug. if it isn't possible i can just use print-screen button on keyboard and print it that way. But that's kinda like cheating :P

i also want help with resizing and rotating the pics randomly to make it look less perfect, but this last little part is optional, to make it i little higher quality, ill post the result in a min.



ill edit the edges of the pics in photoshop to make them look faded/torn too. i don't need help with that though

Timer

2010-03-24 22:53:51

can i get access to your images?

edit:
add this before end.
SaveBitmap(GetDebugCanvas, 'C:\bit\thecollage.bmp');
so it looks like,
...stuff
SaveBitmap(GetDebugCanvas, 'C:\bit\thecollage.bmp');
end.

i luffs yeww

2010-03-24 23:15:50

RotatePoint is in the WizzyPlugin, I think. I didn't really expect you to know what to do with it, more so just giving ideas to anyone who would help. ;)

g0tp0t

2010-03-24 23:21:23

LOL, just telling me where i might find it is a big help, maybe i can figure out how to use it, lol.


Yes, i will attach them all, but they were all off the first page in Google images so there isn't a ton, lol, I'm getting more after i take a shower. lol

g0tp0t4u2share.t35.com

ftp pass is hitthebong

Sorry for not just linking to it lol im too lazy right now to get each link but the 7zip file is g0tp0t4u2share.t35.com/bit.7z and all images are in the same directory as the 7zip file i just linked, named 001-018 like in script

Back

=========

May 26:

i have to work on this same thing for school again, :\. lol. so not a gravedig because the posts above this are usefull :P.

i like it and am trying to create a tpointarray from text or somehow draw text on the bottom of each image which is generated. i also want to make the pictures not cover other images as much. im failing so far :'{


Just realized that happened to be a double post. ill post the code i have edited :]