Skip to content

Commit

Permalink
Commit translated content
Browse files Browse the repository at this point in the history
  • Loading branch information
olprod committed Nov 30, 2017
1 parent 0032e92 commit c72ba65
Show file tree
Hide file tree
Showing 126 changed files with 4,731 additions and 4,624 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
---
---
title: "チュートリアル: オブジェクトの永続化 (Visual Studio) (C#)"
ms.custom:
ms.date: 2015-07-20
ms.date: 07/20/2015
ms.prod: .net
ms.reviewer:
ms.suite:
ms.technology:
- devlang-csharp
ms.technology: devlang-csharp
ms.topic: get-started-article
dev_langs:
- CSharp
ms.assetid: a544ce46-ee25-49da-afd4-457a3d59bf63
caps.latest.revision: 3
caps.latest.revision: "3"
author: BillWagner
ms.author: wiwagn
translation.priority.mt:
- cs-cz
- pl-pl
- pt-br
- tr-tr
ms.openlocfilehash: efdf4694c1a1b6df2e9531a2bb4c813b536a330e
ms.sourcegitcommit: 4f3fef493080a43e70e951223894768d36ce430a
ms.translationtype: HT
ms.sourcegitcommit: 306c608dc7f97594ef6f72ae0f5aaba596c936e1
ms.openlocfilehash: 4c8dce64c470f01f540a83f68e3861df56913e4c
ms.contentlocale: ja-jp
ms.lasthandoff: 07/28/2017

---
ms.contentlocale: ja-JP
ms.lasthandoff: 11/21/2017
---
# <a name="walkthrough-persisting-an-object-in-visual-studio-c"></a>チュートリアル: オブジェクトの永続化 (Visual Studio) (C#)
オブジェクトのプロパティはデザイン時に既定値に設定できますが、そのオブジェクトが破棄されると、実行時に入力した値はすべて失われます。 シリアル化によってインスタンス間でオブジェクトのデータを永続化すると、値を保存しておき、次にそのオブジェクトをインスタンス化するときに、その値を取得することができます。

Expand Down Expand Up @@ -101,7 +92,7 @@ ms.lasthandoff: 07/28/2017

6. **[参照の追加]** ダイアログ ボックスで、**[プロジェクト]** タブをクリックし、LoanClass プロジェクトを選択します。

7. [OK **** ] をクリックしてダイアログ ボックスを閉じます。
7. **[OK]** をクリックしてダイアログ ボックスを閉じます。

8. デザイナーで、フォームに <xref:System.Windows.Forms.TextBox> コントロールを 4 つ追加します。

Expand Down Expand Up @@ -230,6 +221,5 @@ ms.lasthandoff: 07/28/2017
この時点で、アプリケーションを再度ビルドして実行できます。 最初に既定値がテキスト ボックスに表示されます。 値を変更して、4 番目のテキスト ボックスに名前を入力します。 いったんアプリケーションを閉じて、再び実行します。 これで、新しい値がテキスト ボックスに表示されます。

