我是第一次玩计算机图形编程.我想将RGB(24位)图像转换为索引调色板(8位)图像(如GIF).我最初的想法是使用k-means(k = 256).
如何为给定图像选择最佳调色板?这对我来说是一次学习经历,所以我更喜欢源代码的概述型答案.
编辑:抖动目前是偏离主题的.我只是提到"简单"的颜色转换,心理视觉/感知模型; 色彩空间目前也是偏离主题的,虽然在色彩空间之间移动是让我在第一时间思考这个问题的原因:)
我们来看看这个例子.
<html>
<body onload="alert((0.1234*300));alert((0.00005*300))"/>
</html>
Run Code Online (Sandbox Code Playgroud)
为什么结果不应该是37.02和0.015但是37.019999999999996和0.015000000000000001?
Ps:0.00005*300出错,而0.0005*30和0.005*3都可以.
我正在使用Windows 2008 x64 R2与IIS 7.5和ASP.NET 2.0.
我想使用HTTP_REFERER但由于某些原因它不可用所以我决定使用此代码迭代所有服务器变量:
foreach (string vars in Request.ServerVariables)
{
Response.Write (vars.ToString() + "\r\n <br/>");
}
Run Code Online (Sandbox Code Playgroud)
结果如下:
ALL_HTTP ALL_RAW APPL_MD_PATH APPL_PHYSICAL_PATH AUTH_TYPE AUTH_USER AUTH_PASSWORD LOGON_USER REMOTE_USER CERT_COOKIE CERT_FLAGS CERT_ISSUER CERT_KEYSIZE CERT_SECRETKEYSIZE CERT_SERIALNUMBER CERT_SERVER_ISSUER CERT_SERVER_SUBJECT CERT_SUBJECT CONTENT_LENGTH CONTENT_TYPE GATEWAY_INTERFACE HTTPS HTTPS_KEYSIZE HTTPS_SECRETKEYSIZE HTTPS_SERVER_ISSUER HTTPS_SERVER_SUBJECT INSTANCE_ID INSTANCE_META_PATH LOCAL_ADDR PATH_INFO PATH_TRANSLATED QUERY_STRING REMOTE_ADDR REMOTE_HOST REMOTE_PORT REQUEST_METHOD SCRIPT_NAME SERVER_NAME SERVER_PORT SERVER_PORT_SECURE SERVER_PROTOCOL SERVER_SOFTWARE URL HTTP_CONNECTION HTTP_KEEP_ALIVE HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_LANGUAGE HTTP_HOST HTTP_USER_AGENT HTTP________________
任何人都可以解释为什么HTTP_REFERER失踪?
我有这两个班
///////////BASE CLASS
class Base{
public:
Base(int = 0);
~Base();
Base(Base&);
Base(Derived&); ////<-may be problem here?, note: I tried without this function
int valueOfBase();
protected:
int protectedData;
private:
int baseData;
};
/////////////DERIVED CLASS
class Derived: public Base{
public:
Derived(int);
//Derived(Derived&);
~Derived();
private:
int derivedData;
};
and here my main
int main(){
Base base(1);
Derived derived = base;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我读过如果我的派生类没有复制c'tor copy c'tor of the base will be called但每次收到conversion from Base to non-scalar type Derived requested谁错了?我的编译器或我的书,或者我刚刚被误解了?提前致谢
我哪里错了; 我想在命令行上为g ++定义一个预处理器值,但它失败了.下面是复制我的问题的示例代码:
[编辑]我正在使用:
g ++(Debian 4.3.2-1.1)4.3.2
GNU Make 3.81
test.h
#ifndef _test_h_
#define _test_h_
#include "iostream"
#if defined(MY_DEFINED_VALUE)
#if (MY_DEFINED_VALUE != 5)
#undef MY_DEFINED_VALUE
#define MY_DEFINED_VALUE 3
#endif //(MY_DEFINED_VALUE != 5)
#else //defined(MY_DEFINED_VALUE)
#error Error - MY_DEFINED_VALUE is not defined
#endif //defined(MY_DEFINED_VALUE)
class test
{
public:
int val;
test() {}
void show() { std::cout << "val = " << val << "\n"; }
};
#endif //_test_h_
Run Code Online (Sandbox Code Playgroud)
TEST.CPP
//#define MY_DEFINED_VALUE 5
#include "test.h"
int main()
{
test t;
t.val = …Run Code Online (Sandbox Code Playgroud) 有没有办法告诉你的localhost它可以进行跨域ajax调用?
我的测试需要这个.
如果是浏览器特定问题我正在使用谷歌浏览器.
干杯.
我的代码编译并运行,但我被告知这是很成问题的.我不明白我哪里出错了.
而且,声称"char _arrName [2];"并不是错误的.并做作业"_arrName [2] ='\ 0';" ?是不是一个"超出界限"的错误?
#include <iostream>
using namespace std;
class Base {
protected:
char* _name;
public:
virtual ~Base() { cout << "Base dtor of " << _name << endl; };
};
class D1: public Base {
char _arrName[2];
public:
D1() {
_name= _arrName;
_arrName[0]= 'D';
_arrName[1]= '1';
_arrName[2]= '\0';
}
virtual ~D1() { cout << "D1 dtor" << endl; }
};
int main () {
Base* arr[2];
arr[0]= new D1();
delete arr[0];
}
Run Code Online (Sandbox Code Playgroud) 在我的程序中,我需要在每次用户提取时更新文本文件的Balance列.我使用了write方法和append方法,但无济于事.用户登录后,该特定行将存储在数组中
#PIN AccountNo Balance
1598 01-10-102203-0 95000
4895 01-10-102248-0 45000
9512 01-10-102215-0 125000
6125 01-10-102248 85000
Run Code Online (Sandbox Code Playgroud)
代码:
try{
BufferedWriter out = new BufferedWriter(new FileWriter(".\\AccountInfo.txt",true));
if (amount <= 0.0) {
System.out.println("can only withdraw positive amount!");
transactionScreen();
}
else if (this.balance >= amount) {
if(amount>15000.0){
System.out.println("The maximum amount allowed per transaction is only Rs.15000/=");
transactionScreen();
}
else{
this.balance -= amount;
object.c=this.balance;
String newBal=Double.toString(this.balance);
out.write("");
//out.append("");
out.write(newBal);
//out.append(newBal);
}
}
else {
System.out.println("not enough money in account!");
transactionScreen();
}
}
catch(IOException e){
e.printStackTrace(); …Run Code Online (Sandbox Code Playgroud) 我试图从Vim切换到Emacs几个月并遇到了一个奇怪的问题:当font-lock打开时,在emacs中滚动变得非常慢.配置相关部分的示例:
(require 'vimpulse)
(require 'font-lock)
(require 'color-theme)
(global-font-lock-mode 1)
;;(setq font-lock-maximum-decoration t
;;font-lock-maximum-size nil)
;;(setq font-lock-support-mode 'fast-lock-mode ; lazy-lock-mode
;; fast-lock-cache-directories '("~/.emacs-flc"))
Run Code Online (Sandbox Code Playgroud)
即使是以几百行开头的相对较小的文件,它也很慢.似乎这不是一个非常普遍的问题,因为到目前为止我没有找到任何明确的解决方案.
GNU Emacs 23.1.1 Ubuntu 10.04
c++ ×2
ajax ×1
algorithm ×1
clojure ×1
destructor ×1
emacs ×1
emacs-faces ×1
font-lock ×1
g++ ×1
gif ×1
iis ×1
iis-7.5 ×1
java ×1
javascript ×1
localhost ×1
makefile ×1
text-files ×1