Leadtools名前空間 > RasterImageクラス :SetPaletteメソッド |
public void SetPalette( RasterColor[] palette, int startIndex, int count )
'Declaration
Public Sub SetPalette( _ ByVal palette() As RasterColor, _ ByVal startIndex As Integer, _ ByVal count As Integer _ )
'Usage
Dim instance As RasterImage Dim palette() As RasterColor Dim startIndex As Integer Dim count As Integer instance.SetPalette(palette, startIndex, count)
public void SetPalette( RasterColor[] palette, int startIndex, int count )
- (BOOL)setPalette:(nullable NSArray<LTRasterColor *> *)palette range:(NSRange)range error:(NSError **)error
public void setPalette(RasterColor[] palette, int startIndex, int count)
function Leadtools.RasterImage.SetPalette( palette , startIndex , count )
public: void SetPalette( array<RasterColor>^ palette, int startIndex, int count )
1、2、3、4、5、6、7または8のBitsPerPixel値によるRasterImageオブジェクトの画像データは、imageパレットにインデックスから構成されます。GetPaletteメソッドを用いて使われるパレットのコピーを取得することができます。
SetPaletteメソッドでRasterImageオブジェクトにより用いられるパレットを変更することができます。
このメソッドは、符合付きイメージをサポートしません。
詳細については、「RasterPaletteと概要」を参照してください。パレット処理.
16ビットグレースケールimageへの10に関する情報については、「グレースケールイメージ」を参照してください。
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Core Imports Leadtools.ImageProcessing.Color Imports Leadtools.Controls Imports Leadtools.Dicom Imports Leadtools.Drawing Imports Leadtools.Svg Public Sub PaletteExample() Dim codecs As RasterCodecs = New RasterCodecs() Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp") Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_RedPalette.bmp") ' Load the image as 8 bits/pixel Dim image As RasterImage = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1) ' Get the palette of this image and change it to shades of red Dim palette As RasterColor() = image.GetPalette() Dim i As Integer = 0 Do While i < palette.Length palette(i) = New RasterColor(i, 0, 0) i += 1 Loop ' Set the palette back in the image then save the file image.SetPalette(palette, 0, palette.Length) codecs.Save(image, destFileName, RasterImageFormat.Bmp, image.BitsPerPixel) image.Dispose() codecs.Dispose() End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Core; using Leadtools.ImageProcessing.Color; using Leadtools.Dicom; using Leadtools.Drawing; using Leadtools.Controls; using Leadtools.Svg; public void PaletteExample() { RasterCodecs codecs = new RasterCodecs(); string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp"); string destFileName = Path.Combine(ImagesPath.Path,"Image1_RedPalette.bmp"); // Load the image as 8 bits/pixel RasterImage image = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1); // Get the palette of this image and change it to shades of red RasterColor[] palette = image.GetPalette(); for(int i = 0; i < palette.Length; i++) palette[i] = new RasterColor(i, 0, 0); // Set the palette back in the image then save the file image.SetPalette(palette, 0, palette.Length); codecs.Save(image, destFileName, RasterImageFormat.Bmp, image.BitsPerPixel); image.Dispose(); codecs.Dispose(); }
RasterImageExamples.prototype.PaletteExample = function ( ) { Tools.SetLicense(); with (Leadtools.Codecs ) { var codecs = new RasterCodecs(); var srcFileName = "Assets\\Image1.cmp"; var destFileName = "Image1_RedPalette.bmp"; var image = null; // Load the image as 8 bits/pixel return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) { return codecs.loadAsync(Leadtools.LeadStreamFactory.create(loadFile), 8, CodecsLoadByteOrder.rgb, 1, 1); }) .then(function (img) { image = img; console.assert(image.bitsPerPixel === 8, "image.bitsPerPixel === 8"); // Get the palette of this image and change it to shades of red var palette = image.getPalette(); for (var i = 0; i < palette.length; i++) palette[i] = Leadtools.RasterColorHelper.create(i, 0, 0); // Set the palette back in the image then save the file image.setPalette(palette, 0, palette.length); return Tools.AppLocalFolder().createFileAsync(destFileName); }) .then(function (saveFile) { var saveStream = Leadtools.LeadStreamFactory.create(saveFile); return codecs.saveAsync(image, saveStream, Leadtools.RasterImageFormat.bmp, 0); }) .then(function () { image.close(); codecs.close(); }); } }
using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Core; using Leadtools.ImageProcessing.Color; using Leadtools.Dicom; public async Task PaletteExample() { RasterCodecs codecs = new RasterCodecs(); string srcFileName = @"Assets\Image1.cmp"; string destFileName = @"Image1_RedPalette.bmp"; // Load the image as 8 bits/pixel StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile), 8, CodecsLoadByteOrder.Rgb, 1, 1); Assert.IsTrue(image.BitsPerPixel == 8); // Get the palette of this image and change it to shades of red RasterColor[] palette = image.GetPalette(); for (int i = 0; i < palette.Length; i++) palette[i] = RasterColorHelper.Create(i, 0, 0); // Set the palette back in the image then save the file image.SetPalette(palette, 0, palette.Length); StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName); ILeadStream saveStream = LeadStreamFactory.Create(saveFile); await codecs.SaveAsync(image, saveStream, RasterImageFormat.Bmp, 0); image.Dispose(); codecs.Dispose(); }
using Leadtools; using Leadtools.Codecs; using Leadtools.Dicom; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Core; using Leadtools.ImageProcessing.Color; using Leadtools.Examples; using Leadtools.Windows.Media; public void PaletteExample(RasterImage image, Stream destStream) { // image should be loaded as 8 bits/pixel // Get the palette of this image and change it to shades of red RasterColor[] palette = image.GetPalette(); for (int i = 0; i < palette.Length; i++) palette[i] = new RasterColor(i, 0, 0); // Set the palette back in the image then save the file image.SetPalette(palette, 0, palette.Length); RasterCodecs codecs = new RasterCodecs(); codecs.Save(image, destStream, RasterImageFormat.Bmp, 0); image.Dispose(); }
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.Dicom Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Core Imports Leadtools.ImageProcessing.Color Imports Leadtools.Windows.Media Public Sub PaletteExample(ByVal image As RasterImage, ByVal destStream As Stream) ' image should be loaded as 8 bits/pixel ' Get the palette of this image and change it to shades of red Dim palette As RasterColor() = image.GetPalette() Dim i As Integer = 0 Do While i < palette.Length palette(i) = New RasterColor(i, 0, 0) i += 1 Loop ' Set the palette back in the image then save the file image.SetPalette(palette, 0, palette.Length) Dim codecs As RasterCodecs = New RasterCodecs() codecs.Save(image, destStream, RasterImageFormat.Bmp, 0) image.Dispose() End Sub