forked from davemorrissey/subsampling-scale-image-view
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge region display into preview-image branch and implement for full…
… size bitmaps and preview images
- Loading branch information
Showing
6 changed files
with
175 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/content" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" > | ||
|
||
<RelativeLayout | ||
android:id="@+id/text" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:background="#333"> | ||
<ImageView | ||
android:id="@+id/previous" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentLeft="true" | ||
android:layout_centerVertical="true" | ||
android:background="@drawable/buttonstate_transparent" | ||
android:paddingLeft="8dp" | ||
android:paddingRight="8dp" | ||
android:paddingTop="18dp" | ||
android:paddingBottom="18dp" | ||
android:src="@drawable/previous"/> | ||
|
||
<ImageView | ||
android:id="@+id/next" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentRight="true" | ||
android:layout_centerVertical="true" | ||
android:background="@drawable/buttonstate_transparent" | ||
android:visibility="invisible" | ||
android:paddingLeft="8dp" | ||
android:paddingRight="8dp" | ||
android:paddingTop="18dp" | ||
android:paddingBottom="18dp" | ||
android:src="@drawable/next"/> | ||
|
||
<ImageView | ||
android:id="@+id/rotate" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_toLeftOf="@id/next" | ||
android:layout_centerVertical="true" | ||
android:background="@drawable/buttonstate_transparent" | ||
android:paddingLeft="8dp" | ||
android:paddingRight="8dp" | ||
android:paddingTop="18dp" | ||
android:paddingBottom="18dp" | ||
android:src="@drawable/rotate"/> | ||
|
||
<TextView | ||
android:id="@+id/note" | ||
android:layout_height="wrap_content" | ||
android:layout_width="match_parent" | ||
android:layout_toLeftOf="@id/rotate" | ||
android:layout_toRightOf="@id/previous" | ||
android:layout_centerVertical="true" | ||
android:text="Set the region to display instead of the whole image." | ||
android:padding="10dp" | ||
android:textSize="14sp" | ||
android:textColor="#FFFFFF"/> | ||
|
||
</RelativeLayout> | ||
|
||
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView | ||
android:id="@+id/imageView" | ||
android:layout_alignParentTop="true" | ||
android:layout_above="@+id/text" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...c/com/davemorrissey/labs/subscaleview/sample/imagedisplay/ImageDisplayRegionFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Copyright 2014 David Morrissey | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package com.davemorrissey.labs.subscaleview.sample.imagedisplay; | ||
|
||
import android.graphics.Rect; | ||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.view.ViewGroup; | ||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; | ||
import com.davemorrissey.labs.subscaleview.sample.R.id; | ||
import com.davemorrissey.labs.subscaleview.sample.R.layout; | ||
|
||
import java.util.Random; | ||
|
||
public class ImageDisplayRegionFragment extends Fragment { | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
View rootView = inflater.inflate(layout.imagedisplay_region_fragment, container, false); | ||
final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)rootView.findViewById(id.imageView); | ||
imageView.setImageAsset("squirrel.jpg", null, randomRegion(2456, 1632)); | ||
rootView.findViewById(id.previous).setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
((ImageDisplayActivity)getActivity()).previous(); | ||
} | ||
}); | ||
rootView.findViewById(id.rotate).setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
imageView.setOrientation((imageView.getOrientation() + 90) % 360); | ||
} | ||
}); | ||
|
||
return rootView; | ||
} | ||
|
||
private static Rect randomRegion(int width, int height) { | ||
Random random = new Random(System.nanoTime()); | ||
|
||
int left = random.nextInt(width - 2); | ||
int top = random.nextInt(height - 2); | ||
int right = random.nextInt(width - left + 1) + left; | ||
int bottom = random.nextInt(height - top + 1) + top; | ||
|
||
return new Rect(left, top, right, bottom); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters