当前位置:首页 > 代码 > 正文

bmp转代码(bmp转mp4)

admin 发布:2022-12-19 10:06 135


本篇文章给大家谈谈bmp转代码,以及bmp转mp4对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

bmp格式转换PNG格式 c语言或c++编程

BMP是最简单的图形存储格式,在c++里有朋友封装了一个类CDib.

只要把图片使用附件中编辑--粘贴来源找到图画打开另存为选择你想要的格式保存就可以了。也可以右键点击选择打开方式使用图画打开相同的方法。另外photoshop 和office2003的picture manage也有这个功能。

Private Sub mnuconvertBMPtoJPG_Click()

Dim tmpimage As imgdes ' Image descriptors

Dim tmp2image As imgdes

Dim rcode As Long

Dim quality As Long

Dim vbitcount As Long

Dim bdat As BITMAPINFOHEADER ' Reserve space for BMP struct

Dim bmp_fname As String

Dim jpg_fname As String

bmp_fname = "test.bmp"

jpg_fname = "test.jpg"

quality = 75

' Get info on the file we're to load

rcode = bmpinfo(bmp_fname, bdat)

If (rcode NO_ERROR) Then

MsgBox "Cannot find file", 0, "Error encountered!"

Exit Sub

End If

vbitcount = bdat.biBitCount

If (vbitcount = 16) Then ' 16-, 24-, or 32-bit image is loaded into 24-bit buffer

vbitcount = 24

End If

' Allocate space for an image

rcode = allocimage(tmpimage, bdat.biWidth, bdat.biHeight, vbitcount)

If (rcode NO_ERROR) Then

MsgBox "Not enough memory", 0, "Error encountered!"

Exit Sub

End If

' Load image

rcode = loadbmp(bmp_fname, tmpimage)

If (rcode NO_ERROR) Then

freeimage tmpimage ' Free image on error

MsgBox "Cannot load file", 0, "Error encountered!"

Exit Sub

End If

If (vbitcount = 1) Then ' If we loaded a 1-bit image, convert to 8-bit grayscale

' because jpeg only supports 8-bit grayscale or 24-bit color images

rcode = allocimage(tmp2image, bdat.biWidth, bdat.biHeight, 8)

If (rcode = NO_ERROR) Then

rcode = convert1bitto8bit(tmpimage, tmp2image)

freeimage tmpimage ' Replace 1-bit image with grayscale image

copyimgdes tmp2image, tmpimage

End If

End If

' Save image

rcode = savejpg(jpg_fname, tmpimage, quality)

freeimage tmpimage

End Sub

........... Add these defines and declarations to your Global module ...........

' Image descriptor

Type imgdes

ibuff As Long

stx As Long

sty As Long

endx As Long

endy As Long

buffwidth As Long

palette As Long

colors As Long

imgtype As Long

bmh As Long

hBitmap As Long

End Type

Type BITMAPINFOHEADER

biSize As Long

biWidth As Long

biHeight As Long

biPlanes As Integer

biBitCount As Integer

biCompression As Long

biSizeImage As Long

biXPelsPerMeter As Long

biYPelsPerMeter As Long

biClrUsed As Long

biClrImportant As Long

End Type

Declare Function bmpinfo Lib "VIC32.DLL" (ByVal Fname As String, bdat As BITMAPINFOHEADER) As Long

Declare Function allocimage Lib "VIC32.DLL" (image As imgdes, ByVal wid As Long, ByVal leng As Long, ByVal BPPixel As Long) As Long

Declare Function loadbmp Lib "VIC32.DLL" (ByVal Fname As String, desimg As imgdes) As Long

Declare Sub freeimage Lib "VIC32.DLL" (image As imgdes)

Declare Function convert1bitto8bit Lib "VIC32.DLL" (srcimg As imgdes, desimg As imgdes) As Long

Declare Sub copyimgdes Lib "VIC32.DLL" (srcimg As imgdes, desimg As imgdes)

Declare Function savejpg Lib "VIC32.DLL" (ByVal Fname As String, srcimg As imgdes, ByVal quality As Long) As Long

《图像处理----做一个自己的photoshop》

大部分都是源码,其中有bmp--jgep--GIF的代码.

如何用MATLAB把bmp格式变成灰度图像?

楼上回答正确,其实还可用更为简单的方法,此为图像处理中的基础,举简例说明。\x0d\x0a假设你需将名为face1.bmp的彩色图转换为face2.bmp的灰度图,代码如下:\x0d\x0aimageName=strcat('face1.bmp');%获取图像名称\x0d\x0aI=imread(imageName);%读取彩色图像\x0d\x0aJ=rgb2gray(I);%转换为灰度图\x0d\x0afigure(1);%窗口显示灰度图\x0d\x0aimshow(J);\x0d\x0afname=strcat('face2.bmp');\x0d\x0aimwrite(J,fname);%保存为BMP格式的灰度图face2

用C语言实现bmp文件转为jpg文件

BMP是最简单的图形存储格式,在c++里有朋友封装了一个类CDib.

只要把图片使用附件中编辑--粘贴来源找到图画打开另存为选择你想要的格式保存就可以了。也可以右键点击选择打开方式使用图画打开相同的方法。另外photoshop 和office2003的picture manage也有这个功能。

Private Sub mnuconvertBMPtoJPG_Click()

Dim tmpimage As imgdes ' Image descriptors

Dim tmp2image As imgdes

Dim rcode As Long

Dim quality As Long

Dim vbitcount As Long

Dim bdat As BITMAPINFOHEADER ' Reserve space for BMP struct

Dim bmp_fname As String

Dim jpg_fname As String

bmp_fname = "test.bmp"

jpg_fname = "test.jpg"

quality = 75