## <a name="see-also"></a>関連項目
[シリアル化 (C#)](../../../../csharp/programming-guide/concepts/serialization/index.md)
[シリアル化 (C#)](../../../../csharp/programming-guide/concepts/serialization/index.md)
[C# プログラミング ガイド](../../../../csharp/programming-guide/index.md)

174 changes: 136 additions & 38 deletions docs/framework/winforms/advanced/how-to-set-jpeg-compression-level.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,145 @@
---
title: "方法 : JPEG 圧縮レベルの設定 | Microsoft Docs"
ms.custom: ""
ms.date: "03/30/2017"
ms.prod: ".net-framework"
ms.reviewer: ""
ms.suite: ""
ms.technology:
- "dotnet-winforms"
ms.tgt_pltfrm: ""
ms.topic: "article"
dev_langs:
- "jsharp"
helpviewer_keywords:
- "イメージ [Windows フォーム], 変更 (エンコーダー パラメーターを)"
- "JPEG イメージ, 設定 (品質レベルを)"
---
title: "方法: JPEG 圧縮レベルの設定"
ms.custom:
ms.date: 03/30/2017
ms.prod: .net-framework
ms.reviewer:
ms.suite:
ms.technology: dotnet-winforms
ms.tgt_pltfrm:
ms.topic: article
dev_langs:
- csharp
- vb
helpviewer_keywords:
- images [Windows Forms], changing encoder parameters
- JPEG images [Windows Forms], setting quality level
ms.assetid: 4b9a74e3-9504-43c1-9f28-ace651d0772e
caps.latest.revision: 11
author: "dotnet-bot"
ms.author: "dotnetcontent"
manager: "wpickett"
caps.handback.revision: 7
---
# 方法 : JPEG 圧縮レベルの設定
イメージをディスクに保存するときに、ファイル サイズを最小化したり品質を向上させるためにイメージのパラメーターを修正することがあります。 JPEG イメージの品質を調整するには、圧縮レベルを修正します。 JPEG イメージを保存するときに圧縮レベルを指定するには、<xref:System.Drawing.Imaging.EncoderParameters> オブジェクトを作成してそれを <xref:System.Drawing.Image> クラスの <xref:System.Drawing.Image.Save%2A> メソッドに渡す必要があります。 <xref:System.Drawing.Imaging.EncoderParameters> オブジェクトを初期化して、1 つの <xref:System.Drawing.Imaging.EncoderParameter>. によって構成される配列を持つようにします。 <xref:System.Drawing.Imaging.EncoderParameter> を作成するときに <xref:System.Drawing.Imaging.Encoder.Quality> エンコーダーを指定して、必要な圧縮レベルを指定します。
caps.latest.revision: "11"
author: dotnet-bot
ms.author: dotnetcontent
manager: wpickett
ms.openlocfilehash: 66b5a90dd10ec10330adeae2cd859d7b307d3e69
ms.sourcegitcommit: 4f3fef493080a43e70e951223894768d36ce430a
ms.translationtype: MT
ms.contentlocale: ja-JP
ms.lasthandoff: 11/21/2017
---
# <a name="how-to-set-jpeg-compression-level"></a>方法: JPEG 圧縮レベルの設定
イメージをディスクに保存するときに、ファイル サイズを最小化したり品質を向上させるために、イメージのパラメーターを修正したりする必要がある場合があります。 圧縮レベルを修正して、JPEG イメージの品質を調整することができます。 JPEG 画像を保存するときに、圧縮レベルを指定するに作成する必要があります、<xref:System.Drawing.Imaging.EncoderParameters>オブジェクトに渡すと、<xref:System.Drawing.Image.Save%2A>のメソッド、<xref:System.Drawing.Image>クラスです。 初期化、<xref:System.Drawing.Imaging.EncoderParameters>オブジェクトのいずれかで構成される配列を持つこと、<xref:System.Drawing.Imaging.EncoderParameter>です。 作成するときに、<xref:System.Drawing.Imaging.EncoderParameter>を指定して、<xref:System.Drawing.Imaging.Encoder.Quality>エンコーダー、その、必要な圧縮レベルです。

## 使用例
<xref:System.Drawing.Imaging.EncoderParameter> オブジェクトを作成して 3 つの JPEG イメージを保存する方法を次のコード例に示します。 各 JPEG イメージを異なる圧縮レベルで保存するために、<xref:System.Drawing.Imaging.EncoderParameter> コンストラクターに渡す `long` の値を修正します。 品質レベル 0 は最も圧縮率が高く、品質レベル 100 は最も低い圧縮率に対応します。
## <a name="example"></a>例
次のコード例を作成、<xref:System.Drawing.Imaging.EncoderParameter>オブジェクトし、次の 3 つの JPEG 画像を保存します。 各 JPEG イメージは変更することにより、さまざまな品質レベルで保存、`long`に渡された値、<xref:System.Drawing.Imaging.EncoderParameter>コンス トラクターです。 品質レベル 0 は最も圧縮率が高く、品質レベル 100 は最も低い圧縮率に対応します。

[!code-csharp[UsingImageEncodersDecoders#8](../../../../samples/snippets/csharp/VS_Snippets_Winforms/UsingImageEncodersDecoders/CS/Form1.cs#8)]
[!code-vb[UsingImageEncodersDecoders#8](../../../../samples/snippets/visualbasic/VS_Snippets_Winforms/UsingImageEncodersDecoders/VB/Form1.vb#8)]
[!code-csharp[UsingImageEncodersDecoders#6](../../../../samples/snippets/csharp/VS_Snippets_Winforms/UsingImageEncodersDecoders/CS/Form1.cs#6)]
[!code-vb[UsingImageEncodersDecoders#6](../../../../samples/snippets/visualbasic/VS_Snippets_Winforms/UsingImageEncodersDecoders/VB/Form1.vb#6)]
```csharp
private void VaryQualityLevel()
{
// Get a bitmap. The using statement ensures objects
// are automatically disposed from memory after use.
using (Bitmap bmp1 = new Bitmap(@"C:\TestPhoto.jpg"))
{
ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Jpeg);

## コードのコンパイル
この例には、次の項目が必要です。
// Create an Encoder object based on the GUID
// for the Quality parameter category.
System.Drawing.Imaging.Encoder myEncoder =
System.Drawing.Imaging.Encoder.Quality;

- Windows フォーム アプリケーション。
// Create an EncoderParameters object.
// An EncoderParameters object has an array of EncoderParameter
// objects. In this case, there is only one
// EncoderParameter object in the array.
EncoderParameters myEncoderParameters = new EncoderParameters(1);

- <xref:System.Windows.Forms.PaintEventArgs>。これは、<xref:System.Windows.Forms.PaintEventHandler> のパラメーターです。
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 50L);
myEncoderParameters.Param[0] = myEncoderParameter;
bmp1.Save(@"c:\TestPhotoQualityFifty.jpg", jpgEncoder, myEncoderParameters);

myEncoderParameter = new EncoderParameter(myEncoder, 100L);
myEncoderParameters.Param[0] = myEncoderParameter;
bmp1.Save(@"C:\TestPhotoQualityHundred.jpg", jpgEncoder, myEncoderParameters);

// Save the bitmap as a JPG file with zero quality level compression.
myEncoderParameter = new EncoderParameter(myEncoder, 0L);
myEncoderParameters.Param[0] = myEncoderParameter;
bmp1.Save(@"C:\TestPhotoQualityZero.jpg", jpgEncoder, myEncoderParameters);
}
}
```

```vb
Private Sub VaryQualityLevel()
' Get a bitmap. The Using statement ensures objects
' are automatically disposed from memory after use.
Using bmp1 As New Bitmap("C:\test\TestPhoto.jpg")
Dim jpgEncoder As ImageCodecInfo = GetEncoder(ImageFormat.Jpeg)

' Create an Encoder object based on the GUID
' for the Quality parameter category.
Dim myEncoder As System.Drawing.Imaging.Encoder = System.Drawing.Imaging.Encoder.Quality

' Create an EncoderParameters object.
' An EncoderParameters object has an array of EncoderParameter
' objects. In this case, there is only one
' EncoderParameter object in the array.
Dim myEncoderParameters As New EncoderParameters(1)

Dim myEncoderParameter As New EncoderParameter(myEncoder, 50L)
myEncoderParameters.Param(0) = myEncoderParameter
bmp1.Save("c:\test\TestPhotoQualityFifty.jpg", jpgEncoder, myEncoderParameters)

myEncoderParameter = New EncoderParameter(myEncoder, 100L)
myEncoderParameters.Param(0) = myEncoderParameter
bmp1.Save("C:\test\TestPhotoQualityHundred.jpg", jpgEncoder, myEncoderParameters)

' Save the bitmap as a JPG file with zero quality level compression.
myEncoderParameter = New EncoderParameter(myEncoder, 0L)
myEncoderParameters.Param(0) = myEncoderParameter
bmp1.Save("C:\test\TestPhotoQualityZero.jpg", jpgEncoder, myEncoderParameters)
End Using
End Sub
```

```csharp
private ImageCodecInfo GetEncoder(ImageFormat format)
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
foreach (ImageCodecInfo codec in codecs)
{
if (codec.FormatID == format.Guid)
{
return codec;
}
}
return null;
}
```

```vb
Private Function GetEncoder(ByVal format As ImageFormat) As ImageCodecInfo

Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageDecoders()
Dim codec As ImageCodecInfo
For Each codec In codecs
If codec.FormatID = format.Guid Then
Return codec
End If
Next codec
Return Nothing

End Function
```

## <a name="compiling-the-code"></a>コードのコンパイル
この例で必要な要素は次のとおりです。

- Windows フォーム アプリケーション

- A <xref:System.Windows.Forms.PaintEventArgs>、パラメーターのある<xref:System.Windows.Forms.PaintEventHandler>です。

- `TestPhoto.jpg` という名前のイメージ ファイル。保存場所は **c:\\** です。

## 参照
[方法 : エンコーダーがサポートするパラメーターの確認](../../../../docs/framework/winforms/advanced/how-to-determine-the-parameters-supported-by-an-encoder.md)
[ビットマップの種類](../../../../docs/framework/winforms/advanced/types-of-bitmaps.md)
[マネージ GDI\+ でのイメージ エンコーダーおよびイメージ デコーダーの使用](../../../../docs/framework/winforms/advanced/using-image-encoders-and-decoders-in-managed-gdi.md)
## <a name="see-also"></a>関連項目
[方法: エンコーダーがサポートするパラメーターの確認](../../../../docs/framework/winforms/advanced/how-to-determine-the-parameters-supported-by-an-encoder.md)
[ビットマップの種類](../../../../docs/framework/winforms/advanced/types-of-bitmaps.md)
[マネージ GDI+ でのイメージ エンコーダーおよびイメージ デコーダーの使用](../../../../docs/framework/winforms/advanced/using-image-encoders-and-decoders-in-managed-gdi.md)
Loading

0 comments on commit c72ba65

Please sign in to comment.