LEADTOOLS Support
Imaging
Imaging SDK Questions
Re: SetRgnColor() and Fill Not Working - Please Help!
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Wednesday, June 27, 2007 1:25:49 PM(UTC)
Groups: Registered
Posts: 12
I am trying to color only black pixels in a tif file. It seems to work ok when I resize the bitmap in half, but when I try and paint the file without resizing, it just paints the whole file black. I tried both Load() and LoadResize(), and all the functions return success, but the file is painted completely black. I have attached the tif file I was testing with. I am using Raster Pro, Version 14.5. Thanks in advance of any help. Here is my code:
LBase::LoadLibraries(LT_ALL_LEADLIB);
CString PageLocation = "C:\\Test\\Test.tif", NewPageLocation = "C:\\Test\\Test_NEW.tif";
LFile LeadFile;
FILEINFO fInfo;
LBitmapBase * pBitmapBase = new LBitmapBase();
LeadFile.SetFileName((L_TCHAR*)(LPCTSTR)PageLocation.GetBuffer(1));
if( LeadFile.GetInfo(&fInfo, sizeof(FILEINFO)) == SUCCESS )
{
// This works
//int LoadStatus = pBitmapBase->LoadResize((L_TCHAR*)(LPCTSTR)PageLocation.GetBuffer(1), fInfo.Width/2, fInfo.Height/2, 8, SIZE_NORMAL, ORDER_BGR, NULL, NULL);
// This Doesn't
int LoadStatus = pBitmapBase->LoadResize((L_TCHAR*)(LPCTSTR)PageLocation.GetBuffer(1), fInfo.Width, fInfo.Height, 8, SIZE_NORMAL, ORDER_BGR, NULL, NULL);
if( LoadStatus == SUCCESS )
{
LBitmapRgn Region(pBitmapBase);
int Status = Region.SetRgnColor(RGB(0,0,0)); // set the black color as a region
if( pBitmapBase->HasRgn() == TRUE )
{
pBitmapBase->Fill(RGB(50,177,205)); // Fill the black region this color
int error = pBitmapBase->Save((L_TCHAR*)(LPCTSTR)NewPageLocation.GetBuffer(1), FILE_TIFLZW, 8, PQ1, 0, NULL );
}
Region.Free();
pBitmapBase->Free();
}
}
Thanks,
Rich
#2
Posted
:
Thursday, June 28, 2007 6:18:55 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Can you resend the image that you wanted to send? Please put
the Tiff image in a ZIP or RAR file so that our forum will allow posting it.
Also, if possible, can you send me your code in a small test
project (not your full application) so I can check it for you?
#3
Posted
:
Thursday, June 28, 2007 6:28:02 AM(UTC)
Groups: Registered
Posts: 12
Here is the image file as a zip file. Once again thanks for looking into this.
Rich
#4
Posted
:
Thursday, June 28, 2007 6:42:03 AM(UTC)
Groups: Registered
Posts: 12
Adnan,
Thanks for looking into this. I have attached the zipped and attached the source code, and image file that is not working. The code is c++. For some reason when you load in the file at 1/2 the size painting the black pixels and saving the file works. But when you load at the full size with the same function, the saved file is completely black.
Thanks,
Rich
#5
Posted
:
Sunday, July 1, 2007 4:18:50 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Rich,
It seems the source code you sent uses MFC in a console
application. Please either send me the remaining files of this test project, or
at least tell me which version of Visual Studio you're using so that I can
create my own project.
#6
Posted
:
Monday, July 2, 2007 8:25:58 AM(UTC)
Groups: Registered
Posts: 12
Adnan,
Here is the full project, with files. Please note the tif file goes into a c:\test directory. Once again thanks for looking into this. There seems to be something with how large of a file can be colored by region.
Thanks,
Rich
#7
Posted
:
Tuesday, July 3, 2007 6:11:39 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
You will find attached
2 TIFF images generated using your code(one from each function call). I was able to successfully open them using our Main API demo. If you use our demo to view
the files, do they work correctly?
LEADTOOLS Support
Imaging
Imaging SDK Questions
Re: SetRgnColor() and Fill Not Working - Please Help!
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.