Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 5th, 2007, 7:10 AM   #1
tommy_mm
Newbie
 
Join Date: Jan 2007
Posts: 2
Rep Power: 0 tommy_mm is on a distinguished road
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:


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?
tommy_mm is offline   Reply With Quote
Old Jan 5th, 2007, 8:07 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You're putting the same pixel in three adjacent places. Presuming it's an RGB or BGR mapped image, that makes some shade of gray. Have a look at the forum's rules, please.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jan 5th, 2007, 8:23 AM   #3
tommy_mm
Newbie
 
Join Date: Jan 2007
Posts: 2
Rep Power: 0 tommy_mm is on a distinguished road
How should I change that??
tommy_mm is offline   Reply With Quote
Old Jan 5th, 2007, 10:14 AM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Hard to say, since I don't know the format you're using. It's obvious at a glance, however, that one doesn't just replicate a pixel 3 times unless one is enlarging the image in a very rough way. It also looks strange that you're varying x more rapidly than y, since x is the major dimension in the array.

This response is based entirely on your code (which is hard to read, since you didn't use code tags). You have explained your goal and your resources in only the most cursory way and I'm not familiar with the Borland compiler/toolset.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Borland C++ Builder 6 and TCP/IP Book/Guide HybridStorm C++ 12 Jan 23rd, 2006 6:38 PM
error with borland dfoled C++ 6 Oct 1st, 2005 2:05 PM
Borland C++BuilderX, fatal error beezm C++ 3 Aug 17th, 2005 11:48 PM
Borland C++ Dudley C++ 13 May 17th, 2005 12:55 PM
Borland c++ Release compile ! Nysan C++ 0 Apr 17th, 2005 2:01 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:46 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC