This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Thursday, November 12, 2009 12:40:57 AM(UTC)
Groups: Registered
Posts: 8
Hello ,
I am using LeadTools V.16.5 evaluating version and i would really need some help..
I am using ActiveX and powerbuilder and what i am trying to do is add a new blank image at the end of the tif that i load.
I first load my first multipage tif(2 pages) in the the OLE ole_image16
Then i create a new Bitmap in the OLE ole_image26 and then i add the bitmap of the ole_image26 in the bitmaplist of the ole_image16.. And from what i see everything shows ok.. I indeed see a new blank page at the end of the ole_image16. Then i call the Save Method to save my originalTiff. And then after the save , my multipage tif file has 3 pages but the blank page has disappered and instead of the blank image i see the second page of my original multipage tif twice..
Below i have some snippets of the code tha i use
//Load the tiff that i would like to add the blank page
ole_image16.object.Load( ls_picturename , 0, ll_pageno1, -1)
//Add the new image at the end of the tiff file
Ole_width = ole_image16.object.BitmapWidth
Ole_Height = ole_image16.object.BitmapHeight
Ole_BPS = ole_image16.object.BitmapBits
ole_image26.object.CreateBitmap ( Ole_width, Ole_Height, Ole_BPS )
ole_image26.object.Fill( RGB(255, 255, 255)) // fill with white color
ole_image16.object.InsertBitmapListItem(-1 , ole_image26.object.Bitmap)
//Save Method
ll_nRet = this.ole_image16.object.Save ( ls_picturename , 29 , 1, -1, 1)
Could you please help me?? What did i do stupidly wrong??
Thanks in advance
Maria
#2
Posted
:
Thursday, November 12, 2009 6:11:05 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Maria,
You do not need to load all the pages to append a new page. You can simply call code like this (VB6 because I don't have PowerBuilder):
LEAD2.CreateBitmap 500, 500, 24
LEAD2.Fill RGB(255, 255, 255)
LEAD1.Save "multipage.tif", 29, 1, -1, SAVE_APPEND
This will add a white page at the end of ANY tiff file.
#3
Posted
:
Thursday, November 12, 2009 9:06:24 PM(UTC)
Groups: Registered
Posts: 8
Adam , thank you very much for the immediate answer and the snippet that you gave me in vb...
As i can see from your answer i have already implemented what you suggested but it didn't work.. At the begging of your reply you are saying that i don't need to load all the pages.
My case is as follows..
I have a window where i load my ocx and on it i laod a bitmap multipage tiff.. I allow the user to walk though pages and also i would like to give the user the ability to add a new page on the tiff he is viewing.. That is why i have already loaded my multipage tif.. As i have already written when i implement the code you mentioned i see a balnk page in the end of the tiff.. So till this point everything works fine.. When the user closes and opens the window again for the same file then the last page which WAS BLANK, now it has the 1st page of the multipage tiff there..
Any additional help on that??
Thanks in advance..
Maria
#4
Posted
:
Sunday, November 15, 2009 4:38:11 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Maria,
The Save method will save the current page (depending on the value of ole_image16.object.BitmapListIndex) and append it to the end of the file "ls_picturename".
You need to select the page that you added to the end of the ole_image16.object control as follows before you save the image:
//=====================
...
...
ole_image16.object.BitmapListIndex = ole_image16.object.BitmapListCount - 1
//Save Method
ll_nRet = this.ole_image16.object.Save ( ls_picturename , 29 , 1, -1, 1)
//=====================
#5
Posted
:
Wednesday, November 18, 2009 11:10:44 PM(UTC)
Groups: Registered
Posts: 8
Adam ,
Thank you very very much..
That was my error..Now it works perfectly...
Maria
#6
Posted
:
Monday, October 28, 2013 12:27:18 PM(UTC)
Groups: Registered
Posts: 13
Hello LeadTools Team,
I would like to do the same with C#, would that be possible ? I already have a handle to RasterIamge object for the tif file.
I tried to do something like this but not sure if I am on the right track :
--- --- --- --- ---
using (RasterImage rImage = codecs.Load(strTargetCachedImageFullPath))
{
//RasterImage fillerBlankPage = new RasterImage(flags, rImage.Width, rImage.Height, rImage.BitsPerPixel, RasterByteOrder.Rgb, RasterViewPerspective.TopLeft, new RasterColor[] { new RasterColor(System.ConsoleColor.White)}, ...
rImage.InsertPage(rImage.PageCount, fillerBlankPage)
}
--- --- --- --- ---
#7
Posted
:
Tuesday, October 29, 2013 5:38:32 AM(UTC)
Groups: Manager, Tech Support, Administrators
Posts: 218
Was thanked: 12 time(s) in 12 post(s)
In order to add a blank page to a RasterImage, you do the following:
using (RasterImage rImage = codecs.Load(strTargetCachedImageFullPath))
{
RasterImage filler = new RasterImage(RasterMemoryFlags.Conventional, rImage.Width, rImage.Height, rImage.BitsPerPixel, rImage.Order, rImage.ViewPerspective, rImage.GetPalette(), IntPtr.Zero, 0);
rImage.AddPage(filler);
}Note
that this is adding a blank page to the end of the image. If you want
to add multiple blank pages to the end of the image you should use the
following:
for(int i = 0; i < 5; i++)
{
rImage.AddPage(filler.Clone()); //note the use of the Clone method
}
If you want to insert the blank pages in the image you can use the InsertPage method rather than the AddPage Method.
More information for AddPage and InsertPage can be found here:
http://www.leadtools.com/help/leadtools/v18/dh/l/leadtools~leadtools.rasterimage~addpage.html
http://www.leadtools.com/help/leadtools/v18/dh/l/leadtools~leadtools.rasterimage~insertpage.html
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.
![LEAD Logo LEAD Logo](https://www.leadtools.com/images/new-site-images/leadtools-logo-header.png)
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.