Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Image Merger
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Delos




PostPosted: Mon Jul 12, 2004 8:48 pm   Post subject: 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...

code:

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...
Sponsor
Sponsor
Sponsor
sponsor
beard0




PostPosted: Wed Sep 01, 2004 8:49 pm   Post subject: (No subject)

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




PostPosted: Wed Sep 01, 2004 10:16 pm   Post subject: (No subject)

Try the same out w/ the...umm...'newer version' under Submissions.

Can't miss a plug!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: