TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

Reply To: application memory and virtual memory increase quickly

Forums › TWAIN Classic › application memory and virtual memory increase quickly › Reply To: application memory and virtual memory increase quickly

September 21, 2007 at 6:07 am #24141
cmutex
Participant
  • Topics - 1
  • Replies - 3
  • Total Posts - 4

Hi Gabe, thanks for your reply, yes, but i has use GlobalFree to release the handle, see my code segment. thanks again!

bool IMessageFilter.PreFilterMessage(ref Message m)
{
TwainCommand cmd = TwianScanner.PassMessage(ref m);
if (cmd == TwainCommand.Not)
return false;

switch (cmd)
{
case TwainCommand.CloseRequest:
{
EndingScan();
TwianScanner.CloseSrc();
break;
}
case TwainCommand.CloseOk:
{
EndingScan();
TwianScanner.CloseSrc();
break;
}
case TwainCommand.DeviceEvent:
{
break;
}
case TwainCommand.TransferReady:
{

ArrayList pics = TwianScanner.TransferPictures();
this.AutoScrollPosition = new Point(0, 0);
EndingScan();

TwianScanner.CloseSrc();
m_nPicnumber++;
for (int i = 0; i < pics.Count; i++)
{
IntPtr imgPtr = (IntPtr)pics;

IntPtr bmpptr = GlobalLock(imgPtr);
IntPtr pixptr = GetPixelInfo(bmpptr);

this.AutoScrollPosition = new Point(0, 0);
if (m_bmpOrigin!=null)
{
m_bmpOrigin.Dispose();
}

m_bmpOrigin = InptrToBitmap(pixptr, bmpptr);
Bitmap bmp = new Bitmap(m_bmpOrigin);

if (m_bFullSize)
{
pictureBox.Width = bmp.Width;
pictureBox.Height = bmp.Height;

}
else
{
pictureBox.Width = m_nPicOrgWidth;
pictureBox.Height = m_nPicOrgHeight;
bmp = new Bitmap(m_bmpOrigin, this.pictureBox.Width, this.pictureBox.Height);

}
m_nRotate = 1;
pictureBox.Image = bmp;
if (imgPtr != null)
{
GlobalFree(imgPtr);
}

if (bmpptr!=null)
{
GlobalFree(bmpptr);
}

if (pixptr!=null)
{
GlobalFree(pixptr);
}

}
if (pics!=null)
{
pics.Clear();

}
break;
}
}

return true;
}

Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • TWAIN for dental imaging integration
  • PDF/R For who and where?
  • Making searchable PDF with PDF/R
  • Backward compatibility with PDF/A and traditional PDF
  • could not open the twain source. Make sure there is a valid source for your sca
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in