小编All*_*lek的帖子

使用C#锐化位图

我想在图像上放置一个锐化滤镜.我找到了一个简短教程的网站.我试着在C#中这样做,所以这是我的代码.无论如何,我试图找出它为什么不起作用.我不知道我做错了什么,如果是的话,请告诉我该怎么做才能让它按原样运作.谢谢

        public static Bitmap sharpen(Bitmap image)
    {
        Bitmap sharpenImage = new Bitmap(image.Width, image.Height);

        int filterWidth = 3;
        int filterHeight = 3;
        int w = image.Width;
        int h = image.Height;

        double[,] filter = new double[filterWidth, filterHeight];

        filter[0, 0] = filter[0, 1] = filter[0, 2] = filter[1, 0] = filter[1, 2] = filter[2, 0] = filter[2, 1] = filter[2, 2] = -1;
        filter[1, 1] = 9;

        double factor = 1.0;
        double bias = 0.0;

        Color[,] result = new Color[image.Width, image.Height]; …
Run Code Online (Sandbox Code Playgroud)

c# image bitmap image-processing

14
推荐指数
3
解决办法
2万
查看次数

无法从远程计算机连接

我有一些问题,如果不工作,我无法在家检查.这是代码

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.IO;
using System.Net.Security;

class Program
{
    private static IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
    private static int port = 6000;
    private static string data = null;

    static void Main(string[] args)
    {
        Thread thread = new Thread(new ThreadStart(receiveThread));
        thread.Start();
        Console.ReadKey();
    }

    public static void receiveThread()
    {
        while (true)
        {
            TcpListener tcpListener = new TcpListener(ipAddress, port);
            tcpListener.Start();

            Console.WriteLine("Waiting for connection...");

            TcpClient tcpClient = tcpListener.AcceptTcpClient();

            Console.WriteLine("Connected with {0}", tcpClient.Client.RemoteEndPoint);

            while (!(tcpClient.Client.Poll(20, SelectMode.SelectRead)))
            {
                NetworkStream networkStream …
Run Code Online (Sandbox Code Playgroud)

c# connection tcplistener tcpclient

8
推荐指数
1
解决办法
5684
查看次数

在C#中接收和发送数据

我还在努力提高我之前写的一点点.现在我遇到了接收数据的问题.我有一个程序,我用它来发送字符串使用tcpClient到一个程序,我在其中侦听指定的端口.它工作正常,所以我决定再次向前发送数据

public static void receiveThread()
{
    while (true)
    {
        TcpListener tcpListener = new TcpListener(IPAddress.Any, port);
        tcpListener.Start();

        Console.WriteLine("Waiting for connection...");

        TcpClient tcpClient = tcpListener.AcceptTcpClient();

        Console.WriteLine("Connected with {0}", tcpClient.Client.RemoteEndPoint);

        while (!(tcpClient.Client.Poll(20, SelectMode.SelectRead)))
        {
            NetworkStream networkStream = tcpClient.GetStream();
            StreamReader streamReader = new StreamReader(networkStream);

            data = streamReader.ReadLine();

            if (data != null)
            {
                Console.WriteLine("Received data: {0}", data);
                send(data); // Here Im using send Method
            }
        }
        Console.WriteLine("Dissconnected...\n");
        tcpListener.Stop();
    }
}

/// <summary>
/// Sending data
/// </summary>
/// <param name="data">Data to send</param>
public static void …
Run Code Online (Sandbox Code Playgroud)

c# tcplistener tcpclient

6
推荐指数
2
解决办法
2万
查看次数