Click here to Skip to main content
15,908,661 members
Home / Discussions / Graphics
   

Graphics

 
QuestionRe: JPEG Extended ? Pin
Mark Salsbery10-Mar-07 7:16
Mark Salsbery10-Mar-07 7:16 
AnswerRe: JPEG Extended ? Pin
Christian Graus10-Mar-07 7:21
protectorChristian Graus10-Mar-07 7:21 
AnswerRe: JPEG Extended ? Pin
Christian Graus10-Mar-07 7:28
protectorChristian Graus10-Mar-07 7:28 
AnswerRe: JPEG Extended ? Pin
User 171649212-Mar-07 14:53
professionalUser 171649212-Mar-07 14:53 
GeneralRe: JPEG Extended ? Pin
Christian Graus27-Mar-07 2:51
protectorChristian Graus27-Mar-07 2:51 
QuestionDrawing in background thread Pin
Aaron Schaefer9-Mar-07 4:50
Aaron Schaefer9-Mar-07 4:50 
AnswerRe: Drawing in background thread Pin
Mark Salsbery9-Mar-07 6:32
Mark Salsbery9-Mar-07 6:32 
GeneralRe: Drawing in background thread Pin
Aaron Schaefer9-Mar-07 7:27
Aaron Schaefer9-Mar-07 7:27 
You're right, I wan't paying attention there. Updated code looks like this:

void worker_DoWork(object sender, DoWorkEventArgs e)
{
int width = (int)Math.Round(Width * fDPIX);
int height = LogHeightPixels;
Bitmap bmpNew = new Bitmap(width, height/*, System.Drawing.Imaging.PixelFormat.Gdi/*.Format32bppArgb*/);
DrawLogToBitmap(bmpNew);
e.Result = bmpNew;
}

void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
Bitmap bmpNew = (Bitmap)e.Result;
if (bmp != null)
{
bmp.Dispose();
bmp = null;
}
bmp = bmpNew;
Refresh();
}

Refresh ends up calling my Draw method here:


public override void Draw(Graphics gfx, Rectangle rect)
{
gfx.ScaleTransform(zoom, zoom);

// Update the bitmap (only as needed)
if (bDirty)
{
UpdateBitmap(gfx);
}

if (bmp == null || worker.IsBusy)
{
gfx.DrawString("Updating Bitmap, please wait!", this.Font, Brushes.Black, new PointF(0, 0));
return;
}

RectangleF rcSource = new RectangleF(-horizontalOffset, -verticalOffset, ClientRectangle.Width/zoom, ClientRectangle.Height/zoom);
RectangleF rcDest = new RectangleF(ClientRectangle.Location.X, ClientRectangle.Location.Y, ClientRectangle.Size.Width/zoom, ClientRectangle.Size.Height/zoom);

try
{
gfx.DrawImage(bmp, rcDest, rcSource, GraphicsUnit.Pixel);
}
catch (Exception exc)
{
gfx.DrawString(exc.Message, Font, Brushes.Black, new PointF(0,0));
}
etc....
}

Now, the bitmap seems OK, but I get an out of memory exception when I call DrawImage (hence the try/catch block). Using the exact same drawing code in the main thread causes no problems, even though it's a pretty big bitmap (2496 * 49152 * 32 bpp). If I try using a bitmapp with a different pixel format, say 16bpp to conserve memory, performance becomes terrible, but I don't get the exception.
QuestionRe: Drawing in background thread Pin
Mark Salsbery9-Mar-07 12:11
Mark Salsbery9-Mar-07 12:11 
AnswerRe: Drawing in background thread Pin
Aaron Schaefer9-Mar-07 15:36
Aaron Schaefer9-Mar-07 15:36 
GeneralRe: Drawing in background thread Pin
Mark Salsbery10-Mar-07 6:38
Mark Salsbery10-Mar-07 6:38 
GeneralRe: Drawing in background thread Pin
vineas22-Mar-07 20:19
vineas22-Mar-07 20:19 
QuestionExtracting specific image from tiff... Pin
PandemoniumPasha8-Mar-07 22:27
PandemoniumPasha8-Mar-07 22:27 
AnswerRe: Extracting specific image from tiff... Pin
PandemoniumPasha9-Mar-07 0:44
PandemoniumPasha9-Mar-07 0:44 
GeneralRe: Extracting specific image from tiff... Pin
Mogtabam10-Mar-07 21:07
Mogtabam10-Mar-07 21:07 
GeneralRe: Extracting specific image from tiff... Pin
Mark Salsbery11-Mar-07 9:16
Mark Salsbery11-Mar-07 9:16 
QuestionManaged DirectX DeviceResizing Pin
Dmitri Nеstеruk6-Mar-07 4:07
Dmitri Nеstеruk6-Mar-07 4:07 
QuestionMax Rectangles In Any Shape Pin
zbaum002-Mar-07 11:49
zbaum002-Mar-07 11:49 
AnswerRe: Max Rectangles In Any Shape Pin
John R. Shaw3-Mar-07 0:36
John R. Shaw3-Mar-07 0:36 
GeneralRe: Max Rectangles In Any Shape Pin
zbaum004-Mar-07 10:38
zbaum004-Mar-07 10:38 
GeneralRe: Max Rectangles In Any Shape Pin
John R. Shaw9-Mar-07 8:35
John R. Shaw9-Mar-07 8:35 
AnswerRe: Max Rectangles In Any Shape Pin
Shog99-Mar-07 11:21
sitebuilderShog99-Mar-07 11:21 
QuestionHow to Connect DV Video Encoder to FileWriter Pin
Brooks Harris2-Mar-07 11:18
Brooks Harris2-Mar-07 11:18 
AnswerRe: How to Connect DV Video Encoder to FileWriter Pin
Mark Salsbery2-Mar-07 12:52
Mark Salsbery2-Mar-07 12:52 
GeneralRe: How to Connect DV Video Encoder to FileWriter Pin
Brooks Harris3-Mar-07 3:58
Brooks Harris3-Mar-07 3:58 

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.