drop image to only 1 test folder
This commit is contained in:
parent
0adf96dcdb
commit
43e1415eaa
@ -180,7 +180,7 @@ workspace "efsw"
|
|||||||
kind "ConsoleApp"
|
kind "ConsoleApp"
|
||||||
language "C++"
|
language "C++"
|
||||||
links { "efsw-static-lib" }
|
links { "efsw-static-lib" }
|
||||||
files { "src/test/*.cpp" }
|
files { "src/test/efsw-test.cpp" }
|
||||||
includedirs { "include", "src" }
|
includedirs { "include", "src" }
|
||||||
conf_links()
|
conf_links()
|
||||||
|
|
||||||
|
|||||||
@ -49,37 +49,7 @@ class UpdateListener : public efsw::FileWatchListener {
|
|||||||
( oldFilename.empty() ? "" : "from file " + oldFilename + " to " ) +
|
( oldFilename.empty() ? "" : "from file " + oldFilename + " to " ) +
|
||||||
filename + ") has event "
|
filename + ") has event "
|
||||||
<< getActionName( action ) << std::endl;
|
<< getActionName( action ) << std::endl;
|
||||||
|
|
||||||
// Check if a file was added (dropped)
|
|
||||||
/*if (action == efsw::Actions::Add) {
|
|
||||||
int width, height, channels;
|
|
||||||
// Reconstruct the full path
|
|
||||||
std::string fullPath = dir + filename;
|
|
||||||
|
|
||||||
// Add this delay
|
|
||||||
efsw::System::sleep(500);
|
|
||||||
|
|
||||||
std::cout << "File dropped: " << filename << std::endl;
|
|
||||||
std::cout << "Full path: " << fullPath << std::endl;
|
|
||||||
unsigned char* image_data = stbi_load(fullPath.c_str(), &width, &height, &channels, 0);
|
|
||||||
if (image_data)
|
|
||||||
{
|
|
||||||
std::cout << "DEBUG: Image loaded successfully. Flipping..." << std::endl;
|
|
||||||
flip_image_vertically(image_data, width, height, channels);
|
|
||||||
// --- Save the flipped image to a new temporary file ---
|
|
||||||
std::string flipped_filename = "flipped_" + filename;
|
|
||||||
stbi_write_jpg(flipped_filename.c_str(), width, height, channels, image_data, 100); // Quality 100
|
|
||||||
stbi_image_free(image_data);
|
|
||||||
|
|
||||||
STOP = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// This will tell you if the path was wrong or the file was locked
|
|
||||||
std::cout << "DEBUG: stbi_load failed for: " << fullPath << std::endl;
|
|
||||||
std::cout << "Reason: " << stbi_failure_reason() << std::endl;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
if (action == efsw::Actions::Add || action == efsw::Actions::Modified) {
|
if (action == efsw::Actions::Add || action == efsw::Actions::Modified) {
|
||||||
// 1. Ignore the event if it's a file WE created
|
// 1. Ignore the event if it's a file WE created
|
||||||
if (filename.find("flipped_") == 0) {
|
if (filename.find("flipped_") == 0) {
|
||||||
@ -188,7 +158,7 @@ int main( int argc, char** argv ) {
|
|||||||
handleWatchID( fileWatcher.addWatch( CurPath + "test", ul, true ) );
|
handleWatchID( fileWatcher.addWatch( CurPath + "test", ul, true ) );
|
||||||
|
|
||||||
/// adds another watch after started watching...
|
/// adds another watch after started watching...
|
||||||
efsw::System::sleep( 100 );
|
/*efsw::System::sleep( 100 );
|
||||||
|
|
||||||
efsw::WatchID watchID =
|
efsw::WatchID watchID =
|
||||||
handleWatchID( fileWatcher.addWatch( CurPath + "test2", ul, true ) );
|
handleWatchID( fileWatcher.addWatch( CurPath + "test2", ul, true ) );
|
||||||
@ -197,7 +167,7 @@ int main( int argc, char** argv ) {
|
|||||||
if ( watchID > 0 ) {
|
if ( watchID > 0 ) {
|
||||||
efsw::System::sleep( 1000 );
|
efsw::System::sleep( 1000 );
|
||||||
fileWatcher.removeWatch( watchID );
|
fileWatcher.removeWatch( watchID );
|
||||||
}
|
}*/
|
||||||
} else {
|
} else {
|
||||||
if ( fileWatcher.addWatch( path, ul, true ) > 0 ) {
|
if ( fileWatcher.addWatch( path, ul, true ) > 0 ) {
|
||||||
fileWatcher.watch();
|
fileWatcher.watch();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user