Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5943795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:26:49+00:00 2026-05-22T16:26:49+00:00

I have to draw something on a Image wich is captured by the Camera.

  • 0

I have to draw something on a Image wich is captured by the Camera. This works on many Devices, but sometimes the RAM is too small or the pictures too big and the function crashed with a OutOfMemory Exception.

How am I able to:
a) optimize the code to prevent this Exceptions
b) Handle this Exceptions (making pictures smaller, free Ram etc.

here is the code:

 Dim from_bmp As Bitmap
 Dim bmp As Bitmap

 from_bmp = New Bitmap(picname)
 'I also tryed this with a function which is creating the Bitmap from Filestream
 'I also tryed this with the OpenNETCF.Drawing.Imaging.IImage
 'If the Original Pictiure is too big, the function will crash here.

 bmp = New Bitmap(from_bmp.Width, from_bmp.Height + stampheight)
 'now I Create a bitmap which is higher than the original, in order to write the stamp beneth the picture

 Dim font As New System.Drawing.Font("Arial", 30, FontStyle.Regular)
 gr = Graphics.FromImage(bmp)
 gr.DrawImage(from_bmp, 0, 0)
 from_bmp.Dispose()
 'here I draw somethin in the Bitmap
 bmp.Save(deststring, System.Drawing.Imaging.ImageFormat.Jpeg)
 gr.Dispose()
 bmp.Dispose()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:26:50+00:00Added an answer on May 22, 2026 at 4:26 pm

    I’d likely use a “using” pattern for your Bitmaps. Also, be aware that an OOM on Bitmap creation can often be overcome by simply trying again (here’s a diatribe as to why). My bet is that the GC Heap is too full and a second request, especially after a collection, would succeed.

    I’d go through the rest of the code (that not shown) and make sure that all other graphics objects are getting properly Disposed – the CF doesn’t handle auto clean-up of the native resources of graphic objects very well and often needs a bit of help (again, see the above link).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to draw an ellipse in the screen but I don't
I want to draw something on an <mx:Image> I have in my .mxml file,
i have a view with uiimageview i assign this uiimageview image by camera..now i
I have a PictureBox control on a Form that is supposed to draw something
I have a function that draw an image on graphics: private void DrawSmallImage(Graphics g)
As far as I have understood so far, every time I draw something in
I have a custom UIView that draws an image in the draw rect method.
I have a Canvas that i draw text on. (this is quite advanced i
hi, I'm trying to implement something similar to the image attached. I have two
I have some Bytes of image in my string and i want to draw

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.