One of the main sources of confusion (see the FastPix thread) seems to be the idea of using 32-bit images only. I've used FastPix regularly myself without problems, but it's not impossible there are other bugs, so I'd appreciate it if you post anything you find or which puzzles you to the FastPix thread in the CodeBank. I don't think it would work satisfactorily in this instance, with small text n the image Hope_feda posted, however.Īs to bugs in FastPix, there was an error in the code which I only discovered a few years ago: I got the rgba order of the bytes wrong in FastPix.ByteArray. and others: Reducing the resolution of the image (as in post #9) to speed up image processing is a good possibility which is easily overlooked. Now if only I had 1 euro for everyone who didn't thank me. My only question now is can I use it freely? What is your "licensing" policy? Thanks in advance.FastPix, like anything in the forum's CodeBank, is free to use however you like. I don't know why I couldn't get it to work first time, but it really works now! You're code is amazing. My only question now is can I use it freely? What is your "licensing" policy? Thanks in advance. So if you use the same image several times, it will be more efficient to convert the image just once.īBHey, thanks a lot for you reply. G = (col And &HFF00) > 8 'get green byteĮnd FunctionIn method 3, nearly half the time is taken up converting the image to 32 bits. R = (col And &HFF0000) > 16 'get red byte Public Function ToBlackAndWhite3(bmp As Bitmap) As Bitmapīmp = New Bitmap(bmp) 'this makes sure the bitmap is 32-bit format. below) to your project using Add Existing Item. The idea is that by putting the image processing loop inside a Using-End Using block, it's easier to concentrate on optimizing the actual image processing code.Ĭode: 'Note: copy FastPix.vb from my CodeBank entry (see my sig. in the Code Project) but FastPix is as far as I know unique in unlocking the image in the Dispose code. It's not hard to find other examples of classes that do a similar job (e.g. Here's the code for method 3:įastPix is indeed based on LockBits, but it simplifies the code by limiting its use to 32 bit bitmaps. I'm not sure why the results vary so widely - it probably depends on my present hardware - but clearly you can expect a considerable speedup using method 3 compared to your original results. In the image loop, I use exclusively Integer and Logical methods, because these are much more efficient than calls like Color.R etc.: 9 - 38 milliseconds. with FastPix GetPixel and SetPixel: 53 - 103 milliseconds.ģ. with Bitmap.GetPixel and SetPixel, based on your code from post #1: 663 - 680 milliseconds.Ģ. Hope_Veda, I timed 3 different ways to make your Image black-and-white on my computer:ġ. The idea is that by putting the image processing loop inside a Using-End Using block, it's easier to concentrate on optimizing the actual image processing code. FastPix is indeed based on LockBits, but it simplifies the code by limiting its use to 32 bit bitmaps. I have found that locking the whole image can often be slow things down though and it is faster to process the image in parts when working on large images. I've never used BB's FastPix, but I'm guessing that it is based on using Lockbits to lock the whole image in memory and should be fairly fast. How large of an image are you processing?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |