Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 22nd, 2007, 11:23 AM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default pixel colour

hi..can anyone help me with the code to count the number of red and black pixels in an image? Pls reply as soon as possible. Really appreciate it
this was a program we managed to come up with in C program..cos tats the only programming language we were thought in sch...is it possible for someone to help us to convert this to VB?but this is only for a pixel in the picture...but we want an overall calculation for the whole image...i think we have to loop it and use count and all..but really dun know how to get to go about it..

void get_icolumn(HWND hWnd, imgdes *image, int xx, int yy)
{
#define GET_BLU(c) (int)(((c) >> 16) & 0xff)
#define GET_GRN(c) (int)(((c) >> 8) & 0xff)
#define GET_RED(c) (int)((c) & 0xff)
long color;
int red, grn, blu;
char szBuff[80];
char *str;

color = getpixelcolor(image, xx, yy);
if(color >= 0) { // Indicates no errors
if(image->bmh->biBitCount <= 8)
wsprintf(szBuff,
"Color value at (%d,%d) is %d, %d bpp", xx, yy,
(int)color, (int)image->bmh->biBitCount);
else { // 24-bit image
blu = GET_BLU(color);
grn = GET_GRN(color);
red = GET_RED(color);
wsprintf(szBuff, "Color value at (%d,%d) is red: %d, "
"green: %d, blue: %d, %d bpp", xx, yy, red, grn, blu,
(int)image->bmh->biBitCount);
}
MessageBox(hWnd, szBuff, 0, MB_OK);
}
else { // Error if color < 0
switch((int)color) { // Assign error message
case BAD_RANGE: str="Range error";
case BAD_BPP: str="Bits per pixel not 1, 8, or 24";
}
MessageBox(hWnd, str, 0, MB_OK);
}
}






Similar Threads
Thread Thread Starter Forum Replies Last Post
Recording pixel position abhi2086 C# 2005 1 August 4th, 2008 02:59 AM
Changing Fore colour and back colour darrenb Access VBA 2 May 25th, 2007 07:10 AM
number pixel Perseus Beginning VB 6 1 August 11th, 2005 05:08 PM
Query Regarding the pixel CsharpHelp C# 0 May 16th, 2005 11:12 PM
pixel coordinates david.iulian Classic ASP Basics 0 March 31st, 2005 07:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.