|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Adjusting Contrast or Brightness in VB6In VB6: Does anyone know of a very efficient and fast way of altering the
Contrast or brightness of an image (in a picturebox) on the screen. The image does not have to be saved. Thanks. > In VB6: Does anyone know of a very efficient and fast way of altering the Have a look at the "Colour adjustment demo" or "Edge detection / Edge snap / Filter kernel" demos on my site, both of which> Contrast or brightness of an image (in a picturebox) on the screen. The > image does not have to be saved. demonstrate how to perform brightness/contrast adjustments; the former using the Wni32 API (WinNT based OS' only) and the latter through code alone (OS unspecific.) Hope this helps, Mike - Microsoft Visual Basic MVP - E-Mail: ED***@mvps.org WWW: Http://EDais.mvps.org/ Hi Mike,
Thanks for the sample code - it works brilliantly - I am just amazed at how powerful and fast VB6 can be now. In the redraw procedure - I can't seem to work why you call Call SetColorAdjustment(picPreview.hDC, NewAdjust) .. .. .. .. followed by : Call SetColorAdjustment(picPreview.hDC, OrigAdjust) in the same procedure. I am also looking forward to spending some tim egoing through your tutorials. John "Mike D Sutton" <ED***@mvps.org> wrote in message / Filter kernel" demos on my site, both of whichnews:Oer7SFQaFHA.3528@TK2MSFTNGP09.phx.gbl... > > In VB6: Does anyone know of a very efficient and fast way of altering the > > Contrast or brightness of an image (in a picturebox) on the screen. The > > image does not have to be saved. > > Have a look at the "Colour adjustment demo" or "Edge detection / Edge snap > demonstrate how to perform brightness/contrast adjustments; the former using the Wni32 API (WinNT based OS' only) and the latterShow quoteHide quote > through code alone (OS unspecific.) > Hope this helps, > > Mike > > > - Microsoft Visual Basic MVP - > E-Mail: ED***@mvps.org > WWW: Http://EDais.mvps.org/ > > > Thanks for the sample code - it works brilliantly - I am just amazed at how The colour adjustment is applied to the entire DC, and any drawing commands (that honour the colour adjustment properties) will> powerful and fast VB6 can be now. > > In the redraw procedure - I can't seem to work why you call > > Call SetColorAdjustment(picPreview.hDC, NewAdjust) > . > . > . > . > followed by : > Call SetColorAdjustment(picPreview.hDC, OrigAdjust) > in the same procedure. adjust their output to the currently applied mode. Since we don't want any other drawing on the DC to be colour adjusted (just the image we're drawing ourselves) I back the initial default colour adjustment properties up at the start of the procedure and re-apply those at the end to restore the DC back to normal. This way any drawing done to the window by VB or any other API's will not be affected. In this case since there's very little drawing going on it's probably safe to apply the adjustment once, but IMO it's cleaner to leave the DC the way you found it and good practice to get into if you're doing lots of GDI work. > I am also looking forward to spending some time going through your Good luck, let me know if you have any problems with them.> tutorials. Cheers, Mike - Microsoft Visual Basic MVP - E-Mail: ED***@mvps.org WWW: Http://EDais.mvps.org/ |
|||||||||||||||||||||||