My problem is that, i can’t view all the image or some pixels.
I have a imageview and bitmap on it. And with canvas library, I drawing the imageview limits. But the result is wrong. Why not sample the left and lower boundaries of the image? If I increase the brush size if it is.
Image : https://i.stack.imgur.com/R3Byw.jpg
I will show only the code of this part of my app
//Init imagebitmap
largeBitmap = Bitmap.createBitmap(200,200, Bitmap.Config.ARGB_8888);
//Init canvas
canvas = new Canvas(largeBitmap);
canvas.drawColor(0xffffffff);
//Set largeBitmap on Image
as.setImageBitmap(largeBitmap);
//Init Pincel
pincel1 = new Paint();
pincel1.setARGB(255, 0, 0, 0);
//Draw Limits
int ancho = canvas.getWidth();
int alto = canvas.getHeight();
canvas.drawLine(0, 0, ancho, 0, pincel1); // Superior
canvas.drawLine(0, alto, ancho, alto, pincel1); // Inferior
canvas.drawLine(0, 0, 0, alto, pincel1); // Izq
canvas.drawLine(ancho, 0, ancho, alto, pincel1); // Drch
xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center_horizontal" >
<HorizontalScrollView
android:id="@+id/hsv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center_horizontal" >
<LinearLayout
android:id="@+id/ll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="@string/app_name"
android:scaleType="center"
tools:context=".SIDetailFragment" />
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
I set scrollview only for test the bitmap image with scroll views on a easy form
Thanks in advance!
It’s because you’re going “too far”. As with (almost) everything in programming, canvas indexes are 0 based. So you need to use
ancho -1andalto - 1.