LEADTOOLS Support
Imaging
Imaging SDK Questions
leadtools.RasterException: Invalid parameter passed
#1
Posted
:
Monday, June 6, 2016 9:28:17 PM(UTC)
Groups: Registered
Posts: 1
Hello people
i am developing an android app and trying to convert a RasterImage to a Bitmap image so that i can draw a line on the bitmap image through canvas and set that bitmap to my RasterImageViewer. but i am getting this exception and my RasterImage is not being converted. below is my code can somebody pleaseeeee help me out.
Bitmap newpic;
newpic=RasterImageConverter.convertToBitmap(_loadedImage2, ConvertToImageOptions.NONE.getValue());
newpic = Bitmap.createBitmap(secondviewer.getWidth(), secondviewer.getHeight(), Config.ARGB_8888);
Canvas c = new Canvas(newpic);
c = new Canvas(newpic);
secondviewer.draw(c);
Paint p = new Paint();
p.setColor(color);
c.drawLine(x, y, xend, yend, p);
secondviewer.setImageBitmap(newpic);
here secondviewer is a RASTERIMAGEVIEWER and _loadedImage2 is a RASTERIMAGE. i have also attached the screenshot of exception
Nayab123 attached the following image(s):
#2
Posted
:
Tuesday, June 7, 2016 6:01:07 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 71
Was thanked: 4 time(s) in 3 post(s)
Hi,
The issue is with the second parameter in your convertToBitmap function call. You can simply pass null as the second parameter since you are attempting to use ConvertToImageOption.None anyway. I added some code to our ViewerDemo that demonstrates how to do what you are wanting to do (image is the RasterImage and mViewer is the RasterImageViewer):
Bitmap newpic = RasterImageConverter.convertToBitmap(image, null);
Canvas c = new Canvas(newpic);
Paint p = new Paint();
p.setColor(getResources().getColor(R.color.blue1));
c.drawLine(0, newpic.getHeight() / 2, newpic.getWidth(), newpic.getHeight() / 2, p);
mViewer.setImageBitmap(newpic);
This code takes in the RasterImage and converts it to a Bitmap, draws a horizontal blue line the width of the image half way down the image, then sets the Bitmap into the viewer.
Aaron Brasington
Developer Support Engineer
LEAD Technologies, Inc.
![LEAD Logo LEAD Logo](https://www.leadtools.com/images/new-site-images/leadtools-logo-header.png)
LEADTOOLS Support
Imaging
Imaging SDK Questions
leadtools.RasterException: Invalid parameter passed
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.