From 4646aea99f60b899315df494c1ebfadc72bc57f8 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Tue, 11 Oct 2011 23:20:26 -0500 Subject: [PATCH] Fixed a bug with the SDL YUV420p color conversion. Locally scoped Image was going out of scope, before I could get the colors completly out of it. Race condition. --- include/Frame.h | 1 + src/Frame.cpp | 11 +++++++---- src/Player.cpp | 12 ++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/Frame.h b/include/Frame.h index 61655b4f..cab26cb8 100644 --- a/include/Frame.h +++ b/include/Frame.h @@ -31,6 +31,7 @@ namespace openshot { private: Magick::Image *image; + Magick::Image *small_image; juce::AudioSampleBuffer *audio; public: diff --git a/src/Frame.cpp b/src/Frame.cpp index 9ec407c4..e64de1b9 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -139,15 +139,18 @@ const Magick::PixelPacket* Frame::GetPixels(int row) const Magick::PixelPacket* Frame::GetPixels(unsigned int width, unsigned int height, int frame) { // Create a new resized image - Magick::Image newImage = *image; - newImage.resize(Magick::Geometry(width, height)); + //Magick::Image newImage = *image; + small_image = new Magick::Image(*(image)); + small_image->resize(Magick::Geometry(width, height)); + small_image->colorize(255, 0, 0, Magick::Color(0,0,255)); + small_image->blur(5.0, 5.0); stringstream file; file << "frame" << frame << ".png"; - newImage.write(file.str()); + small_image->write(file.str()); // Return arry of pixel packets - return newImage.getConstPixels(0,0, newImage.columns(), newImage.rows()); + return small_image->getConstPixels(0,0, small_image->columns(), small_image->rows()); } // Get height of image diff --git a/src/Player.cpp b/src/Player.cpp index 5907796c..ad7b1139 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -145,12 +145,12 @@ for (int stuff = 0; stuff < number_of_cycles; stuff++) const Magick::PixelPacket *pixel = reduced_color; // Get the RGB colors -// float r = pixel[pixel_index].red / 255.0; -// float b = pixel[pixel_index].blue / 255.0; -// float g = pixel[pixel_index].green / 255.0; - float r = 100.0; - float g = 100.0; - float b = 100.0; + float r = pixel[pixel_index].red / 255.0; + float b = pixel[pixel_index].blue / 255.0; + float g = pixel[pixel_index].green / 255.0; +// float r = 100.0; +// float g = 100.0; +// float b = 100.0; // Calculate UV colors float v = (0.439 * r) - (0.368 * g) - (0.071 * b) + 128;