I try to create a screenshot like described here:
word
How can I show it in my form after it is taken? I tried to display it inside a pictureBox:
word
But I get:
Severity Code Description Project File Line Suppression State Error CS0029 Cannot implicitly convert type 'System.Drawing.Graphics' to 'System.Drawing.Image' SRAT C:\Users\Edd\documents\visual studio 2017\Projects\SRAT\SRAT\Form1.cs 20 Active
and this answer says that it is not possible to convert it
答案 0 :(得分:1)
A <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1">
<ImageView
android:id="@+id/imageView"
android:layout_width="38dp"
android:layout_height="38dp"
android:layout_marginLeft="@dimen/_5dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:scaleType="fitXY"
android:src="@drawable/circle_line_shape"
android:tint="@color/colorGray" />
<com.daasuu.bl.BubbleLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="@dimen/_5dp"
android:padding="3dp"
app:bl_arrowDirection="left"
app:bl_arrowHeight="14dp"
app:bl_arrowPosition="10dp"
app:bl_arrowWidth="8dp"
app:bl_cornersRadius="0dp"
app:bl_strokeWidth="0.5dp">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/_5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/parent_list_issue_title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="3dp"
android:text="Titulo de la incidencia"
android:textSize="12sp"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/parent_list_issue_subtitle_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/parent_list_issue_title_text_view"
android:textColor="@color/grey_semi_transparent"
android:textSize="10sp"
android:text="Subtitulo de la incidencia - Texto de prueba aplicación" />
<ImageButton
android:id="@+id/parent_list_item_expand_arrow"
android:layout_width="30dp"
android:layout_height="25dp"
android:src="@drawable/arrow_drop_down_circle"
android:paddingRight="5dp"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:scaleType="fitXY"
android:background="@color/white"/>
</RelativeLayout>
</com.daasuu.bl.BubbleLayout>
object is a sort of wrapper around an image that lets you draw on the image. They are usually temporary, and don't actually own the pixels that you're drawing.
In your case, <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap android:src="@drawable/ic_circle"
android:gravity="center" />
</item>
</layer-list>
is just providing the ability to draw onto mRecordButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
countDownTimer.cancel();
mIsRecording = false;
mIsTimelapse = false;
// Starting the preview prior to stopping recording which should hopefully
// resolve issues being seen in Samsung devices.
try {
startPreview();
mMediaRecorder.stop();
mMediaRecorder.reset();
} catch (Exception e) {
e.printStackTrace();
}
Intent mediaStoreUpdateIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
mediaStoreUpdateIntent.setData(Uri.fromFile(new File(mVideoFileName)));
sendBroadcast(mediaStoreUpdateIntent);
goNext();
}
});
, which is where the image actually lives in memory.
You should throw away the Graphics
and return the gfxScreenshot
:
bmpScreenshot
Then you can assign the bitmap to a Graphics
:
Bitmap