Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Um.. I thought I understood scan line... but when I step through the code, the source pointer remains empty and nothng gets transferred. I you have any advice, I'm listening.
this is the core of my code, I'm hoping to do stuff to the pixels between reading and writing, but this part doesn't work, an I don't know why.

C++
void TDriverFrm::MoveBmp(Graphics::TBitmap *Dest, Graphics::TBitmap *Source, TColor Color)
{
  int x,y;
  TRGBTriple *Sbyte, *Dbyte;

  for(y=0; y<TILEDIM; y++){
    Sbyte = (TRGBTriple *)Source->ScanLine[y];
    Dbyte = (TRGBTriple *)Dest->ScanLine[y];
    for(x=0; x<TILEDIM; x++){
      Dbyte[x] = Sbyte[x];
    }
  }
}
Posted
Updated 3-Dec-17 8:25am
Comments
Dave Kreskowiak 5-Jan-16 16:07pm    
You're going to have to define "doesn't work". That tells us nothing. What is the code supposed to do exactly and what is it actually doing?

A scan line is just the array of bytes that make up a single row of pixels in a bitmap image.
completeknowitall 5-Jan-16 17:04pm    
sorry, I thought it was obvious ( I guess it never is ) I'm trying to copy pixel data pixel by pixel from one bitmap to another using the scanline funtion. the line:

Sbyte = (TRGBTriple *) Source->Scanline[y];

assigns the pointer to the correct line (i guess) and the line

Dbyte[x] = Sbyte[x];

should transfer RGB data to the destination bitmap. however, my debugger shows that

Sbyte[0] ... Sbyte[2] contain all 0x00
(or rather '\0' because it thinks it's a char *)

I was hoping someone with exp. in scanline could point out the "obvious" mistake I made.

1 solution

I haven't touched C++ in about 5 years and I've never even heard of Embarcadero, but... it looks like your cast is being applied to the wrong item. Shouldn't it be something like:
C
Sbyte = (TRBGTriple *)(Source->scanline[y]);
 
Share this answer
 
Comments
completeknowitall 18-Jan-16 14:48pm    
You are right. I have learned from you.
I owe you, I owe you money.

Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900