Article View: borland.public.cppbuilder.nativeapi
Article #13569Re: how to send directly the bitmap pixel to a postscript printer ?
From: Richard Yu
Date: Fri, 03 Oct 2003 18:02
Date: Fri, 03 Oct 2003 18:02
125 lines
4090 bytes
4090 bytes
yes,
supplied is a working ver,
for the following code,
if size is 50 by 50, ok
if size 150 by 150, wrong result.
aBmp->Width=150; or 50
aBmp->Height=150; or 50
my c code like this:
void __fastcall TForm1::PrintBMPpsFileClick(TObject *Sender)
{
DWORD count;
char *buffer;
HANDLE printer;
DOC_INFO_1 di;
DWORD written;
char *port;
DWORD BytesCopied;// Number of bytes returned
char PrinterName[80];
String aLine;
String aPrinterName;
Graphics::TBitmap *aBmp=new Graphics::TBitmap;
aBmp->Width=150;
aBmp->Height=150;
aBmp->PixelFormat=pf24bit;
TStringList *aPSList=new TStringList;
GetDefaultPrinter(PrinterName, &BytesCopied);//ok
port=PrinterName;
aPrinterName=PrinterName;
aPSList->Add(" %! ");
aPSList->Add("10 10 translate ");
aLine=IntToStr(aBmp->Width)+" "+IntToStr(aBmp->Height)+" scale";
aPSList->Add(aLine);
aLine=IntToStr(aBmp->Width)+" "+IntToStr(aBmp->Height)+" 8 ["
+IntToStr(aBmp->Width)+" 0 0 -"+IntToStr(aBmp->Height)
+" 0 "+IntToStr(aBmp->Height)+"]";
aPSList->Add(aLine);
aPSList->Add("{<");
aPSList->Add(">}");
aPSList->Add("false 3 colorimage");
aPSList->Add("showpage");
buffer = (char *)malloc(PRINT_BUF_SIZE);
OpenPrinterA(port, &printer, NULL);
di.pDocName ="";// wbuf;
di.pOutputFile = NULL;
di.pDatatype = TEXT("RAW");
StartDocPrinter(printer, 1, (LPBYTE)&di);
<file://write> ps header list
for(int i=0;i< aPSList->Count-3;i++)
{
aLine=aPSList->Strings[i]+" \r\n";
buffer=aLine.c_str();
WritePrinter(printer, (LPVOID)buffer, aLine.Length(), &written);
}
<file://write> image pixels
String aRGBLine,aRGBHexPixel;
for(int j=0;j< aBmp->Height;j++)
{
aRGBLine="";
for(int i=0;i<aBmp->Width;i++)
{
aBmp->Canvas->Pixels[i][j]=TColor(RGB(255,250,240));//test a single color
image
aRGBHexPixel=PixelToHexStr(aBmp->Canvas->Pixels[i][j]);
<file://aRGBLine+=aRGBHexPixel>;
aLine=aRGBHexPixel+" \r\n";
buffer=aLine.c_str();
WritePrinter(printer, (LPVOID)buffer, aLine.Length(), &written);
}
}
<file://write> tail list
for(int i=aPSList->Count-3 ;i< aPSList->Count;i++)
{
aLine=aPSList->Strings[i]+" \r\n";
buffer=aLine.c_str();
WritePrinter(printer, (LPVOID)buffer, aLine.Length(), &written);
}
EndDocPrinter(printer);
ClosePrinter(printer);
}
thanks for help.
"Chris Hill" <Chris244@aol.com> wrote in message
news:3f7cee1e.2885516513@forums.borland.com...
> On Thu, 2 Oct 2003 15:05:45 -0700, "Richard Yu"
> <richard@colorselector.com> wrote:
> >for this small image size, it's ok, but when I increase the size a bit,
like
> >100 by 100,
>
> You haven't given enough information to answer your question. If I
> understand your question, you have provided the working version of the
> PostSctipt code but not the malfunctioning code.
>
> What is different about the 100x100 image? Have you changed all the
> associated numbers (width, height, matrix) as well as the image data
> itself?
>
> Chris Hill
> Chris244@aol.com
Technical Details
Message-ID:
<3f7db9fd$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!yellow.newsread.com!netaxs.com!newsread.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f7ca16a$1@newsgroups.borland.com> <3f7cee1e.2885516513@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,11a834cdc185b9c2 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-10-03 11:12:07 PST From: "Richard Yu" <richard@colorselector.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f7ca16a$1@newsgroups.borland.com> <3f7cee1e.2885516513@forums.borland.com> Subject: Re: how to send directly the bitmap pixel to a postscript printer ? Date: Fri, 3 Oct 2003 11:02:53 -0700 Lines: 127 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 24.207.7.224 Message-ID: <3f7db9fd$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1065204221 24.207.7.224 (3 Oct 2003 11:03:41 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!yellow.newsread.com!netaxs.com!newsread.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail