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



Last Go to last post Unread Go to first unread post
#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);
Paint p = new Paint();
c.drawLine(x, y, xend, yend, p);

here secondviewer is a RASTERIMAGEVIEWER and _loadedImage2 is a RASTERIMAGE. i have also attached the screenshot of exception
Nayab123 attached the following image(s):

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:01:07 AM(UTC)


Groups: Registered, Tech Support, Administrators
Posts: 71

Was thanked: 4 time(s) in 3 post(s)


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();
c.drawLine(0, newpic.getHeight() / 2, newpic.getWidth(), newpic.getHeight() / 2, p);


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.

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-2023, Yet Another Forum.NET
This page was generated in 0.068 seconds.