Thank you for your quick reply.
Użytkownik "Tom Smith" <no***************@use.netnapisał w wiadomości
news:eh**********@gemini.csx.cam.ac.uk...
Here's an absolute rule: your compiler is right. Always.
I am ready to recognize its authority as only second to divine.
The problem is it only tells me that I am wrong, not what I can do
to be right.
As for what's going on with your particular error, you haven't really
given us enough (any) information: can you post a relevant piece of code
and the actual error message? (See
Here is the source file and the header. Complying with the FAQ, I'm not
cutting
out any part of the code, so it's rather lengthy, but I put a "LOOK HERE"
comment
in the offending line. My purpose in that particular fragment is simply to
read in
an image file and then run through its pixels one by one, doing different
things
depending on whether each successive pixel is white or black. And they are
all either white or black; I made the image that way - so I figured I can
just take
any of the three color components and compare it to a threshold.
The error message is:
! error C2039: 'GetRed' : is not a member of 'System::Drawing::Color'
I also tried GetR(), which the headers define as synonymous with GetRed.
The result was the same.
Thanks again - L.
< ------- lengthy source file begins, stand back! ----- >
#include "StdAfx.h"
#include ".\k3palette.h"
// #include <atlsecurity.h>
#include <atlimage.h>
// #include <gdiplusbase.h//* not included originally!
// #include <gdiplusheaders.h>
// #include <gdipluscolor.h>
// #include <gdiplusbitmap.h>
#using <mscorlib.dll>
#using <system.dll>
#using <system.drawing.dll>
// #using <system.windows.forms.dll//* these lines were commented
using namespace System;
using namespace System::IO;
using namespace System::Collections; //*
using namespace System::Resources; //*
using namespace System::Drawing;
// using namespace System::Windows::Forms; //*
void K3Log(char *);
K3Palette::K3Palette(long unsigned NCol, char PaletteType)
{ // NCol =Number of colours;
// PaletteType= (uppercase letters only)
// 'G'-greyscale,
// 'H'-rainbow of hues,
// 'F'-scan full colour space
long unsigned i,k,j,j8;
N=NCol;
MyInks=new int[NCol][3];
switch(PaletteType) {
case 'G':
for(i=0;i<NCol;i++) {
MyInks[i][0]=MyInks[i][1]=MyInks[i][2]=(int)( ((double)i)/((double)NCol)
* 255.0);
};
break;
case 'H':
{
int rg=4;
int gb=3;
int br=5;
int SumCoeff;
SumCoeff=rg+gb+br;
rg=(NCol*rg)/SumCoeff;
gb=(NCol*gb)/SumCoeff;
br=NCol-rg-gb;
for(i=0;i<NCol;i++) {
// K3Log("Playing colors");
if(i<=rg) {
MyInks[i][0]=255*(rg-i)/rg;
MyInks[i][1]=255*i/rg;
MyInks[i][2]=0;
}
else if(i<=rg+gb) {
MyInks[i][0]=0;
MyInks[i][1]=255*(rg+gb-i)/gb;
MyInks[i][2]=255*(i-rg)/gb;
if(i==rg+gb) {
MyInks[i][0]=MyInks[i][1]=128;
};
}
else {
MyInks[i][0]=255*(i-rg-gb)/br;
MyInks[i][1]=0;
MyInks[i][2]=255*(rg+gb+br-i)/br;
};
};
};
break;
// case 'F': included in default!
// break; All other values of PaletteType treated as 'F'.
default:
for(i=0;i<NCol;i++) {
k=(long unsigned)( ((double)i) / ((double)NCol) * 16777216.0 );
// avoid zeros, scatter values.
MyInks[i][0]=MyInks[i][1]=MyInks[i][2]=0;
for(j=0;j<8;j++) { // now reshuffle the bits so that neighbouring..
for(j8=0;j8<3;j8++) { //.. numbers have different colours.
MyInks[i][j8]*=2;
MyInks[i][j8]+=(k&1);
k=k/2;
};
};
};
};
}
void K3Palette::GetInk(unsigned long i, unsigned long *deliver) {
// *deliver=(i&1) ? 200 : 0;
// *(deliver+1)=(i&2) ? 200 : 0;
// *(deliver+2)=(i&4) ? 200 : 0;
i=i%N;
if(i<0) {
K3Log("Negative ink number!");
i=0;
}
else
if (i>(N-1)) {
K3Log("ESceSSive ink number!");
i=N-1;
};
*deliver=MyInks[i][0];
*(deliver+1)=MyInks[i][1];
*(deliver+2)=MyInks[i][2];
};
long unsigned K3Palette::GetN() {
return(N);
};
void K3Palette::DumpLegend(char *filnam) {
// create bitmap file with given name,
// featuring 10 rows per color.
Bitmap *MujBitmap;
long i,j,k;
Color K3Ink,K3Ink2,Paper;
COLORREF PaperCOLORREF;
K3Log("Legending!");
K3Log(filnam);
MujBitmap=new Bitmap(300,10*N);
MujBitmap->SetResolution(300.0,300.0);
MujBitmap->FromFile("C:\\K3RF\\TextLegend.jpg");
for(k=0;k<N;k++) {
K3Log("another legend color");
K3Ink=Color::FromArgb(MyInks[k][0],MyInks[k][1],MyInks[k][2]);
if(MyInks[k][0]/3+MyInks[k][1]/3+MyInks[k][2]/3<127) {
K3Ink2=Color::FromArgb(255,255,255);
} else {
K3Ink2=Color::FromArgb(0,0,0);
};
for(i=0;i<300;i++) {
for(j=10*k;j<10*k+10;j++) {
Paper=MujBitmap->GetPixel(i,j);
// PaperCOLORREF=Paper.ToCOLORREF();
if(((int)(Paper.GetRed()))>210) { // LOOK HERE
MujBitmap->SetPixel(i,j,K3Ink);
}
else {
MujBitmap->SetPixel(i,j,K3Ink2);
};
};
};
};
K3Log("Saving legend");
K3Log(filnam);
MujBitmap->Save(filnam);
K3Log("Legend saved");
};
K3Palette::~K3Palette(void)
{
}
< --- and here is my header file ".\k3palette.h" --->
#pragma once
class K3Palette
{
public:
K3Palette(long unsigned, char);
~K3Palette(void);
void GetInk(long unsigned, long unsigned*);
long unsigned GetN(void);
void DumpLegend(char *filnam);
private:
int (*MyInks)[3];
long unsigned N;
};