Is this a code for generating 8 bit grayscale?? - 1.Private Sub CMDGRAY_Click()
-
2.Dim X As Integer, Y As Integer
-
3.Dim R As Integer, G As Integer, B As Integer, A As Integer
-
4.For X = 1 To ubx
-
5.For Y = 1 To uby
-
6.pixels(X, Y) = Picture1.Point(X, Y)
-
7.Next Y
-
8.Next X
-
9.
-
10.For X = 1 To ubx
-
11.For Y = 1 To uby
-
12.R = pixels(X, Y) And &HFF
-
13.G = ((pixels(X, Y) And &HFF00) / &H100) Mod &H100
-
14.B = ((pixels(X, Y) And &HFF0000) / &H10000) Mod &H100
-
15.A = (R + G + B) / 3
-
16.pixels(X, Y) = RGB(A, A, A)
-
17.Next Y
-
18.Next X
-
19.For X = 1 To ubx
-
20.For Y = 1 To uby
-
21.Picture2.PSet (X, Y), pixels(X, Y)
-
22.Next Y
-
23.Next X
2 1880
It should be relatively easy to see if that's the case by running the code.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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.
|
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...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |