x38class 0 Newbie Poster

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.