Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C and C++

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.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-2007, 06:49 AM
tommy_mm tommy_mm is offline
Newbie
 
Join Date: Jan 2007
Posts: 1
Rep Power: 0
tommy_mm is on a distinguished road
Default Scanline in Borland

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(); 
}
But the image I have received is gray. The original one was colorful.
How to use Scanline to receive original copied picture?

Last edited by Jordan; 01-05-2007 at 08:31 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 01-05-2007, 08:33 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 26
Posts: 5,846
Last Blog:
Performance or Maintai...
Rep Power: 20
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2007, 12:09 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,034
Last Blog:
NaNoWriMo Day 23 The...
Rep Power: 24
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

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;
}
It just seems to be a difference of RGB element by RGB element vs color by color.

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 09:09 PM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 65%

Ads