 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Marc Pelletier Guest
|
Posted: Thu May 26, 2005 3:34 pm Post subject: deconstructing bitmap |
|
|
Hello,
I am attempting to work with the ERMapper ECW/JP2000 sdk, which exposes a
c api, and I am having difficulty passing the data into it.
During compression I expose a callback function which get called for each
scanline of the bitmap. Within that function I fill 3 arrays with the
red, green and blue components of the scanline. What I'm doing isn't
working, I get an 'unable to read input line' error message. I'm doing it
like this...
// yes this must be single
TpColorPlane = ^TColorPlane;
TColorPlane = array[0..High(Word)] of single;
TInputArray = packed record
pRed : TpColorPlane;
pGreen : TpColorPlane;
pBlue : TpColorPlane;
end;
TpRGBArray = ^TRGBArray;
TRGBArray = array[0..High(Word)] of TRGBTriple;
function DoReadCallBack( pInfo: TpNCSEcwCompressClient; nNextLine:
Longword; var InputArray: TInputArray): ByteBool;
var
i : integer;
bmp : TBitmap;
pLine : TpRGBArray;
pRed,
pGreen,
pBlue : TpColorPlane;
begin
bmp := TBitmap( pInfo^.pClientData^ );
pRed := InputArray.pRed;
pGreen := InputArray.pGreen;
pBlue := InputArray.pBlue;
pLine := bmp.ScanLine[nNextLine];
for i := 0 to bmp.Width - 1 do
begin
pBlue^[i] := pLine^[i].rgbtBlue;
pGreen^[i] := pLine^[i].rgbtGreen;
pRed^[i] := pLine^[i].rgbtRed;
end;
result := true;
end;
Can anyone spot a problem with this code?
thanks,
Marc Pelletirr
Goldak Airborne Surveys
|
|
| Back to top |
|
 |
Marc Pelletier Guest
|
Posted: Thu May 26, 2005 3:45 pm Post subject: Re: deconstructing bitmap |
|
|
Marc Pelletier <marc (AT) stopspam (DOT) goldak.ca> wrote in
news:Xns96626176EEE80mmpp1234.dd (AT) 207 (DOT) 105.83.66:
| Quote: | function DoReadCallBack( pInfo: TpNCSEcwCompressClient; nNextLine:
Longword; var InputArray: TInputArray): ByteBool;
|
In case it helps, I am including a simple example of how this callback is
implemented in the sdk. In this example they are just filling it with
made up data however.
cheers
Marc
/*
** Read callback function - called once for each input line
*/
static BOOLEAN ReadCallback(NCSEcwCompressClient *pClient,
UINT32 nNextLine,
IEEE4 **ppInputArray)
{
ReadInfo *pRI = (ReadInfo*)pClient->pClientData;
UINT32 nBand;
for(nBand = 0; nBand < pClient->nInputBands; nBand++) {
UINT32 nCell;
IEEE4 *pLine = ppInputArray[nBand];
if(pClient->nInputBands == 1) {
/* 1 band, do a grid pattern */
for(nCell = 0; nCell < pClient->nInOutSizeX; nCell++) {
if(((nCell / 30) % 2 == nBand) || ((nNextLine / 30) % 2 ==
nBand)) {
pLine[nCell] = 1000.0f;
} else {
pLine[nCell] = 0.0f;
}
}
} else {
for(nCell = 0; nCell < pClient->nInOutSizeX; nCell++) {
if(((nCell / 30) % pClient->nInputBands == nBand) &&
((nNextLine / 30) % pClient->nInputBands == nBand)) {
pLine[nCell] = 1000.0f;
} else {
pLine[nCell] = 0.0f;
}
}
}
}
return(TRUE); /* would return FALSE on an error */
}
|
|
| Back to top |
|
 |
Ronaldo Souza Guest
|
Posted: Sat May 28, 2005 11:54 am Post subject: Re: deconstructing bitmap |
|
|
Marc,
| Quote: | bmp := TBitmap( pInfo^.pClientData^ );
|
What do you get from bmp.PixelFormat? Anything different from pf24bit
won't work.
HTH,
Ronaldo
|
|
| Back to top |
|
 |
Marc Pelletier Guest
|
Posted: Mon May 30, 2005 2:44 pm Post subject: Re: deconstructing bitmap |
|
|
Ronaldo Souza <nospam (AT) nospam (DOT) org> wrote in news:42985BE1.7000805
@nospam.org:
| Quote: | What do you get from bmp.PixelFormat? Anything different from pf24bit
won't work.
|
Right, I should have mentioned that. Its all 24 bit.
cheers
Marc
|
|
| Back to top |
|
 |
Nils Haeck Guest
|
Posted: Tue May 31, 2005 2:05 am Post subject: Re: deconstructing bitmap |
|
|
Hello Marc,
It could be something simple yet annoying like having corresponding calling
convention.. did you try putting "stdcall" or "cdecl" behind your function
declaration? e.g.
function DoReadCallBack( pInfo: TpNCSEcwCompressClient; nNextLine:
Longword; var InputArray: TInputArray): ByteBool; stdcall;
Anyway, if I were you I would first try to reproduce their example literally
before going to something more difficult like providing your own bitmap
data.
Nils Haeck
www.simdesign.nl
"Marc Pelletier" <marc (AT) stopspam (DOT) goldak.ca> schreef in bericht
news:Xns96626176EEE80mmpp1234.dd (AT) 207 (DOT) 105.83.66...
| Quote: | Hello,
I am attempting to work with the ERMapper ECW/JP2000 sdk, which exposes a
c api, and I am having difficulty passing the data into it.
During compression I expose a callback function which get called for each
scanline of the bitmap. Within that function I fill 3 arrays with the
red, green and blue components of the scanline. What I'm doing isn't
working, I get an 'unable to read input line' error message. I'm doing it
like this...
// yes this must be single
TpColorPlane = ^TColorPlane;
TColorPlane = array[0..High(Word)] of single;
TInputArray = packed record
pRed : TpColorPlane;
pGreen : TpColorPlane;
pBlue : TpColorPlane;
end;
TpRGBArray = ^TRGBArray;
TRGBArray = array[0..High(Word)] of TRGBTriple;
function DoReadCallBack( pInfo: TpNCSEcwCompressClient; nNextLine:
Longword; var InputArray: TInputArray): ByteBool;
var
i : integer;
bmp : TBitmap;
pLine : TpRGBArray;
pRed,
pGreen,
pBlue : TpColorPlane;
begin
bmp := TBitmap( pInfo^.pClientData^ );
pRed := InputArray.pRed;
pGreen := InputArray.pGreen;
pBlue := InputArray.pBlue;
pLine := bmp.ScanLine[nNextLine];
for i := 0 to bmp.Width - 1 do
begin
pBlue^[i] := pLine^[i].rgbtBlue;
pGreen^[i] := pLine^[i].rgbtGreen;
pRed^[i] := pLine^[i].rgbtRed;
end;
result := true;
end;
Can anyone spot a problem with this code?
thanks,
Marc Pelletirr
Goldak Airborne Surveys
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|