全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1568
推到 Plurk!
推到 Facebook!

是scanline讓我的圖只能列印1/3?

尚未結案
grace717
一般會員


發表:1
回覆:0
積分:0
註冊:2007-05-15

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-10-19 02:21:07 IP:140.127.xxx.xxx 訂閱

[code cpp]
//===========================================================================
//image_io file which is used to preprocess the images with BCB.
//===========================================================================
//---------------------------------------------------------------------------
#pragma hdrstop
#include
#pragma package(smart_init)
//---------------------------------------------------------------------------
//===========================================================================
// header files
//===========================================================================
#include "image_io.h"
//===========================================================================
//===========================================================================
// global data, the input image
//===========================================================================
Graphics::TBitmap *pBitmap = new Graphics::TBitmap();
int w,h;
//===========================================================================
//===========================================================================
// bmp display
// show bitbmp image into TImage object
//===========================================================================
void bmp_disp(Graphics::TBitmap *bmp, TImage *Image)
{
Image->Canvas->Draw(0,0,bmp);
Image->Width = bmp->Width;
Image->Height = bmp->Height;
}
//===========================================================================
//===========================================================================
// Bmp to Array
//used to create images in memory.
//===========================================================================
int* bmp2array(Graphics::TBitmap *bmp,int *wp,int *hp)
{
int i,j;
int *reg,*f;
Byte *ptr;
w=bmp->Width;
h=bmp->Height;
*wp=w;
*hp=h;
reg=new int[w*h];
f=reg;
for(j=0;j {
ptr=(Byte *)bmp->ScanLine[j];
for(i=0;i {
*(f )=(int) (*ptr );
}
}
return reg;
}
//===========================================================================
//===========================================================================
//Array to Bmp
//used to store image-in-memory as files on a disk.
//===========================================================================
void array2bmp(Graphics::TBitmap *bmp,int *g,int w,int h)
{
int i,j;
Byte *ptr;
//Byte *gtr;
bmp->Width=w;
bmp->Height=h;
for(j=0;j {
ptr=(Byte *)bmp->ScanLine[j];
for(i=0;i {
*ptr =(Byte) (*g );
}
}
}
//===========================================================================


[/code]


這是我的IO輸出部分的程式

scanline似乎讓我的8bit的bmp圖放大成24bit
照之前版上看到的處理方式(把w*3)都試過了
若強制轉成8bit又會讓原本的像素改變

請問有什麼比較好的方式嗎??
編輯記錄
grace717 重新編輯於 2007-10-19 02:30:34, 註解 無‧
arisaka_matsuri
高階會員


發表:25
回覆:205
積分:231
註冊:2003-10-19

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-10-22 17:16:13 IP:140.113.xxx.xxx 訂閱
不曉得你說的「scanline會放大...」是指用在array2bmp or bmp2array裡的哪一個?

我想問題可能跟傳入的TBitmap物件的PixelFormat沒有設定好有關
系統時間:2024-05-05 12:28:11
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!