如何使用C ++读取8位灰度JPEG图像? [英] How to read a 8-bit grayscale JPEG image using C++?

查看:88
本文介绍了如何使用C ++读取8位灰度JPEG图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




您能告诉我使用C ++读取8位

灰度JPEG的最简单代码是什么?


非常感谢,

速度。

Hi,

Could you please tell me what is the simplest code to read a 8-bit
grayscale JPEG using C++?

Thanks a ton,
Speed.

推荐答案

Speed写道:
Speed wrote:




能告诉我8位读取的最简单的代码是什么

使用C ++的灰度JPEG?
Hi,

Could you please tell me what is the simplest code to read a 8-bit
grayscale JPEG using C++?



你在comp.lang.c中问了同样的基本问题。选择一种语言。


Brian

You asked the same basic question in comp.lang.c. Pick a language.


Brian


默认用户写道:
Default User wrote:

Speed写道:
Speed wrote:

>

你能告诉我什么是最简单的代码来阅读使用C ++的8位
灰度JPEG?
>Hi,

Could you please tell me what is the simplest code to read a 8-bit
grayscale JPEG using C++?



你在comp.lang.c中问了同样的基本问题。选择一种语言。


You asked the same basic question in comp.lang.c. Pick a language.



你确定它是同一个问题吗?我希望那个,那边,他好b $ b已经问过


你能告诉我什么是读取8位的最简单的代码
使用C的灰度JPEG?

在这种情况下,也许他希望在收到答案后推迟选择语言,直到



对OP:C ++标准没有对JPEG

文件做出任何特殊规定。尽管你可能正在寻找一个l3rd派对图书馆

解决方案,但请注意这些是在这个组中的偏离主题。


阅读二进制文件完全进入内存,你可以在C ++中使用这样的代码




#include< iterator>

#包括< fstream>

#include< vector>

#include< iostream>


typedef std :: vector< ; char缓冲区;


int main(void){

//读取文件:

std :: ifstream infile(" speed_001.cc",std :: ios :: binary);

缓冲区the_buf(std :: istreambuf_iterator< char>(infile),

(std :: istreambuf_iterator< char>()));

//写数据:

std :: cout<< the_buf.size()<< ''\ n'';

std :: copy(the_buf.begin(),the_buf.end(),

std :: ostream_iterator< char>(std :: cout,""));

std :: cout<< ''\ n'';

}

最好


Kai-Uwe Bux

Are you sure it was the same question? I would expect that, over there, he
had asked

Could you please tell me what is the simplest code to read a 8-bit
grayscale JPEG using C?
In that case, maybe he would like to defer the choice of the language until
after he received answers.
To the OP: the C++ standard does not make any special provisions for JPEG
files. In as much as you might be looking for a l3rd party library
solution, please note that those are off-topic in this group.

To read a binary file completely into memory, you could use code like this
in C++:

#include <iterator>
#include <fstream>
#include <vector>
#include <iostream>

typedef std::vector< char buffer;

int main ( void ) {
// read file:
std::ifstream infile ( "speed_001.cc", std::ios::binary );
buffer the_buf ( std::istreambuf_iterator<char>( infile ),
(std::istreambuf_iterator<char>()) );
// write data:
std::cout << the_buf.size() << ''\n'';
std::copy( the_buf.begin(), the_buf.end(),
std::ostream_iterator<char>( std::cout, "" ) );
std::cout << ''\n'';
}
Best

Kai-Uwe Bux




Speed< lo ********** @ gmail.comwrote in message ...

Speed <lo**********@gmail.comwrote in message...

您好,

您能否告诉我使用C ++读取8位

灰度JPEG的最简单代码是什么?

非常感谢,

速度。
Hi,
Could you please tell me what is the simplest code to read a 8-bit
grayscale JPEG using C++?
Thanks a ton,
Speed.



#include< iostream>

#include< fstream>

#include< vector>


{

std :: ifstream PicIn(" MyPic.jpg",

std :: ios_base :: in | std :: ios_base :: binary);

if(not PicIn.is_open()){

std :: cout<<" \ n FAILED"< ;< std :: endl;

返回EXIT_FAILURE;

}

std :: vector< unsigned charImage;


while(PicIn.peek()!= EOF){//你没说''最快''< G>

Image.push_back(PicIn.get) ());

}


std :: cout<<" \ n Image.size()="

<<< Image.size()<<"" bytes。"<< std :: endl;

PicIn.close();

}


-

Bob R

POVrookie

#include <iostream>
#include <fstream>
#include <vector>

{
std::ifstream PicIn( "MyPic.jpg",
std::ios_base::in | std::ios_base::binary );
if( not PicIn.is_open() ){
std::cout<<"\n FAILED"<<std::endl;
return EXIT_FAILURE;
}
std::vector<unsigned charImage;

while( PicIn.peek() != EOF ){ // you didn''t say ''fastest'' <G>
Image.push_back( PicIn.get() );
}

std::cout<<"\n Image.size() = "
<<Image.size()<<" bytes."<<std::endl;
PicIn.close();
}

--
Bob R
POVrookie


这篇关于如何使用C ++读取8位灰度JPEG图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