本文整理汇总了C++中AnsiString::WideChar方法的典型用法代码示例。如果您正苦于以下问题:C++ AnsiString::WideChar方法的具体用法?C++ AnsiString::WideChar怎么用?C++ AnsiString::WideChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnsiString
的用法示例。
在下文中一共展示了AnsiString::WideChar方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BrouseFile
// ôóíêöèÿ îòêðûòèÿ ôàéëà äëÿ ïðîñìîòðà ñ âõîäÿùèì ïàðàìåòðîì - èìåíåì îòêðûâàåìîãî ãðàôè÷åñêîãî ôàéëà
void BrouseFile(AnsiString FN)
{ float ho=0;
float wo;
if (FN!=""){//åñëè èìÿ ôàéëà óêàçàíî òî âûïîëíèòü äåéñòâèÿ
Form1->Image1->Align=alClient;//ðàçâîðà÷èâàåì îáëàñòü ïðîñìîòðà íà âñþ äîñòóïíþ ïëîùàäü
Form1->Image1->Picture->Assign(0);//î÷èùàåì îáëàñòü ïðîñìîòðà
WCHAR buff[10001];
Graphics::TBitmap *Buf = new Graphics::TBitmap();//ñîçäàåì îáúåêò êëàññà TBitmap
Gdiplus::Image *image =new Gdiplus::Image (FN.WideChar(buff,10000)); //ñîçäàåì îáúåêò êëàññà Gdiplus::Image è çàãðóæàåì â íåãî èçîáðàæåíèå èç âûáðàííîãî ôàéëà
Buf->Width=image->GetWidth();//óêàçûâàåì øèðèíó è âûñîòó èçîáðàæåíèÿ
Buf->Height=image->GetHeight();
Gdiplus::Graphics graphics(Buf->Canvas->Handle);//ïåðåäàåì óêàçàòåëü íà îáúåêò Buf
graphics.DrawImage(image, 0, 0, image->GetWidth(), image->GetHeight());
//ïðîðèñîâûâàåì âçÿòîå èç ôàéëà èçîáðàæåíèå â îáúåêòå Buf
Form1->Image1->Picture->Assign(Buf);//âûâîäì ïðîðèñîâàííîå èçîáðàæåíèå â îáëàñòü ïðîñìîòðà
Form1->ScrollBox1->Refresh();//îáíîâëÿåì ðàçìåðíîñòü îáëàñòè ïðîñìîòðà
z_min=1;//èíèöèàëèçèðåì ïåðåìåííûå ìàñøàáèðîâàíèÿ
z_max=1;
Form1->StatusBar1->Panels->Items[1]->Text="Ôàéë - "+Form1->FileListBox1->Items->Strings[Form1->FileListBox1->ItemIndex];//âûâîäèì ñëóæåáíóþ èíôîðìàöèþ
Form1->StatusBar1->Panels->Items[2]->Text="Ðàçìåð - "+IntToStr(image->GetWidth())+"x"+IntToStr(image->GetHeight());
//
B->Assign(0);//î÷èùàåì ðåçåðâíûé îáúåêò êëàññà TBitmap
B->Width=Form1->Image1->Picture->Bitmap->Width;//çàäàåì ðàçìåðû ðåçåðâíîãî îáúåêòà
B->Height=Form1->Image1->Picture->Bitmap->Height;
B->Canvas->Draw(0,0,Form1->Image1->Picture->Bitmap);//ïðîðèñîâûâàåì èçîáðàæåíèå â ðåçåðâíîì îáúåêòå èç îáëàñòè ïðîñìîòðà
//åñëè êàðòèíêà èçíà÷àëüíî áîëüøå îáëàñòè ïðîñìîòðà
//òî îíà áóäåò àâòîìàòè÷åñêè óìåíüøåíà
//äàëåå îïðåäåëÿåì êîýô. óìåíüøåíèÿ
if ((B->Height>Form1->Image1->Height)||(B->Width>Form1->Image1->Width)) //åñëè ïàðìåòðû êàðòèíêè ïðåâûøàþò ïàðàìåòðû îáëàñòè
{
ho=float(Form1->Image1->Height)/float(B->Height); //âû÷èñëÿåì ñîîòíîøåíèÿ âåëè÷èí
wo=float(Form1->Image1->Width)/float(B->Width);
if (ho>wo) //îïåðåäåëÿåì áîëüøóþ èç âåëè÷èí, ÷òîáû èçîáðàæåíèå ïîìåñòèëîñü â îáëàñòè ïðîñìîòðà
{z_min=1+ho;} //óñòàíàâëèâàåì êîýô.
else {z_min=1+wo;}
}
delete image;//î÷èùàåì ïàìÿòü
delete Buf;
}
}
示例2: save
//---------------------------------------------------------------------------
void save()
{
FILE * pFile;
int returnValue = 0;
int FilterIndex = 0;
AnsiString FileName;
AnsiString MSG;
FileName = ChangeFileExt(FormSave->EditSave->Text, FormSave->LabelSave->Caption);
if (FormSave->LabelSave->Caption == ".png") {
FilterIndex = 1;
}
if (FormSave->LabelSave->Caption == ".bmp") {
FilterIndex = 2;
}
if (FormSave->LabelSave->Caption == ".gif") {
FilterIndex = 3;
}
if (FormSave->LabelSave->Caption == ".tif") {
FilterIndex = 4;
}
if (FormSave->LabelSave->Caption == ".jpg") {
FilterIndex = 5;
}
pFile = fopen(FileName.c_str(), "r");
if (pFile == NULL) {
returnValue = 6;
} else {
fclose(pFile);
MSG = FileName + " existiert bereits.\nMöchten Sie die Datei ersetzen?";
returnValue = MessageBox(NULL, MSG.c_str(), "Datei speichern", MB_YESNO | MB_ICONEXCLAMATION);
}
if (returnValue == 6) {
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
CLSID encoderClsid;
Image* image;
WCHAR filename[1024];
FormGraph->PaintBox->Picture->SaveToFile("graph.tmp");
image = new Image(L"graph.tmp");
if (FilterIndex == 1) {
GetEncoderClsid(L"image/png", &encoderClsid);
}
if (FilterIndex == 2) {
GetEncoderClsid(L"image/bmp", &encoderClsid);
}
if (FilterIndex == 3) {
GetEncoderClsid(L"image/gif", &encoderClsid);
}
if (FilterIndex == 4) {
GetEncoderClsid(L"image/tiff", &encoderClsid);
}
if (FilterIndex == 5) {
GetEncoderClsid(L"image/jpeg", &encoderClsid);
}
image->Save((FileName.WideChar(filename, 1024)), &encoderClsid, NULL);
delete image;
GdiplusShutdown(gdiplusToken);
remove("graph.tmp");
}
FormSave->Visible = false;
}
示例3: FlipCurPage
void __fastcall TTiffBook::FlipCurPage(int n) {
//-------------------------------------------------------------------------------
// Переворачивает текущую страницу вверх ногами |
// n - номер страницы, который надо нанести. <= 0 - только убрать ном стр |
//-------------------------------------------------------------------------------
stop++;
Gdiplus::Graphics *g32;
TTiffImage *img = GetImagePage(GetPage());
Gdiplus::Bitmap *fbm = img->fbm;
Gdiplus::Rect r;
int w = fbm->GetWidth(), h = fbm->GetHeight();
// g = new Gdiplus::Graphics(fbm);
Gdiplus::Bitmap *b32 = new Gdiplus::Bitmap(w, h, PixelFormat32bppARGB);
g32 = new Gdiplus::Graphics(b32);
Gdiplus::Matrix matr;
matr.Rotate(180.0f); // поворачиваем его на 270 градусов
g32->SetTransform(&matr);
//r.X = 0;
//r.Y = 0;
//r.Width = w;
//r.Height = h;
//r.X = -SaveBitmapH;
//r.Y = -30;
//r.Width = SaveBitmapH - 30;
//r.Height = SaveBitmapW - 30;
r.X = -w;
r.Y = -h;
r.Width = w;
r.Height = h;
sres = g32->DrawImage(fbm, r, 0, 0, w, h, Gdiplus::UnitPixel, 0, 0, 0);
matr.Reset();
g32->SetTransform(&matr);
// Удаляем черные полосы сверху и снизу
Gdiplus::Pen whitePen2(Gdiplus::Color(255, 255, 255, 255), 2);
g32->DrawLine(&whitePen2, 0, 0, w, 0);
g32->DrawLine(&whitePen2, 0, h-1, w, h-1);
// Удаляем старый номер страницы - он теперь внизу
// Gdiplus::Pen whitePen40(Gdiplus::Color(255, 0, 0, 0), 45); // ??? Пока черный - для отладки!
Gdiplus::Pen whitePen40(Gdiplus::Color(255, 255, 255, 255), 45);
g32->DrawLine(&whitePen40, 0, h - 50, 200, h - 50);
if (n > 0) { // Здесь выводим номер страницы
AnsiString snum;
wchar_t wnum[20];
snum.printf("%d", n);
snum.WideChar(wnum, 20);
Gdiplus::Font myFont(L"Arial", 40, Gdiplus::FontStyleBold);
Gdiplus::PointF origin(w - 160, 20.0f);
Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));
g32->DrawLine(&whitePen40, w - 200, 50, w, 50);
sres = g32->DrawString(wnum, -1, &myFont, origin, &blackBrush);
}
//if (npage > 0) { // Здесь выводим номер страницы
// AnsiString snum;
// wchar_t wnum[20];
// snum.printf("%d", npage);
// snum.WideChar(wnum, 20);
// Gdiplus::Font myFont(L"Arial", 40, Gdiplus::FontStyleBold);
// Gdiplus::PointF origin(SaveBitmapW - 160, 20.0f);
// Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));
// SaveBitmap2TiffGraphics->DrawString(wnum, -1, &myFont, origin, &blackBrush);
//}
// ------- строим SaveBitmap2TiffBitmap1
UINT *pix;
unsigned char byte, bit, *pix1;
Gdiplus::Bitmap *b1 = new Gdiplus::Bitmap(w, h, PixelFormat1bppIndexed);
Gdiplus::Rect BitsRect(0, 0, w, h);
Gdiplus::BitmapData *bits = new Gdiplus::BitmapData;
Gdiplus::BitmapData *bits1 = new Gdiplus::BitmapData;
sres = b32->LockBits(&BitsRect, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, bits);
sres = b1->LockBits(&BitsRect, Gdiplus::ImageLockModeWrite, PixelFormat1bppIndexed, bits1);
for (int y = 0; y < h; y++) {
pix = (UINT *)((int)bits->Scan0 + bits->Stride * y);
pix1 = (unsigned char *)((int)bits1->Scan0 + bits1->Stride * y);
byte = 0;
for (int x = 0; x < w; x++, pix++) {
if ((*pix & 0xFF) > 0xD8) {
bit = 1;
}
else bit = 0;
byte <<= 1; byte |= bit;
if ((x & 7) == 7) {
*pix1++ = byte;
byte = 0;
}
}
//.........这里部分代码省略.........
示例4: DrawCenter
void __fastcall TTiffImage::DrawCenter(TCanvas *c, int xc, int yc, int w1, int h1, int PageNumber) {
//-------------------------------------------------------------------------------
// Рисует текущую страницу с центром (xc, yc) |
// Масштабирует пропроционально, в итоге будет заполнено либо w, либо h |
//-------------------------------------------------------------------------------
if (fbm == NULL) return;
Gdiplus::Graphics *gra, *g32;
Gdiplus::Bitmap *b32;
Gdiplus::Rect r;
int w = fbm->GetWidth(), h = fbm->GetHeight();
b32 = new Gdiplus::Bitmap(w, h, PixelFormat32bppARGB);
g32 = new Gdiplus::Graphics(b32);
r.X = 0;
r.Y = 0;
r.Width = w;
r.Height = h;
sres = g32->DrawImage(fbm, r, 0, 0, w, h, Gdiplus::UnitPixel, 0, 0, 0);
if (PageNumber != 0) { // Надо выводить номер страницы?
AnsiString snum;
wchar_t wnum[20];
Gdiplus::Pen whitePen40(Gdiplus::Color(255, 255, 255, 255), 45);
snum.printf("%d", PageNumber);
snum.WideChar(wnum, 20);
Gdiplus::Font myFont(L"Arial", 40, Gdiplus::FontStyleBold);
Gdiplus::PointF origin(w - 160, 20.0f);
Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));
g32->DrawLine(&whitePen40, w - 200, 50, w, 50);
if (PageNumber > 0) {
sres = g32->DrawString(wnum, -1, &myFont, origin, &blackBrush);
}
}
w = w1; h = h1;
gra = new Gdiplus::Graphics(c->Handle);
//if (CanvasHandle != c->Handle) {
// if (CanvasHandle != NULL) delete gra;
// CanvasHandle = c->Handle;
// gra = new Gdiplus::Graphics(CanvasHandle);
//}
double scalex = (double)w / GetWidth();
double scaley = (double)h / GetHeight();
double scale = scalex < scaley ? scalex : scaley;
w = round(GetWidth() * scale);
h = round(GetHeight() * scale);
xc -= w / 2;
yc -= h / 2;
Gdiplus::Rect dst(xc, yc, w, h);
// gra->DrawImage(fbm, dst, 0, 0, GetWidth(), GetHeight(), Gdiplus::UnitPixel, 0, 0, 0);
gra->DrawImage(b32, dst, 0, 0, GetWidth(), GetHeight(), Gdiplus::UnitPixel, 0, 0, 0);
delete gra;
delete g32;
delete b32;
}
示例5: whiteBrush
static void __fastcall SaveBitmap2Tiff(Gdiplus::Bitmap *bm, int npage) {
//-------------------------------------------------------------------------------
// Выводит очередную страницу в файл *.tif |
// Если npage == 0, то не выводит номер страницы |
// Полагает, что если это многостраничный файл, то страница уже выбрана |
//-------------------------------------------------------------------------------
if (SaveBitmap2TiffState == 0) return;
// ------------------ для начала строим образ в SaveBitmap2TiffBitmap32 (SaveBitmap2TiffGraphics)
int x, y, w, h;
h = bm->GetHeight();
w = bm->GetWidth();
Gdiplus::SolidBrush whiteBrush(Gdiplus::Color(255, 255, 255, 255));
SaveBitmap2TiffGraphics->FillRectangle(&whiteBrush, Gdiplus::Rect(0, 0, SaveBitmapW, SaveBitmapH));
//Gdiplus::Matrix matr;
Gdiplus::Rect r;
//if (w > h) { // Если изображение шире, чем выше
// matr.Rotate(270.0f); // поворачиваем его на 270 градусов
// SaveBitmap2TiffGraphics->SetTransform(&matr);
// r.X = -SaveBitmapH;
// r.Y = -30;
// r.Width = SaveBitmapH - 30;
// r.Height = SaveBitmapW - 30;
//} else {
// r.X = 30;
// r.Y = 0;
// r.Width = SaveBitmapW - 30;
// r.Height = SaveBitmapH - 30;
//}
r.X = 0;
r.Y = 0;
r.Width = SaveBitmapW;
r.Height = SaveBitmapH;
SaveBitmap2TiffGraphics->DrawImage(bm, r, 0, 0, w, h, Gdiplus::UnitPixel, 0, 0, 0);
// matr.Reset();
// SaveBitmap2TiffGraphics->SetTransform(&matr);
if (npage != 0) { // Здесь выводим номер страницы
AnsiString snum;
wchar_t wnum[20];
Gdiplus::Pen whitePen40(Gdiplus::Color(255, 255, 255, 255), 45);
snum.printf("%d", npage);
snum.WideChar(wnum, 20);
Gdiplus::Font myFont(L"Arial", 40, Gdiplus::FontStyleBold);
Gdiplus::PointF origin(SaveBitmapW - 160, 20.0f);
Gdiplus::SolidBrush blackBrush(Gdiplus::Color(255, 0, 0, 0));
SaveBitmap2TiffGraphics->DrawLine(&whitePen40, SaveBitmapW - 200, 50, SaveBitmapW, 50);
if (npage > 0) {
SaveBitmap2TiffGraphics->DrawString(wnum, -1, &myFont, origin, &blackBrush);
}
}
// ------- строим SaveBitmap2TiffBitmap1
UINT *pix;
unsigned char byte, bit, *pix1;
w = SaveBitmapW; h = SaveBitmapH;
Gdiplus::Rect BitsRect(0, 0, SaveBitmapW, SaveBitmapH);
Gdiplus::BitmapData *bits = new Gdiplus::BitmapData;
Gdiplus::BitmapData *bits1 = new Gdiplus::BitmapData;
sres = SaveBitmap2TiffBitmap32->LockBits(&BitsRect, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, bits);
sres = SaveBitmap2TiffBitmap1->LockBits(&BitsRect, Gdiplus::ImageLockModeWrite, PixelFormat1bppIndexed, bits1);
for (y = 0; y < SaveBitmapH; y++) {
pix = (UINT *)((int)bits->Scan0 + bits->Stride * y);
pix1 = (unsigned char *)((int)bits1->Scan0 + bits1->Stride * y);
byte = 0;
for (x = 0; x < SaveBitmapW; x++, pix++) {
if ((*pix & 0xFF) > 0xD8) {
bit = 1;
}
else bit = 0;
byte <<= 1; byte |= bit;
if ((x & 7) == 7) {
*pix1++ = byte;
byte = 0;
}
}
}
SaveBitmap2TiffBitmap32->UnlockBits(bits); delete bits;
SaveBitmap2TiffBitmap1->UnlockBits(bits1); delete bits1;
// ------- и наконец выводим очередную страницу SaveBitmap2TiffBitmap1
Gdiplus::EncoderParameters encoderParameters;
ULONG parameterValue;
// An EncoderParameters object has an array of
// EncoderParameter objects. In this case, there is only
// one EncoderParameter object in the array.
encoderParameters.Count = 1;
// Initialize the one EncoderParameter object.
//.........这里部分代码省略.........