Russian Qt Forum
Мая 31, 2025, 09:49 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: QPixmap().toByteArray()  (Прочитано 5455 раз)
IGHOR
Крякер
****
Offline Offline

Сообщений: 390



Просмотр профиля WWW
« : Апреля 29, 2008, 06:43 »

Как достать из QPixmap QByteArray() ?
Нужно запросом записать QPixmap в базу MySql, это можно только через QByteArray правильно ?
Записан
Вячеслав
Гость
« Ответ #1 : Апреля 29, 2008, 12:09 »

через QVariant  и bindValue IMHO
Записан
Alex03
Гость
« Ответ #2 : Апреля 29, 2008, 12:33 »

ИМХО.
1. В БД правильнее хранить картинку в одном из общепринятых форматов (JPG, GIF, PNG и т.д., а то и в любом из них Улыбающийся ).
2. QPixmap - платформо зависимый класс, уж лучше использовать QImage.
Цитировать
Note that the pixel data in a pixmap is internal and is managed by the underlying window system. Pixels can only be accessed through QPainter functions or by converting the QPixmap to a QImage. Depending on the system, QPixmap is stored using a RGB32 or a premultiplied alpha format. If the image has an alpha channel, and if the system allows, the preferred format is premultiplied alpha. Note also that QPixmap, unlike QImage, may be hardware dependent. On X11 and Mac, a QPixmap is stored on the server side while a QImage is stored on the client side (on Windows, these two classes have an equivalent internal representation, i.e. both QImage and QPixmap are stored on the client side and don't use any GDI resources).
Записан
IGHOR
Крякер
****
Offline Offline

Сообщений: 390



Просмотр профиля WWW
« Ответ #3 : Апреля 29, 2008, 19:53 »

ну есть у меня файл c:\logo.png
как его с помощью Qt залить в базу ?
Записан
crossly
Гость
« Ответ #4 : Апреля 29, 2008, 21:04 »

Цитировать
bool QPixmap::save ( QIODevice * device, const char * format = 0, int quality = -1 ) const
This is an overloaded member function, provided for convenience.
This function writes a QPixmap to the given device using the specified image file format and quality factor. This can be used, for example, to save a pixmap directly into a QByteArray:
         QPixmap pixmap;
         QByteArray bytes;
         QBuffer buffer(&bytes);
         buffer.open(QIODevice::WriteOnly);
         pixmap.save(&buffer, "PNG"); // writes pixmap into bytes in PNG format
assistent рулит:)
Записан
IGHOR
Крякер
****
Offline Offline

Сообщений: 390



Просмотр профиля WWW
« Ответ #5 : Апреля 29, 2008, 21:09 »

Спасибо
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 2.679 секунд. Запросов: 23.