MCPcopy Create free account
hub / github.com/bluescan/tacentview / DoSaveExtractFramesModal

Method DoSaveExtractFramesModal

Src/MultiFrame.cpp:348–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346
347
348void Viewer::DoSaveExtractFramesModal(bool saveExtractFramesPressed)
349{
350 if (saveExtractFramesPressed)
351 ImGui::OpenPopup("Extract Frames");
352
353 // The unused isOpenExtractFrames bool is just so we get a close button in ImGui. Returns false if popup not open.
354 bool isOpenExtractFrames = true;
355 if (!ImGui::BeginPopupModal("Extract Frames", &isOpenExtractFrames, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar))
356 return;
357
358 float inputWidth = Gutil::GetUIParamScaled(160.0f, 2.5f);
359 float buttonWidth = Gutil::GetUIParamScaled(76.0f, 2.5f);
360
361 int numFrames = CurrImage->GetNumFrames();
362
363 // These two statics are in lock-step for efficiency.
364 static tIntervalSet frameSet;
365 static char framesToExtract[128] = "all";
366 if (saveExtractFramesPressed)
367 {
368 frameSet.Clear();
369 frameSet.Add( tInterval(0, numFrames-1) );
370 tString rangedStr = frameSet.Get();
371 tStd::tStrncpy(framesToExtract, rangedStr.Chr(), 128);
372
373 // Strncpy is scary. It may not write the terminating null!
374 framesToExtract[127] = '\0';
375 }
376
377 tString srcFileName = tGetFileName(CurrImage->Filename);
378 tString genMsg;
379 tsPrintf
380 (
381 genMsg,
382 "Extracts specified frames and saves them to a folder.\n"
383 "%d frames will be extraxcted from\n"
384 "%s\n"
385 "Frames to extract: %s\n",
386 frameSet.Count(), srcFileName.Chr(), frameSet.MakeInclusive().Get(tIntervalRep::Normal, tIntervalSetRep::Union).Chr()
387 );
388 ImGui::Text(genMsg.Chr());
389
390 ImGui::Separator();
391 tFileType fileType = DoSaveChooseFiletype();
392 DoSaveFiletypeOptions(fileType);
393
394 ImGui::Separator();
395 tString destDir = DoSubFolder();
396 static char outBaseName[128] = "ExtractedFrame";
397 if (saveExtractFramesPressed)
398 {
399 tString currBaseName = tGetFileBaseName(CurrImage->Filename);
400 if (!currBaseName.IsEmpty())
401 {
402 tStd::tStrncpy(outBaseName, currBaseName.Chr(), 128);
403 outBaseName[127] = '\0';
404 }
405 }

Callers

nothing calls this directly

Calls 6

GetNumFramesMethod · 0.80
AddMethod · 0.80
ClearMethod · 0.45
SetMethod · 0.45
IsValidMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected