Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

I get a "Common Error in GDI+" when saving an image with Kaliko SaveJPG. #15

Copy link
Copy link
@hannibalstgt

Description

@hannibalstgt
Issue body actions

Hello Fredrik,
you can probably remember me, the person which coded the CineStripScanner probably one of the very first users of the the Kaliko Image Library FastFilters to apply Unsharpmask to scanned Cine Film Strips.

I am now doing a new program (CineFrameGrabber) a program that should grab frames of a Cine Film (Super 8 or Normal 8) using a Digital Microscope and a stepper motor to advance the frames.
This creates some problems in synchronizing the various devices (the videocapture Device, the Serial Port
with the stepper motor and my program ). Therefore I have to use the TPL because I have to wait for the completion events of these devices.

But I do have a problem when saving images with Kaliko (under Windows 10 Home Edition 64 Bit Creators Edition). I am using VS Community 2017 .NET 4.5 and C# .

This is the code snippet I created

.....
using Kaliko.ImageLibrary;
using Kaliko.ImageLibrary.FastFilters;
using Kaliko.ImageLibrary.Filters;
using System.Drawing.Imaging;
....

....
if (snapshotSelected)
{
captureFrame.Snapshot();
}
else
{
requestImage = true;
}
taskG = new Task(new Action(showAndSaveImage));
taskG.Start();
taskG.Wait();
.......
......

    public static void showAndSaveImage()
    {
        KalikoImage theGrabbed;   // the grabbed cine film image
        int    imageNrI = ExecutionForm.actImgNo;
        String targetFile;
        string imageNrS;
        string fillZeros = "000000";
        int nrLen = 0;
        string imgType = DefinitionForm.activeInstance._imageType;  // JPG or PNG

/line 250/ Console.WriteLine("0250 showAndSaveImage started");
try
{
if (ExecutionForm.snapshotSelected == true)
{
ExecutionForm.picBoxImage = (Image)new Bitmap(ExecutionForm.aSnapshotFrame, ExecutionForm.picBoxSize);
theGrabbed = new KalikoImage(ExecutionForm.aSnapshotFrame);
}
else
{
ExecutionForm.picBoxImage = (Image)new Bitmap(ExecutionForm.aVideoFrame, ExecutionForm.picBoxSize);
theGrabbed = new KalikoImage(ExecutionForm.aVideoFrame); ;
}
if (theGrabbed != null)
{
if (DefinitionForm.activeInstance._sharpenOn == true)
{
Kaliko.ImageLibrary.FastFilters.FastUnsharpMaskFilter unsharpMaskFilter =
new Kaliko.ImageLibrary.FastFilters.FastUnsharpMaskFilter(DefinitionForm.activeInstance._radiusF,
DefinitionForm.activeInstance._contrastF,
DefinitionForm.activeInstance._thresholdI);
theGrabbed.ApplyFilter(unsharpMaskFilter);
}

                imageNrS = fillZeros + Convert.ToString(imageNrI).Trim();
                nrLen = imageNrS.Length;
                imageNrS = imageNrS.Substring((nrLen - 6), 6);
                ExecutionForm.actImgNoS = DefinitionForm.activeInstance._actProjectId +  DefinitionForm.activeInstance._subDirName + imageNrS + "." + DefinitionForm.activeInstance._imageType;
                targetFile = DefinitionForm.activeInstance._actTargetSubFolder + actImgNoS;
                switch (imgType)
                {
                    case "JPG":

/line 309/ theGrabbed.SaveJpg(targetFile, 90); // Common GDI+ error
break;
case "PNG":
theGrabbed.SavePng(targetFile);
break;
default:
theGrabbed.SavePng(targetFile);
break;
}
ExecutionForm.theRetVal = true;
}
else
{
ExecutionForm.theRetVal = false;
}
}
catch (Exception ex)
{
ExecutionForm.theRetVal = false;
Console.WriteLine("315 ex = " + ex);
}
}


And that is what I get. ( Always returnValue = false; !!! due to the Exception occured) .
What am I doing wrong. What is a common GDI+ error. I do nothing special except using
the Task Parallel Library (TPL) of MS .NET 4.5

This is the output of System.WriteLine:
ExecutionForm.txt

0250 showAndSaveImage started
"CineFrameGrabber.exe" (CLR v4.0.30319: CineFrameGrabber.exe): "C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing.resources\v4.0_4.0.0.0_de_b03f5f7f11d50a3a\System.Drawing.resources.dll" geladen. Das Modul wurde ohne Symbole erstellt.
Ausnahme ausgelöst: "System.Runtime.InteropServices.ExternalException" in System.Drawing.dll
315 ex = System.Runtime.InteropServices.ExternalException (0x80004005): Allgemeiner Fehler in GDI+.
bei System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
bei Kaliko.ImageLibrary.ImageOutput.SaveFile(KalikoImage image, String fileName, Int64 quality, String imageFormat, Boolean saveResolution)
bei Kaliko.ImageLibrary.KalikoImage.SaveJpg(String fileName, Int64 quality)
bei CineFrameGrabber.ExecutionForm.showAndSaveImage() in D:\C#Prog\Projects\CineFrameGrabber\CineFrameGrabber\ExecutionForm.cs:Zeile 309.

Many Thanks for your assistance
Wolfgang Kurz
wolfgang@uwkurz.de

The full method is atached as txt File. ExecutionForm.txt (rename it to .cs if needed)

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.