|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
In Borland C++
I have copied an Image1 to an array tab[x][y], now i wnant to copy pixels from that array to Image2 using ScanLine. I have used code: Code:
int tab[256][256], *LinePtr;
void __fastcall TForm1::Button2Click(TObject *Sender)
{
for (int y=0; y<255; y++)
{
LinePtr = (BYTE *) Image2->Picture->Bitmap->ScanLine[y];
for (int x=0; x<255; x++)
{
LinePtr[x*3] = tab[x][y];
LinePtr[x*3+1] = tab[x][y];
LinePtr[x*3+2] = tab[x][y];
}
}
Image2->Refresh();
}
How to use Scanline to receive original copied picture? Last edited by Jordan; 01-05-2007 at 08:31 AM. |
| Sponsored Links |
|
|
|
|||||
|
I don't know enough about it to help you but I did find this:
efg's Tech Note: Manipulating Pixels With Delphi's ScanLine Property WingedPanther uses Borland I believe (I may be wrong). He may be able to help you further.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog Don't hesitate to ask any questions that you have! Check out our ASCII Calculator! |
|
|||||
|
Just looking at a few things: LinePtr points to int, but you are assigning it pointers to bytes. This could cause issues.
the code from the 2006 Borland help has this example: Code:
[C++]
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap *pBitmap = new Graphics::TBitmap();
// This example shows drawing directly to the Bitmap
Byte *ptr;
try
{
pBitmap->LoadFromFile("C:\\Program Files\\Borland\\CBuilder\\Images\\Splash\\256color\
\factory.bmp ");
for (int y = 0; y < pBitmap->Height; y++)
{
ptr = pBitmap->ScanLine[y];
for (int x = 0; x < pBitmap->Width; x++)
ptr[x] = (Byte)y;
}
Canvas->Draw(0,0,pBitmap);
}
catch (...)
{
ShowMessage("Could not load or alter bitmap");
}
delete pBitmap;
}
Third: you appear to be setting the R, G, and B values all to tab[x][y], which would be a shade of grey.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| John | ........ | 223.00000 |
| dargueta | ........ | 168.00000 |
| Xav | ........ | 164.00000 |
| gaylo565 | ........ | 18.00000 |
| WingedPanther | ........ | 15.00000 |
| |pH| | ........ | 15.00000 |
| Johnnyboy | ........ | 3.00000 |
| navghost | ........ | 1.00000 |
Goal: 100,000 Posts
Complete: 65%