' Get info on the file we're to load

rcode = bmpinfo(bmp_fname, bdat)

If (rcode NO_ERROR) Then

MsgBox "Cannot find file", 0, "Error encountered!"

Exit Sub

End If

vbitcount = bdat.biBitCount

If (vbitcount = 16) Then ' 16-, 24-, or 32-bit image is loaded into 24-bit buffer

vbitcount = 24

End If

' Allocate space for an image

rcode = allocimage(tmpimage, bdat.biWidth, bdat.biHeight, vbitcount)

If (rcode NO_ERROR) Then

MsgBox "Not enough memory", 0, "Error encountered!"

Exit Sub

End If

' Load image

rcode = loadbmp(bmp_fname, tmpimage)

If (rcode NO_ERROR) Then

freeimage tmpimage ' Free image on error

MsgBox "Cannot load file", 0, "Error encountered!"

Exit Sub

End If

If (vbitcount = 1) Then ' If we loaded a 1-bit image, convert to 8-bit grayscale

' because jpeg only supports 8-bit grayscale or 24-bit color images

rcode = allocimage(tmp2image, bdat.biWidth, bdat.biHeight, 8)

If (rcode = NO_ERROR) Then

rcode = convert1bitto8bit(tmpimage, tmp2image)

freeimage tmpimage ' Replace 1-bit image with grayscale image

copyimgdes tmp2image, tmpimage

End If

End If

' Save image

rcode = savejpg(jpg_fname, tmpimage, quality)

freeimage tmpimage

End Sub

........... Add these defines and declarations to your Global module ...........

' Image descriptor

Type imgdes

ibuff As Long

stx As Long

sty As Long

endx As Long

endy As Long

buffwidth As Long

palette As Long

colors As Long

imgtype As Long

bmh As Long

hBitmap As Long

End Type

Type BITMAPINFOHEADER

biSize As Long

biWidth As Long

biHeight As Long

biPlanes As Integer

biBitCount As Integer

biCompression As Long

biSizeImage As Long

biXPelsPerMeter As Long

biYPelsPerMeter As Long

biClrUsed As Long

biClrImportant As Long

End Type

Declare Function bmpinfo Lib "VIC32.DLL" (ByVal Fname As String, bdat As BITMAPINFOHEADER) As Long

Declare Function allocimage Lib "VIC32.DLL" (image As imgdes, ByVal wid As Long, ByVal leng As Long, ByVal BPPixel As Long) As Long

Declare Function loadbmp Lib "VIC32.DLL" (ByVal Fname As String, desimg As imgdes) As Long

Declare Sub freeimage Lib "VIC32.DLL" (image As imgdes)

Declare Function convert1bitto8bit Lib "VIC32.DLL" (srcimg As imgdes, desimg As imgdes) As Long

Declare Sub copyimgdes Lib "VIC32.DLL" (srcimg As imgdes, desimg As imgdes)

Declare Function savejpg Lib "VIC32.DLL" (ByVal Fname As String, srcimg As imgdes, ByVal quality As Long) As Long

《图像处理----做一个自己的photoshop》

大部分都是源码,其中有bmp--jgep--GIF的代码.

求将BMP真彩图转化为黑白两色图片的C语言代码

这个其实很简单的,将bmp图标一二进制数据读入,没4个一组,第一个数据无用,后面三个分别为R、G、B,然后将这个三个数据改为三者的平方平均值:r=g=b=sqrt(R^2+G^2+B^2)/3即可

用matlab如何把bmp转换jpg代码

%

图像不同类型之间的转化

%

对应参数的设置

%

JPEG

jpg

‘Quality’

[0,100]间任意值,默认为75

%

TIFF

tif

‘Compression’

‘none’或‘packbits’二位图为‘ccitt’

%

HDF

hdf

‘Compression’

‘none’‘rle’或‘jpeg’默认‘rle’

[X,cmap]=imread('gz.bmp');

imwrite(X,'gz1.jpg','Quality')

%将图像以JPEG格式保存

imfinfo('gz1.jpg')

%读取图像的特征信息

24位bmp顺时针旋转90度C++代码求查错

参考一下VC++数字图像处理类的书,下面是一个类似的,自己看看有什么帮助吗

/***********************************************************************

* 函数名称:

* Anticlockwise90()

*

*

*说明:对图像逆时针旋转90度

***********************************************************************/

void GeometryTrans::Anticlockwise90()

{

//释放旧的输出图像缓冲区

if(m_pImgDataOut!=NULL){

delete []m_pImgDataOut;

m_pImgDataOut=NULL;

}

//输入图像每行像素字节数 int lineByte=(m_imgWidth*m_nBitCount/8+3)/4*4;

//输出图像的宽和高

m_imgWidthOut=m_imgHeight;

m_imgHeightOut=m_imgWidth;

//输出图像每行像素字节数 int lineByteOut=(m_imgWidthOut*m_nBitCount/8+3)/4*4;

//申请缓冲区,存放输出结果 m_pImgDataOut=new unsigned char[lineByteOut*m_imgHeightOut];

//循环变量,图像坐标 int i,j;

//循环变量,像素的每个通道 int k;

//每像素字节数,输出图像与输入图像相等 int pixelByte=m_nBitCountOut/8;

//逆时针90度

for(i=0;im_imgHeightOut;i++){

for(j=0;jm_imgWidthOut;j++){

for(k=0;kpixelByte;k++)

*(m_pImgDataOut+i*lineByteOut+j*pixelByte+k)

=*(m_pImgData+(m_imgHeight-1-j)*lineByte+i*pixelByte+k);

}

}

}

bmp转代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于bmp转mp4、bmp转代码的信息别忘了在本站进行查找喔。

标签:

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/6426.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载