Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# EPPlus resize pictures to fit in the cell Pin
Richard MacCutchan4-Sep-21 1:04
mveRichard MacCutchan4-Sep-21 1:04 
GeneralRe: C# EPPlus resize pictures to fit in the cell Pin
Mou_kol4-Sep-21 2:10
Mou_kol4-Sep-21 2:10 
AnswerRe: C# EPPlus resize pictures to fit in the cell Pin
Richard Andrew x644-Sep-21 2:17
professionalRichard Andrew x644-Sep-21 2:17 
AnswerRe: C# EPPlus resize pictures to fit in the cell Pin
BillWoodruff4-Sep-21 2:07
professionalBillWoodruff4-Sep-21 2:07 
GeneralRe: C# EPPlus resize pictures to fit in the cell Pin
Mou_kol4-Sep-21 2:11
Mou_kol4-Sep-21 2:11 
GeneralRe: C# EPPlus resize pictures to fit in the cell Pin
BillWoodruff4-Sep-21 2:13
professionalBillWoodruff4-Sep-21 2:13 
GeneralRe: C# EPPlus resize pictures to fit in the cell Pin
Mou_kol4-Sep-21 2:29
Mou_kol4-Sep-21 2:29 
QuestionHaving an issue accessing a bitmap region from two different threads. Pin
Herboren2-Sep-21 17:43
Herboren2-Sep-21 17:43 
I can't for the life of me figure out how to access the region from a tick thread which is calling a bgworker().

Here is the original code

C#
private void t_processFrame_Tick(object sender, EventArgs e)
{
    if (!_bw_frameProcessor.IsBusy)
    {
        _bw_frameProcessor.RunWorkerAsync();
    }
}

private void _bw_frameProcessor_DoWork(object sender, DoWorkEventArgs e)
{
    try
    {
        GetImage = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
        g = Graphics.FromImage(GetImage);
        g.CopyFromScreen(screen.Bounds.X, 0, 0, 0, GetImage.Size);

        pbDesktopFeed.Image = (Bitmap)GetImage;                           
        motionDetector.ProcessFrame((Bitmap)pbDesktopFeed.Image);
    }
    catch (Exception ex) { }
}


Its kind of frustrating because I have been sitting here for 3 days (I have a high tolerance of trying different variations before I burn myself out) trying to figure out why it works fine in Timer_Tick but not when Timer) Tick is running the Backgroundworker. My guess is that it is because of the Threads between the both.

I have tried cloning the bitmap inside the background worker

C#
GetImage = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
Bitmap clone = (Bitmap) GetImage.Clone()
g = Graphics.FromImage(clone);
g.CopyFromScreen(screen.Bounds.X, 0, 0, 0, clone.Size);
pbDesktopFeed.Image = (Bitmap)GetImage;
motionDetector.ProcessFrame((Bitmap)pbDesktopFeed.Image);


I have tried cloning the image using AForge:

C#
GetImage = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
g = Graphics.FromImage(GetImage );
g.CopyFromScreen(screen.Bounds.X, 0, 0, 0, GetImage .Size);
pbDesktopFeed.Image = (Bitmap)GetImage;
motionDetector.ProcessFrame(AForge.Imaging.Image.Clone((Bitmap)pbDesktopFeed.Image));


This however, works fine when I drop it all into the Timer_Tick event.

C#
private void t_processFrame_Tick(object sender, EventArgs e)
{
    try
    {
        GetImage = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
        g = Graphics.FromImage(GetImage);
        g.CopyFromScreen(screen.Bounds.X, 0, 0, 0, GetImage.Size);

        pbDesktopFeed.Image = (Bitmap)GetImage;
        motionDetector.ProcessFrame((Bitmap)pbDesktopFeed.Image);
    }
    catch (Exception ex) { }
}

AnswerRe: Having an issue accessing a bitmap region from two different threads. Pin
OriginalGriff2-Sep-21 20:12
mveOriginalGriff2-Sep-21 20:12 
GeneralRe: Having an issue accessing a bitmap region from two different threads. Pin
Herboren4-Sep-21 5:11
Herboren4-Sep-21 5:11 
QuestionWindows Service Pin
DoxMan30-Aug-21 6:37
DoxMan30-Aug-21 6:37 
AnswerRe: Windows Service Pin
Dave Kreskowiak30-Aug-21 7:41
mveDave Kreskowiak30-Aug-21 7:41 
AnswerRe: Windows Service Pin
mverbeke31-Aug-21 3:40
mverbeke31-Aug-21 3:40 
Questionusing Rect, Vertex, Point in windowsbase.dll: better performance compared to the usual ? Pin
BillWoodruff25-Aug-21 15:34
professionalBillWoodruff25-Aug-21 15:34 
QuestionC# and Excel don't work in a computer without Visual Studio Pin
Ismael Oliveira 202124-Aug-21 12:57
Ismael Oliveira 202124-Aug-21 12:57 
AnswerRe: C# and Excel don't work in a computer without Visual Studio Pin
RedDk24-Aug-21 13:56
RedDk24-Aug-21 13:56 
AnswerRe: C# and Excel don't work in a computer without Visual Studio Pin
Richard MacCutchan24-Aug-21 21:43
mveRichard MacCutchan24-Aug-21 21:43 
GeneralRe: C# and Excel don't work in a computer without Visual Studio Pin
Ismael Oliveira 202125-Aug-21 12:20
Ismael Oliveira 202125-Aug-21 12:20 
GeneralRe: C# and Excel don't work in a computer without Visual Studio Pin
Richard MacCutchan25-Aug-21 21:58
mveRichard MacCutchan25-Aug-21 21:58 
GeneralRe: C# and Excel don't work in a computer without Visual Studio Pin
Ismael Oliveira 202126-Aug-21 4:03
Ismael Oliveira 202126-Aug-21 4:03 
GeneralRe: C# and Excel don't work in a computer without Visual Studio Pin
Ismael Oliveira 202126-Aug-21 4:51
Ismael Oliveira 202126-Aug-21 4:51 
GeneralRe: C# and Excel don't work in a computer without Visual Studio Pin
Richard MacCutchan26-Aug-21 4:55
mveRichard MacCutchan26-Aug-21 4:55 
GeneralRe: C# and Excel don't work in a computer without Visual Studio Pin
Ismael Oliveira 202126-Aug-21 10:41
Ismael Oliveira 202126-Aug-21 10:41 
GeneralRe: C# and Excel don't work in a computer without Visual Studio Pin
Dave Kreskowiak26-Aug-21 5:08
mveDave Kreskowiak26-Aug-21 5:08 
GeneralRe: C# and Excel don't work in a computer without Visual Studio Pin
Ismael Oliveira 202126-Aug-21 19:46
Ismael Oliveira 202126-Aug-21 19:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.