Programación en C# para extraer datos de la imagen en cuestión
/// lt;summarygt;
/// Obtener la imagen con la transparencia especificada
/// lt;/summarygt;
/// lt;param name="SourceBitmap"gt;Imagen fuentelt;/paramgt;
/// lt;param name="OpaCityValue"gt;Porcentaje de transparencialt;/paramgt; p>
/// lt;param name="OpaCityValue"gt;Porcentaje de transparencialt;/paramgt
/// p>
/// lt;returnsgt;lt;/returnsgt; ;
/// lt;remarksgt;lt;/remarksgt;
mapa de bits público TheTransparentBitmap(Bitmap SourceBitmap, double OpaCityValue)
{
try {
//Definir una copia de imagen temporal
Bitmap ForOutBitmap = new Bitmap(SourceBitmap);
//Definir datos de imagen
BitmapData bmpDATA = new BitmapData();
//Asigna datos al área especificada de la imagen
bmpDATA = ForOutBitmap.LockBits(new Triangle(0, 0 , SourceBitmap.Width - 1, SourceBitmap.Height - 1), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
//Defina la matriz de bytes utilizada para el cálculo
byte[] BTS = new byte[bmpDATA.Stride * bmpDATA.Height 1];
//Establece el byte en los datos de imagen especificados
Runtime.InteropServices.Marshal.Copy(bmpDATA.Scan0). , BTS, 0, BTS.Length - 1);
//Variables de cálculo configuradas para evitar "el divisor no puede ser 0"
int tmpValue = 0
<; p> //Dado que se ha especificado como modo ARGB de 32 bits, cada 4 se organizan como B G R A, A es transparenciafor (int I = 0 ; I lt; = BTS.Length - 4; I = 4) {
tmpValue = BTS[I 3] * OpaCityValue;
//Modificar una transparencia
BTS[I 3] = tmpValue; /p>
}
//Después de completar el cálculo, devuelve el grupo de bytes al puntero
Ciertos datos de imagen
System.Runtime.InteropServices.Marshal.Copy(BTS, 0, bmpDATA.Scan0, BTS.Length - 1
//Desbloquea los datos de imagen para permitir); el hilo de llamada continúa la ejecución
ForOutBitmap.UnlockBits(bmpDATA
// Devuelve la imagen procesada
return ForOutBitmap
} catch (Exception ex) {
//Si ocurre una excepción, devuelve un valor nulo
return null;