From: mayayana on 28 Aug 2006 19:37 I'm trying to do a simple crop by loading a JPG into a picturebox, then PaintPicture to a second box with size set to the crop region. Very simple. It works fine but fails on certain images. The one picture I have that fails is 2500 x 1700 pixels (approx.), from a digital camera. And other pics saved from the same camera seem to fail, even though they open fine in IrfanView or PaintShopPro. Is the picture just too big? Should I do it a different way? (I've never quite grokked what autoredraw actually does.)
From: Randy Birch on 28 Aug 2006 19:50 autoredraw creates a memory copy of the image, so if a window is covered then uncovered VB will repaint the image into the control. When autoredraw is false, the image loaded into the picture box is just drawn on the device context of the picture box; there is no 'persistent bitmap' of the image so when you place another window overtop, the picture disappears. -- Randy Birch MS MVP Visual Basic http://vbnet.mvps.org/ Please reply to the newsgroups so all can participate. "mayayana" <mayaXXyana1a(a)mindXXspring.com> wrote in message news:J6LIg.2643$bM.1192(a)newsread4.news.pas.earthlink.net... I'm trying to do a simple crop by loading a JPG into a picturebox, then PaintPicture to a second box with size set to the crop region. Very simple. It works fine but fails on certain images. The one picture I have that fails is 2500 x 1700 pixels (approx.), from a digital camera. And other pics saved from the same camera seem to fail, even though they open fine in IrfanView or PaintShopPro. Is the picture just too big? Should I do it a different way? (I've never quite grokked what autoredraw actually does.)
From: Mike D Sutton on 28 Aug 2006 20:05 > I'm trying to do a simple crop by > loading a JPG into a picturebox, > then PaintPicture to a second box > with size set to the crop region. > > Very simple. It works fine but fails > on certain images. The one picture > I have that fails is 2500 x 1700 pixels > (approx.), from a digital camera. And > other pics saved from the same camera > seem to fail, even though they open > fine in IrfanView or PaintShopPro. > > Is the picture just too big? Should I do it > a different way? VB's back-buffer implementation uses a Device Dependant Bitmap (DDB) to store the image data, which is quite limited in how large it can be made. On older OS' this used to be ~16mb uncompressed data size, on later OS this has been expended but is still quite restrictive. The image you describe would take just over 16mb uncompressed space at 32-bit so this looks like it's hitting that boundary. A workaround for this is to use a Device Dependant Bitmap (DIB) and manage the GDI resources yourself, have a look at the DIB article on my site for an example of how to work with them. Hope this helps, Mike - Microsoft Visual Basic MVP - E-Mail: EDais(a)mvps.org WWW: Http://EDais.mvps.org/
From: mayayana on 29 Aug 2006 00:10 > A workaround for this is to use a Device Dependant Bitmap (DIB) and manage the GDI resources yourself, have a look at > the DIB article on my site for an example of how to work with them. > Hope this helps, > Thanks. The memory problem makes sense. I assume that as Randy describes autoredraw I was putting double data into memory with that. But it also failed with autoredraw set to false. Even then, I guess, I was actually trying to store two 14MB+ bitmaps by painting one to the other. I actually downloaded your DIB article and part of the DC article tonight. I haven't worked with this stuff for a long time, and never did very much, but I've found a sample image editor project in my pile of saved code that doesn't choke on the big image. So I guess I probably have the basics of what I need somewhere in there.
From: Mike D Sutton on 29 Aug 2006 01:15
> The memory problem makes sense. I assume that > as Randy describes autoredraw I was putting double > data into memory with that. But it also failed with > autoredraw set to false. Even then, I guess, I was > actually trying to store two 14MB+ bitmaps by painting > one to the other. > > I actually downloaded your DIB article > and part of the DC article tonight. I haven't worked > with this stuff for a long time, and never did very > much, but I've found a sample image editor project > in my pile of saved code that doesn't choke on the > big image. So I guess I probably have the basics > of what I need somewhere in there. Search your code for CreateDIBSection(), that's the key to creating your DIB back-buffer. Here's an old post with some pretty bare-bones DIB buffer creation: http://groups.google.co.uk/group/microsoft.public.vb.winapi.graphics/msg/4f941fe33eef7264 Ignore the middle bit (messing around with VarPtrArray(), RtlMoveMemory() and such,) you only need the GDI calls at the top and bottom of the example code. Hope this helps, Mike - Microsoft Visual Basic MVP - E-Mail: EDais(a)mvps.org WWW: Http://EDais.mvps.org/ |