
-----------------------------------
Delos
Mon Jul 12, 2004 8:48 pm

Image Merger
-----------------------------------
Ok, here's some code that I posted somewhere in Submissions...but I thought I'd make it a bit more available.

This could be useful if you needed to merge two pics together, in a pseudo-Photoshop sort of way...


setscreen ("offscreenonly") 

var forePic, bgPic : int 

forePic := Pic.FileNew ("pic1.bmp") 
bgPic := Pic.FileNew ("pic2.bmp") 

Pic.Draw (forePic, 0, 0, picCopy) 

for i : 1 .. Pic.Width (forePic) 
    for j : 1 .. Pic.Height (forePic) 
    % These loops analyse each pixel in the foreground picture.

        if i mod 2 = 0 and j mod 2 = 0 then 
        % Select every other pixel.  Change this line to change the
        % pattern.

        /*
         Around here you can add lines like
         "if whatdotcolour (i,j) = 0 then"
         So that you can decide whether or not to follow through with the next line.
         */
            drawdot (i, j, colourbg) 
            % This clause draws the colourbg colour at alternating points, 
            % but this colour itself is entirely transparent! 
        end if 
    end for 
end for 

forePic := Pic.New (0, 0, Pic.Width (forePic), Pic.Height (forePic)) 
% Creates the resultant pic.

Pic.Draw (bgPic, 0, 0, picCopy) 
Pic.Draw (forePic, 20, 20, picMerge) 
% Merge the pictures together. 

%Pic.Draw (forePic, 20, 20, picXor) 
% For a spooooky effect. 

View.Update 


Don't forget to change the Pic.FileNew() parts...
It works better if the first pic is smaller than that second pic...

-----------------------------------
beard0
Wed Sep 01, 2004 8:49 pm


-----------------------------------
It's a neat program, though I must say that as a utilitarian program, it would be fairly limited.  You were right about the spookyness:

-----------------------------------
Delos
Wed Sep 01, 2004 10:16 pm


-----------------------------------
Try the same out w/ the...umm...'newer version' under Submissions.

[url=http://www.compsci.ca/v2/viewtopic.php?t=5905]Can't miss a plug!
