From be802dafb09e2cf62788faa8afca6e9284a977f0 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Sat, 11 Aug 2012 21:13:05 -0500 Subject: [PATCH] Added experimental AddEffect method to the frame object, to apply image effects --- include/Frame.h | 24 +++++++++++++----------- src/Frame.cpp | 13 +++++++++++++ src/Main.cpp | 5 ++++- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/include/Frame.h b/include/Frame.h index ffde306b..b62316f6 100644 --- a/include/Frame.h +++ b/include/Frame.h @@ -68,6 +68,15 @@ namespace openshot /// Assignment operator Frame& operator= (const Frame& other); + /// Add (or replace) pixel data to the frame + void AddImage(int width, int height, const string map, const Magick::StorageType type, const void *pixels_); + + /// Add audio samples to a specific channel + void AddAudio(int destChannel, int destStartSample, const float* source, int numSamples, float gainToApplyToSource); + + /// Experimental method to add effects to this frame + void AddEffect(string name); + /// Copy data and pointers from another Frame instance void DeepCopy(const Frame& other); @@ -104,12 +113,6 @@ namespace openshot /// Get pixel data (for a resized image) const Magick::PixelPacket* GetPixels(unsigned int width, unsigned int height, int frame); - /// Set Pixel Aspect Ratio - void SetPixelRatio(int num, int den); - - /// Set Sample Rate, used for playback (Play() method) - void SetSampleRate(int sample_rate); - /// Get height of image int GetHeight(); @@ -119,15 +122,14 @@ namespace openshot /// Save the frame image to the specified path. The image format is determined from the extension (i.e. image.PNG, image.JPEG) void Save(string path, float scale); - /// Add (or replace) pixel data to the frame - void AddImage(int width, int height, const string map, const Magick::StorageType type, const void *pixels_); + /// Set Pixel Aspect Ratio + void SetPixelRatio(int num, int den); - /// Add audio samples to a specific channel - void AddAudio(int destChannel, int destStartSample, const float* source, int numSamples, float gainToApplyToSource); + /// Set Sample Rate, used for playback (Play() method) + void SetSampleRate(int sample_rate); /// Play audio samples for this frame void Play(); - }; } diff --git a/src/Frame.cpp b/src/Frame.cpp index c7cb8524..6026292a 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -435,6 +435,19 @@ void Frame::AddAudio(int destChannel, int destStartSample, const float* source, audio->addFrom(destChannel, destStartSample, source, numSamples, gainToApplyToSource); } +// Experimental method to add effects to this frame +void Frame::AddEffect(string name) +{ + if (name == "negate") + image->negate(false); + else if (name == "flip") + image->flip(); + else if (name == "oilPaint") + image->oilPaint(3.0); + else if (name == "swirl") + image->swirl(30.0); +} + // Play audio samples for this frame void Frame::Play() { diff --git a/src/Main.cpp b/src/Main.cpp index 2ef6318a..b2d15bd3 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -62,10 +62,13 @@ int main() // Output stream info w.OutputStreamInfo(); - for (int frame = 1; frame <= 500; frame++) + for (int frame = 300; frame <= 450; frame++) { Frame f = r.GetFrame(frame); + // Apply effect + f.AddEffect("oilPaint"); + // Write frame cout << "Write frame " << f.number << endl; w.WriteFrame(&f);