troubleshooting Question

using disk instead of memory for image creation using intptr

Avatar of bemson
bemson asked on
Visual Basic.NET
9 Comments1 Solution274 ViewsLast Modified:
I have the following code to re-create an image

the program fails due to lack of memory even though I have 2gb memory

How can I use disk space instead of memory which fails at this line:
Dim BitMapObject As IntPtr = TargetBitMap.GetHbitmap

is there another variable I can use instead of intptr?

thanks for any help

frmText.Text = "Creating New Image"

Dim FinalRectangle As New Rectangle(0, 0, S.Width, S.Height)

Dim TargetBitMap As New Bitmap(Original_Image, S.Width, S.Height)
TargetBitMap.SetResolution(ImageDPI, ImageDPI)

frmMain.Text = "Setting Image properties"
fails on next line "out of memory"
Dim BitMapObject As IntPtr = TargetBitMap.GetHbitmap

frmMain.Text = "Building New Image"

Dim NewGraphics As Graphics = Graphics.FromImage(TargetBitMap.FromHbitmap(BitMapObject))
NewGraphics.DrawImage(Original_Image, FinalRectangle)

frmText.Text = "Saving New Image"

TargetBitMap.Save(Image2Resize2, Imaging.ImageFormat.Jpeg)
Mike Tomlinson
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros