Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, June 6, 2016 9:33:17 PM(UTC)
Nayab123

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):
errormsg.png
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, June 7, 2016 6:06:07 AM(UTC)

Aaron  
Aaron

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
 
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.

Powered by YAF.NET | YAF.NET © 2003-2019, Yet Another Forum.NET
This page was generated in 0.132 seconds.