473,411 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

8 bit grayscale?

Is this a code for generating 8 bit grayscale??
Expand|Select|Wrap|Line Numbers
  1. 1.Private Sub CMDGRAY_Click()
  2. 2.Dim X As Integer, Y As Integer
  3. 3.Dim R As Integer, G As Integer, B As Integer, A As Integer
  4. 4.For X = 1 To ubx
  5. 5.For Y = 1 To uby
  6. 6.pixels(X, Y) = Picture1.Point(X, Y)
  7. 7.Next Y
  8. 8.Next X
  9. 9. 
  10. 10.For X = 1 To ubx
  11. 11.For Y = 1 To uby
  12. 12.R = pixels(X, Y) And &HFF
  13. 13.G = ((pixels(X, Y) And &HFF00) / &H100) Mod &H100
  14. 14.B = ((pixels(X, Y) And &HFF0000) / &H10000) Mod &H100
  15. 15.A = (R + G + B) / 3
  16. 16.pixels(X, Y) = RGB(A, A, A)
  17. 17.Next Y
  18. 18.Next X
  19. 19.For X = 1 To ubx
  20. 20.For Y = 1 To uby
  21. 21.Picture2.PSet (X, Y), pixels(X, Y)
  22. 22.Next Y
  23. 23.Next X
Sep 29 '12 #1
2 1880
Rabbit
12,516 Expert Mod 8TB
It should be relatively easy to see if that's the case by running the code.
Sep 29 '12 #2
Killer42
8,435 Expert 8TB
Note that for a better grayscale the colours aren't given equal weight. In other words, red, green and blue don't all contribute the same amount to the darkness of the resulting gray.

I forget the exact proportions, but the ColourToGreyscale function in this article looks as though it may help.
Sep 30 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: tjh | last post by:
hi - i'm a bit new to PHP - i've been messing around with the GD2 image functions and was wondering: i see a lot of information about converting a color image to grayscale but i can't figure...
0
by: Java script Dude | last post by:
In trying to speed up my web pages, I want to avoid using multiple images (disabled, hover, nohover). I've currently got opacity working on hover and it looks great and works in IE and Moz. But I...
6
by: QuasiChameleon | last post by:
Hi, I'm trying to create a grayscale image class that reads and writes grayscale Targa format. This works well with smaller images, but corrupts larger images and creates a "Segmentation fault...
8
by: RicercatoreSbadato | last post by:
I'm using bmp.Save() and the bmp is in PixelFormat.Format8bppIndexed. But when I open the image with Gimp, it tells me that the image is RGB and not grayscale.
0
by: tlemcenvisit | last post by:
Hello I translated this code (witch convert an image to grayscale) from C#.NET to C++.NET The C#.NET code is : private void GrayScale(Bitmap b) { BitmapData bmData = b.LockBits(new...
2
by: Harry Simpson | last post by:
I'm having trouble reducing the size of a bitmap programmatically: The file size of the original is 2400k. The picture is 816x1056. 16 million colors i think. I only need grayscale render. ...
2
by: Henry Wu | last post by:
Hi I was at the search for making e.Graphics.DrawImage turn any image to Grayscale, and I found two similar solutions but different ColorMatrix values, what is the difference between the two? Is...
4
by: Brian L. Troutwine | last post by:
I've recently begun to teach myself pygame by making a bunch of small toys. My current toy is cellular automata displayer and I've gotten a bit stuck on the displaying bit. (If automata isn't the...
8
by: platinumhimani | last post by:
-How to convert any image(8,16,24,32 or 64-bit) to 8-bit grayscale -i have tried to convert a 24-bit image to grayscale using setpixel and getpixel functions, in vb.net but i am unable to save...
0
by: vkinra | last post by:
Hi, I am reading some image data out of a camera pixels and have extracted the raw pixel intensity. Each "pixel" on the Camera sensor has either a R,G, or B filter that gives the intensity of the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.